unshare causes breakage in docker

Justin Cattle j at ocado.com
Tue Apr 27 22:05:37 CEST 2021


We build FAI images in docker.

It seems like this change has broken that workflow:

commit 5bc6385471b2b8b625c3bbaba76488b3127aebf1
Author: Thomas Lange <lange at debian.org>
Date:   Thu Sep 24 20:29:08 2020 +0200

    Use unshare when calling chroot

    Bug report : Daemonized processes inside the chroot cause image
building to hang indefinitely
    See https://salsa.debian.org/cloud-team/debian-cloud-images/-/issues/9

diff --git a/bin/fai b/bin/fai
index 433e7eb5..13cddec8 100755
--- a/bin/fai
+++ b/bin/fai
@@ -87,7 +87,7 @@ fai_init() {
       [ $do_init_tasks -eq 1 ] && FAI_ROOT=/target || FAI_ROOT=/
     # executed command in the environment of the new system
-    ROOTCMD="chroot $FAI_ROOT"
+    ROOTCMD="unshare --pid --fork --kill-child --mount-proc chroot
     # no chroot needed
     [ "$FAI_ROOT" = '/' ] && ROOTCMD=
diff --git a/bin/fai-make-nfsroot b/bin/fai-make-nfsroot
index 9ac4c367..588a62c0 100755
--- a/bin/fai-make-nfsroot
+++ b/bin/fai-make-nfsroot
@@ -152,7 +152,7 @@ cfdir=$(readlink -f $cfdir) # canonicalize path

+ROOTCMD="unshare --pid --fork --kill-child --mount-proc chroot $NFSROOT"
 export DEBIAN_FRONTEND=noninteractive

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

I haven't dug into it in great detail yet, but this produces the following
error during fai-make-nfsroot, even running as root user in a container
in privileged mode:

I: Base system installed successfully.
umount /proc failed: Invalid argument
failed to read mtab: No such file or directory
failed to read mtab: No such file or directory
file written to /var/log/fai/fai-make-nfsroot.log and
when calling fai-make-nfsroot.
file written to /var/log/fai/fai-setup.log

If I revert that change, it all works again.

Can we somehow make unshare vs chroot an option ?  Or, even better perhaps,
detect docker and don't use unshare in that case ?



This email is confidential and may contain copyright material of 
members of the Ocado Group. Opinions and views expressed in this message 
may not necessarily reflect the opinions and views of the members of the 
Ocado Group.

If you are not the intended recipient, please notify us 
immediately and delete all copies of this message. Please note that it is 
your responsibility to scan this message for viruses.

References to the 
"Ocado Group" are to Ocado Group plc (registered in England and Wales with 
number 7098618) and its subsidiary undertakings (as that expression is 
defined in the Companies Act 2006) from time to time. The registered office 
of Ocado Group plc is Buildings One & Two, Trident Place, Mosquito Way, 
Hatfield, Hertfordshire, AL10 9UL.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-koeln.de/pipermail/linux-fai/attachments/20210427/c1c47ea6/attachment.html>

More information about the linux-fai mailing list