public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Cc: Cedric Hombourger <Cedric_Hombourger@mentor.com>
Subject: [PATCH 2/3] isar-events: Improve umount handler
Date: Wed,  5 Dec 2018 10:29:49 +0100	[thread overview]
Message-ID: <b1dccfd211da98c1c132ca531fd2b8b17d26c1be.1544002190.git.jan.kiszka@siemens.com> (raw)
In-Reply-To: <cover.1544002190.git.jan.kiszka@siemens.com>
In-Reply-To: <cover.1544002190.git.jan.kiszka@siemens.com>

From: Jan Kiszka <jan.kiszka@siemens.com>

Using lazy umount avoids having to loop over the mount points.
Furthermore, also triggering on runQueueExitWait allows to perform the
umount earlier. Finally, filter for the events we actually want.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 meta/classes/isar-events.bbclass | 38 +++++++++++++-------------------------
 1 file changed, 13 insertions(+), 25 deletions(-)

diff --git a/meta/classes/isar-events.bbclass b/meta/classes/isar-events.bbclass
index b3ce434..05b27e5 100644
--- a/meta/classes/isar-events.bbclass
+++ b/meta/classes/isar-events.bbclass
@@ -6,34 +6,22 @@
 
 addhandler isar_handler
 
-python isar_handler () {
+python isar_handler() {
     import subprocess
-    import time
+    import bb.runqueue
 
-    def umount_all(basepath):
-        # '/proc/mounts' contains all the active mounts, so knowing basepath
-        # we can get the list of mounts for the specific multiconfig and
-        # clean them.
-        result = True
+    tmpdir = d.getVar('TMPDIR', True)
+    if not tmpdir:
+        return
+
+    basepath = tmpdir + '/work/'
+
+    with open(os.devnull, 'w') as devnull:
         with open('/proc/mounts', 'rU') as f:
             for line in f:
                 if basepath in line:
-                    if subprocess.call('sudo umount ' + line.split()[1],
-                                       stdout=devnull, stderr=devnull,
-                                       shell=True) != 0:
-                        result = False
-        return result
-
-    devnull = open(os.devnull, 'w')
-
-    if isinstance(e, bb.event.BuildCompleted):
-        tmpdir = d.getVar('TMPDIR', True)
-
-        if tmpdir:
-            basepath = tmpdir + '/work/'
-
-            while not umount_all(basepath):
-                time.sleep(1)
-
-    devnull.close()
+                    subprocess.call('sudo umount -l ' + line.split()[1],
+                                    stdout=devnull, stderr=devnull, shell=True)
 }
+
+isar_handler[eventmask] = "bb.runqueue.runQueueExitWait bb.event.BuildCompleted"
-- 
2.16.4


  parent reply	other threads:[~2018-12-05  9:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-05  9:29 [PATCH 0/3] umount fixes and cleanups Jan Kiszka
2018-12-05  9:29 ` [PATCH 1/3] ci: Wait for bitbake worker to finish before deleting artifacts Jan Kiszka
2018-12-05  9:52   ` Hombourger, Cedric
2018-12-05  9:59   ` Maxim Yu. Osipov
2018-12-05 10:04     ` Jan Kiszka
2018-12-05  9:29 ` Jan Kiszka [this message]
2018-12-05  9:29 ` [PATCH 3/3] Remove redundant recursive umounts Jan Kiszka
2018-12-05 11:12 ` [PATCH 0/3] umount fixes and cleanups Maxim Yu. Osipov
2018-12-05 11:32   ` Hombourger, Cedric
2018-12-05 12:14   ` Jan Kiszka
2018-12-05 12:31     ` Hombourger, Cedric
2018-12-05 12:35       ` Jan Kiszka
2018-12-05 12:48         ` Hombourger, Cedric
2018-12-05 12:54           ` Jan Kiszka
2018-12-05 14:26     ` Maxim Yu. Osipov
2018-12-05 14:52       ` Jan Kiszka
2018-12-05 23:08         ` Jan Kiszka
2018-12-07 13:46 ` Maxim Yu. Osipov

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=b1dccfd211da98c1c132ca531fd2b8b17d26c1be.1544002190.git.jan.kiszka@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=Cedric_Hombourger@mentor.com \
    --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