[rhel7-branch 1/1] rpmostreepayload: Forcibly unmount everything in sysroot

cgwalters installerbot-noreply at redhat.com
Tue Sep 22 19:53:00 UTC 2015


From: Colin Walters <walters at verbum.org>

There is an issue with 7.2 where something in the interaction
between blivet/systemd/rpmostreepayload is mounting filesystems
"deep" in `/mnt/sysimage/ostree/deploy/$x/sysroot/deploy/...`.

This then triggers another bug where the initramfs tmpfs gets remounted
read-only, and that in turns breaks dracut's ability to shutdown.

While these mounts do appear even in Fedora now, they're not actively
breaking things (for some reason), so let's just go with this crude
but functional hack for now, then re-investigate upstream and get the
mounts looking saner there.
---
 anaconda                                 |  6 ++++--
 pyanaconda/packaging/__init__.py         |  6 ++++++
 pyanaconda/packaging/rpmostreepayload.py | 14 ++++++++++++--
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/anaconda b/anaconda
index 31c9796..1bafc59 100755
--- a/anaconda
+++ b/anaconda
@@ -46,7 +46,7 @@ if ("debug=1" in proc_cmdline) or ("debug" in proc_cmdline):
 
 import atexit, sys, os, time, signal
 
-def exitHandler(rebootData, storage, exitCode=None):
+def exitHandler(rebootData, storage, payload, exitCode=None):
     # Clear the list of watched PIDs.
     iutil.unwatchAllProcesses()
 
@@ -69,6 +69,8 @@ def exitHandler(rebootData, storage, exitCode=None):
         while True:
             time.sleep(10000)
 
+    payload.preShutdown()
+
     if image_count or flags.dirInstall:
         anaconda.storage.umountFilesystems(swapoff=False)
         devicetree = anaconda.storage.devicetree
@@ -1218,7 +1220,7 @@ if __name__ == "__main__":
     signal.signal(signal.SIGUSR1, lambda signum, frame:
                   exception.test_exception_handling())
     signal.signal(signal.SIGUSR2, lambda signum, frame: anaconda.dumpState())
-    atexit.register(exitHandler, ksdata.reboot, anaconda.storage)
+    atexit.register(exitHandler, ksdata.reboot, anaconda.storage, anaconda.payload)
 
     # Fallback to default for interactive or for a kickstart with no installation method.
     fallback = not (flags.automatedInstall and ksdata.method.method)
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index f6b56ff..5da1b22 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -165,6 +165,12 @@ def prepareMountTargets(self, storage):
         """
         pass
 
+    def preShutdown(self):
+        """Called when the system is exiting (either due to success or failure).
+        An example use is to unmount any mountpoints in the installation root.
+        """
+        pass
+
     ###
     ### METHODS FOR WORKING WITH REPOSITORIES
     ###
diff --git a/pyanaconda/packaging/rpmostreepayload.py b/pyanaconda/packaging/rpmostreepayload.py
index c9e190d..b0d936c 100644
--- a/pyanaconda/packaging/rpmostreepayload.py
+++ b/pyanaconda/packaging/rpmostreepayload.py
@@ -214,13 +214,13 @@ def prepareMountTargets(self, storage):
 
         # Set up bind mounts as if we've booted the target system, so
         # that %post script work inside the target.
-        binds = [(iutil.getTargetPhysicalRoot(),
+        self._binds = [(iutil.getTargetPhysicalRoot(),
                   iutil.getSysroot() + '/sysroot'),
                  (varroot,
                   iutil.getSysroot() + '/var'),
                  (iutil.getSysroot() + '/usr', None)]
 
-        for (src, dest) in binds:
+        for (src, dest) in self._binds:
             self._safeExecWithRedirect("mount",
                                        ["--bind", src, dest if dest else src])
             if dest is None:
@@ -287,3 +287,13 @@ def postInstall(self):
         set_kargs_args.extend(self.storage.bootloader.boot_args)
         set_kargs_args.append("root=" + self.storage.rootDevice.fstabSpec)
         self._safeExecWithRedirect("ostree", set_kargs_args, root=iutil.getSysroot())
+
+    def preShutdown(self):
+        # A crude hack for 7.2; forcibly recursively unmount
+        # everything we put in the sysroot.  There is something going
+        # on inside either blivet (or systemd?) that's causing mounts inside
+        # /mnt/sysimage/ostree/deploy/$x/sysroot/ostree/deploy
+        # which is not what we want.
+        for (src, dest) in reversed(self._binds):
+            # Also intentionally ignore errors here
+            iutil.execWithRedirect("umount", ['-R', dest if dest else src])


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/b01befb134c3cb7e30869fb63a81c28128d56a74


More information about the anaconda-patches mailing list