From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 8BEB1138359 for ; Thu, 29 Oct 2020 16:16:58 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D4686E09C6; Thu, 29 Oct 2020 16:16:57 +0000 (UTC) Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C2009E09C7 for ; Thu, 29 Oct 2020 16:16:57 +0000 (UTC) Received: by mail-qk1-f181.google.com with SMTP id z6so2418845qkz.4 for ; Thu, 29 Oct 2020 09:16:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gvtKOOTMdnZ6OHh7eNCeoj7bfZ1zhesTwpTXyAQgp8I=; b=pXZhu+n8b+7dtw+DDAhT48+wEX92tHDeC0xtdFKtPLy9ONL5jfPxun5Bz53spPHU5Y hDc+EE6Up+iIO5j8xV6XqIw4Gv2rpUVJTgc17nnl5jOJNMtUKLt+eVOXvkiD7TUajw/j EVd/zoUhayoeQUWuXhG2ysYpdb1ZLCE2b+wXPVghd8QfIamWJ+vz7ygVvVV2zKqE6SXZ HzyDpyWEWTsbncDnydvtmT+3CgE1ca9dHspeYwbxPbnilG4XZkWSbJBS3Debyoourl81 fg6iDiEBohgW0ugB1iGogZ78fuqAmSIFvHUuXu2pbbyQ3RWXUxRsnz/+gDTaVTKepxqG /NsQ== X-Gm-Message-State: AOAM530soIEEeghSlbRfM9sBbz53eYmIkMZ/X24PLEdn02lvTLopJZsY CBE5ezuTKRurFVEJ1TnzNbT9rU9hdnQ= X-Google-Smtp-Source: ABdhPJzmTAuDWqE1ZvCN4GPQmmx5LmHN9A90AP5AySwyPmqhblEnIzmJ1+yHDSLg/M4SCHhJxfiorw== X-Received: by 2002:a37:7f03:: with SMTP id a3mr4442462qkd.72.1603988216674; Thu, 29 Oct 2020 09:16:56 -0700 (PDT) Received: from localhost (2606-a000-131c-10bb-0000-0000-0000-1fc3.inf6.spectrum.com. [2606:a000:131c:10bb::1fc3]) by smtp.gmail.com with ESMTPSA id p5sm1328130qtu.13.2020.10.29.09.16.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 09:16:55 -0700 (PDT) From: Matt Turner To: gentoo-catalyst@lists.gentoo.org Cc: Matt Turner Subject: [gentoo-catalyst] [PATCH 12/12] catalyst: Drop unbind() Date: Thu, 29 Oct 2020 12:16:32 -0400 Message-Id: <20201029161632.146732-12-mattst88@gentoo.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201029161632.146732-1-mattst88@gentoo.org> References: <20201029161632.146732-1-mattst88@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: d6b52e18-c9e5-4757-8146-5cfe0c81978b X-Archives-Hash: 52b7a76ef1d6e5726cac46c56b56acd0 mount_namespaces(7) says A mount ceases to be a member of a peer group when either the mount is explicitly unmounted, or when the mount is implicitly unmounted because a mount namespace is removed (because it has no more member processes). As a result, we can rely on exiting the mount namespace to unmount the bind mounts. Signed-off-by: Matt Turner --- catalyst/base/stagebase.py | 45 +------------------------------ catalyst/targets/embedded.py | 1 - catalyst/targets/livecd_stage1.py | 1 - catalyst/targets/livecd_stage2.py | 2 -- catalyst/targets/netboot.py | 3 --- catalyst/targets/stage4.py | 1 - 6 files changed, 1 insertion(+), 52 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index d5454b77..a75dbdf9 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -498,7 +498,6 @@ class StageBase(TargetBase, ClearBase, GenBase): "setup_environment", "run_local", "preclean", - "unbind", ]) self.finish_sequence.extend([ "clean", @@ -853,40 +852,8 @@ class StageBase(TargetBase, ClearBase, GenBase): fstype=fstype, options=options) cxt.mount() except OSError as e: - self.unbind() raise CatalystError(f"Couldn't mount: {source}, {e.strerror}") - def unbind(self): - chroot_path = self.settings["chroot_path"] - umount_failed = False - - # Unmount in reverse order - for target in [Path(chroot_path + self.mount[x]['target']) - for x in reversed(self.mount) - if self.mount[x]['enable']]: - if not target.exists(): - log.debug('%s does not exist. Skipping', target) - continue - - if not ismount(target): - log.debug('%s is not a mount point. Skipping', target) - continue - - try: - cxt = libmount.Context(target=str(target)) - cxt.umount() - except OSError as e: - log.warning("Couldn't umount: %s, %s", target, - e.strerror) - umount_failed = True - - if umount_failed: - # if any bind mounts really failed, then we need to raise - # this to potentially prevent an upcoming bash stage cleanup script - # from wiping our bind mounts. - raise CatalystError( - "Couldn't umount one or more bind-mounts; aborting for safety.") - def chroot_setup(self): self.makeconf = read_makeconf(normpath(self.settings["chroot_path"] + self.settings["make_conf"])) @@ -1190,7 +1157,6 @@ class StageBase(TargetBase, ClearBase, GenBase): env=self.env) self.resume.enable("remove") except: - self.unbind() raise def preclean(self): @@ -1206,7 +1172,6 @@ class StageBase(TargetBase, ClearBase, GenBase): self.resume.enable("preclean") except: - self.unbind() raise CatalystError("Build failed, could not execute preclean") def capture(self): @@ -1269,7 +1234,6 @@ class StageBase(TargetBase, ClearBase, GenBase): self.settings['controller_file']) except CatalystError: - self.unbind() raise CatalystError("Stage build aborting due to error.", print_traceback=False) @@ -1349,7 +1313,6 @@ class StageBase(TargetBase, ClearBase, GenBase): with namespace(mount=True): if not self.run_sequence(self.build_sequence): - self.unbind() return False if not self.run_sequence(self.finish_sequence): @@ -1375,7 +1338,6 @@ class StageBase(TargetBase, ClearBase, GenBase): env=self.env) log.info('unmerge shell script') except CatalystError: - self.unbind() raise self.resume.enable("unmerge") @@ -1450,7 +1412,6 @@ class StageBase(TargetBase, ClearBase, GenBase): fileutils.touch(build_packages_resume) self.resume.enable("build_packages") except CatalystError: - self.unbind() raise CatalystError( self.settings["spec_prefix"] + "build aborting due to error.") @@ -1474,7 +1435,6 @@ class StageBase(TargetBase, ClearBase, GenBase): self._build_kernel(kname=kname) self.resume.enable("build_kernel") except CatalystError: - self.unbind() raise CatalystError( "build aborting due to kernel build error.", print_traceback=True) @@ -1518,7 +1478,6 @@ class StageBase(TargetBase, ClearBase, GenBase): key = 'boot/kernel/' + kname + '/config' if key in self.settings: if not os.path.exists(self.settings[key]): - self.unbind() raise CatalystError("Can't find kernel config: %s" % self.settings[key]) @@ -1527,7 +1486,7 @@ class StageBase(TargetBase, ClearBase, GenBase): self.settings['chroot_path'] + '/var/tmp/' + kname + '.config') except IOError: - self.unbind() + raise def _copy_initramfs_overlay(self, kname): key = 'boot/kernel/' + kname + '/initramfs_overlay' @@ -1557,7 +1516,6 @@ class StageBase(TargetBase, ClearBase, GenBase): env=self.env) self.resume.enable("bootloader") except CatalystError: - self.unbind() raise CatalystError("Script aborting due to error.") def livecd_update(self): @@ -1573,7 +1531,6 @@ class StageBase(TargetBase, ClearBase, GenBase): self.resume.enable("livecd_update") except CatalystError: - self.unbind() raise CatalystError( "build aborting due to livecd_update error.") diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 1314ce7c..e9138437 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -56,7 +56,6 @@ class embedded(StageBase): "root_overlay", "fsscript", "unmerge", - "unbind", ]) self.finish_sequence.extend([ "remove", diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index 81367053..5c5e9f58 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -34,7 +34,6 @@ class livecd_stage1(StageBase): "chroot_setup", "setup_environment", "build_packages", - "unbind", ]) self.finish_sequence.extend([ "clean", diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index f6c14919..3606047f 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -80,7 +80,6 @@ class livecd_stage2(StageBase): for x in self.settings["livecd/modblacklist"]: myf.write("\nblacklist "+x) except: - self.unbind() raise CatalystError("Couldn't open " + self.settings["chroot_path"] + "/etc/modprobe.d/blacklist.conf.", @@ -109,7 +108,6 @@ class livecd_stage2(StageBase): "fsscript", "rcupdate", "unmerge", - "unbind", ]) self.finish_sequence.extend([ "remove", diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index 9a0a4156..55f4dff1 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -93,7 +93,6 @@ class netboot(StageBase): cmd([self.settings['controller_file'], 'image'] + myfiles, env=self.env) except CatalystError: - self.unbind() raise CatalystError("Failed to copy files to image!", print_traceback=True) @@ -121,7 +120,6 @@ class netboot(StageBase): cmd([self.settings['controller_file'], 'final'], env=self.env) log.notice('Netboot Build Finished!') except CatalystError: - self.unbind() raise CatalystError("Failed to move kernel images!", print_traceback=True) @@ -178,7 +176,6 @@ class netboot(StageBase): "move_kernels", "remove", "empty", - "unbind", ]) self.finish_sequence.extend([ "clean", diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 78a5c780..b7f74b01 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -57,7 +57,6 @@ class stage4(StageBase): "preclean", "rcupdate", "unmerge", - "unbind", ]) self.finish_sequence.extend([ "remove", -- 2.26.2