Commit b6ad8d9c authored by Frederic Danis's avatar Frederic Danis

Fix systemd-nspawn error when running in gitlab CI

When running in gitlab CI with docker the following error may occur:
 Failed to register machine: Unit machine-root.scope already exists.

We only use systemd-nspawn for temporary containers which are not intended
to be used interactively, so it is not useful for them to be listed by
machined.

Registering with machined can also be harmful: because our root directory
is named `root`, if two concurrent flatdeb instances communicate with the
same machined instance, the second one will try to use the same name as
the first and so will fail to register, causing flatdeb to fail.

This can be avoided by preventing the systemd-nspawn container from
registering with machined (which is supported since systemd v209).
Signed-off-by: Frederic Danis's avatarFrédéric Danis <frederic.danis@collabora.com>
parent a446d60e
...@@ -74,6 +74,7 @@ def main(): ...@@ -74,6 +74,7 @@ def main():
'--directory={}'.format(args.sysroot), '--directory={}'.format(args.sysroot),
'--as-pid2', '--as-pid2',
'--tmpfs=/run/lock', '--tmpfs=/run/lock',
'--register=no',
'env', 'DEBIAN_FRONTEND=noninteractive', 'env', 'DEBIAN_FRONTEND=noninteractive',
] ]
......
...@@ -136,6 +136,7 @@ def main(): ...@@ -136,6 +136,7 @@ def main():
'--directory={}'.format(args.sysroot), '--directory={}'.format(args.sysroot),
'--as-pid2', '--as-pid2',
'--tmpfs=/run/lock', '--tmpfs=/run/lock',
'--register=no',
] ]
in_chroot_quick = [ in_chroot_quick = [
'chroot', args.sysroot, 'chroot', args.sysroot,
......
...@@ -201,6 +201,7 @@ def main(): ...@@ -201,6 +201,7 @@ def main():
'--directory={}'.format(args.sysroot), '--directory={}'.format(args.sysroot),
'--as-pid2', '--as-pid2',
'--tmpfs=/run/lock', '--tmpfs=/run/lock',
'--register=no',
] ]
if args.output: if args.output:
......
...@@ -55,7 +55,7 @@ in_chroot () { ...@@ -55,7 +55,7 @@ in_chroot () {
done done
systemd-nspawn --directory="$sysroot" --as-pid2 --tmpfs=/run/lock \ systemd-nspawn --directory="$sysroot" --as-pid2 --tmpfs=/run/lock \
env DEBIAN_FRONTEND=noninteractive \ --register=no env DEBIAN_FRONTEND=noninteractive \
"$@" "$@"
} }
......
...@@ -58,6 +58,7 @@ def main(): ...@@ -58,6 +58,7 @@ def main():
'--directory={}'.format(args.sysroot), '--directory={}'.format(args.sysroot),
'--as-pid2', '--as-pid2',
'--tmpfs=/run/lock', '--tmpfs=/run/lock',
'--register=no',
'env', 'env',
'DEBIAN_FRONTEND=noninteractive', 'DEBIAN_FRONTEND=noninteractive',
'SUDO_FORCE_REMOVE=yes', 'SUDO_FORCE_REMOVE=yes',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment