From: Matt Turner <mattst88@gentoo.org>
To: gentoo-catalyst@lists.gentoo.org
Cc: Matt Turner <mattst88@gentoo.org>
Subject: [gentoo-catalyst] [PATCH 12/12] catalyst: Drop unbind()
Date: Thu, 29 Oct 2020 12:16:32 -0400 [thread overview]
Message-ID: <20201029161632.146732-12-mattst88@gentoo.org> (raw)
In-Reply-To: <20201029161632.146732-1-mattst88@gentoo.org>
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 <mattst88@gentoo.org>
---
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
prev parent reply other threads:[~2020-10-29 16:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 16:16 [gentoo-catalyst] [PATCH 01/12] catalyst: Replace pathcompare() Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 02/12] catalyst: Rewrite ismount() to use libmount Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 03/12] catalyst: Use libmount for handling mounts Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 04/12] catalyst: Move action_sequence out of self.settings[] Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 05/12] catalyst: Use .extend() and .append() for action_sequence Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 06/12] catalyst: Split action_sequence into prepare/build/finish Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 07/12] catalyst: Factor out run_sequence() Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 08/12] catalyst: Add and use namespace context manager Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 09/12] catalyst: Run the build sequence in new mount namespace Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 10/12] catalyst: Remove kill_support_pids() Matt Turner
2020-10-29 16:16 ` [gentoo-catalyst] [PATCH 11/12] catalyst: Remove mount_safety_check() Matt Turner
2020-10-29 16:16 ` Matt Turner [this message]
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=20201029161632.146732-12-mattst88@gentoo.org \
--to=mattst88@gentoo.org \
--cc=gentoo-catalyst@lists.gentoo.org \
/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