Package: autopkgtest
Version: 5.11
Severity: normal
Tags: patch

Dear Maintainer,

while running autopkgtest for the munin packages, I encountered problems
in combination with sysvinit in the lxc-based container.
The tests were started before all sysvinit scripts were finished.
In a systemd environment, this works as expected, since
autopkgtest-virt-lxc (and -lxd) wait for the "network-online.target".
(only a numeric runlevel is awaited for systemd as well as for sysvinit)

Packaging tests probably rely on the related services being available.
Thus at the moment it would be necessary for tests being executed in a
sysvinit system to wait explicitly for their services to start up.
This would need to implemented for each test using such an environment.
Thus probably autopkgtest should wait instead (as it does for systemd
services).

The attached patch lets autopkgtest wait for the sysvinit runlevel script
parent process (/etc/init.d/rc) to be finished/absent. This change does
not affect other init systems, since /etc/init.d/rc is only shipped by
the sysvinit-core package. In case of a timeout (60s) this waiting
procedure would fail (just as it does, if the network-online.target is
not reached by systemd).

I tested this patch succesfully. No further timing issues showed up
afterwards.

Please tell me, whether this patch looks reasonable to you.
I am happy to test other options, if you can think of a more suitable
approach.

Thank you for your time!

Cheers,
Lars

-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.4.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), 
LANGUAGE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled

Versions of packages autopkgtest depends on:
ii  apt-utils       1.8.4
ii  libdpkg-perl    1.19.7
ii  procps          2:3.3.15-2+b1
ii  python3         3.7.5-3
ii  python3-debian  0.1.36

Versions of packages autopkgtest recommends:
ii  autodep8  0.22

Versions of packages autopkgtest suggests:
pn  lxc               <none>
pn  lxd               <none>
ii  ovmf              0~20191122.bd85bf54-2
ii  qemu-efi-aarch64  0~20191122.bd85bf54-2
ii  qemu-efi-arm      0~20191122.bd85bf54-2
ii  qemu-system       1:4.2-3
ii  qemu-utils        1:4.2-3
pn  schroot           <none>
pn  vmdb2             <none>

-- no debconf information
--- /usr/bin/autopkgtest-virt-lxc.orig  2020-01-02 00:26:35.591442668 +0100
+++ /usr/bin/autopkgtest-virt-lxc       2020-03-10 00:21:16.528527335 +0100
@@ -125,7 +125,7 @@
         out = out.strip()
         if out.split()[-1].isdigit():
             adtlog.debug('waiting for network')
-            VirtSubproc.check_exec(sudoify(['lxc-attach', '--name', lxc_name, 
'--', 'sh', '-ec', '[ ! -d /run/systemd/system ] || systemctl start 
network-online.target']), timeout=60)
+            VirtSubproc.check_exec(sudoify(['lxc-attach', '--name', lxc_name, 
'--', 'sh', '-ec', 'if [ -d /run/systemd/system ]; then systemctl start 
network-online.target; else while ps -ef | grep -q "/etc/init\.d/rc"; do sleep 
1; done; fi']), timeout=60)
             return
 
         adtlog.debug('wait_booted: runlevel "%s", retrying...' % out)
--- /usr/bin/autopkgtest-virt-lxd.orig  2020-03-10 00:29:05.736763821 +0100
+++ /usr/bin/autopkgtest-virt-lxd       2020-03-10 00:29:55.625213813 +0100
@@ -101,7 +101,7 @@
         out = out.strip()
         if out.split()[-1].isdigit():
             adtlog.debug('waiting for network')
-            VirtSubproc.check_exec(['lxc', 'exec', container_name, '--', 'sh', 
'-ec', '[ ! -d /run/systemd/system ] || systemctl start 
network-online.target'], timeout=60)
+            VirtSubproc.check_exec(['lxc', 'exec', container_name, '--', 'sh', 
'-ec', 'if [ -d /run/systemd/system ]; then systemctl start 
network-online.target; else while ps -ef | grep -q "/etc/init\.d/rc"; do sleep 
1; done; fi'], timeout=60)
             return
 
         adtlog.debug('wait_booted: runlevel "%s", retrying...' % out)

Reply via email to