public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Anton Mikanovich <amikan@ilbers.de>, isar-users@googlegroups.com
Subject: Re: [PATCH v1 5/5] events: Unmount all lost mounts at task fail
Date: Thu, 8 Jul 2021 14:24:23 +0200	[thread overview]
Message-ID: <61de5d8d-08d4-9760-3467-d0313b3cb702@siemens.com> (raw)
In-Reply-To: <20210707163851.204296-6-amikan@ilbers.de>

On 07.07.21 18:38, Anton Mikanovich wrote:
> Perform mounts cleanup in case task fail.
> 
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
>  meta/classes/isar-events.bbclass | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/meta/classes/isar-events.bbclass b/meta/classes/isar-events.bbclass
> index 73419b4..50f5cb3 100644
> --- a/meta/classes/isar-events.bbclass
> +++ b/meta/classes/isar-events.bbclass
> @@ -4,6 +4,25 @@
>  # Copyright (C) 2015-2017 ilbers GmbH
>  # Copyright (c) Siemens AG, 2018
>  
> +def is_mounted(d, mountpoint, subpath=None):
> +    path = d.getVar(mountpoint, True)
> +    if path:
> +        if subpath:
> +            path = os.path.join(path, subpath)
> +        path = os.path.realpath(path)
> +        with open('/proc/mounts') as f:
> +            for line in f.readlines():
> +                if path in line:
> +                    return True
> +    return False
> +
> +def safe_exec(func, d):
> +    try:
> +        if d.getVar(func, False):
> +            bb.build.exec_func(func, d)
> +    except Exception:
> +        pass
> +
>  addhandler build_started
>  
>  python build_started() {
> @@ -35,6 +54,14 @@ python task_failed() {
>      # Avoid false positives if a second target depends on this task and retries
>      # the execution after the first failure.
>      os.remove(task_once_stamp(d))
> +
> +    # Cleanup possible lost mounts
> +    if is_mounted(d, 'BUILDROOT_DEPLOY'):
> +        safe_exec("image_undo_mounts", d)
> +    if is_mounted(d, 'BUILDROOT'):
> +        safe_exec("dpkg_undo_mounts", d)
> +    if is_mounted(d, 'ROOTFSDIR', 'dev'):
> +        safe_exec("rootfs_undo_mounts", d)
>  }
>  task_failed[eventmask] = "bb.build.TaskFailed"
>  
> 

No looping, so everything you miss here will continue to be cleaned up
by build_completed() - so what's the point of these changes?

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux

  reply	other threads:[~2021-07-08 12:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-07 16:38 [PATCH v1 0/5] Restore downstream mounts compatibility Anton Mikanovich
2021-07-07 16:38 ` [PATCH v1 1/5] Revert "dpkg: Make mount buildroot reliable" Anton Mikanovich
2021-07-08 12:16   ` Jan Kiszka
2021-07-07 16:38 ` [PATCH v1 2/5] mount: Allow calling unmount on not mounted paths Anton Mikanovich
2021-07-08 12:17   ` Jan Kiszka
2021-07-07 16:38 ` [PATCH v1 3/5] dpkg: Remove unmount loop Anton Mikanovich
2021-07-08 12:21   ` Jan Kiszka
2021-07-08 14:35     ` Anton Mikanovich
2021-07-08 16:16       ` Jan Kiszka
2021-08-17 13:02     ` Anton Mikanovich
2021-07-07 16:38 ` [PATCH v1 4/5] image: Add reference counter Anton Mikanovich
2021-07-07 16:38 ` [PATCH v1 5/5] events: Unmount all lost mounts at task fail Anton Mikanovich
2021-07-08 12:24   ` Jan Kiszka [this message]
2021-07-08 14:41     ` Anton Mikanovich
2021-07-08 16:28       ` Jan Kiszka
2021-07-12 16:08         ` Baurzhan Ismagulov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=61de5d8d-08d4-9760-3467-d0313b3cb702@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=amikan@ilbers.de \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox