]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: spawn the to-be-killed-on-soft-reboot units with --collect 29428/head
authorFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 3 Oct 2023 14:40:49 +0000 (16:40 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 3 Oct 2023 14:40:49 +0000 (16:40 +0200)
Otherwise they might leave stuff behind if they don't respond fast
enough to the first SIGTERM and get SIGKILLEd, which then breaks reusing
the unit name further in the test:

[ 2993.620849] H testsuite-82.sh[43]: + systemd-run -p Type=exec -p DefaultDependencies=no -p IgnoreOnIsolate=yes --unit=testsuite-82-nosurvive.service sleep infinity
[ 2993.628686] H systemd[1]: testsuite-82-nosurvive.service: About to execute: /usr/bin/sleep infinity
[ 2993.628886] H systemd[1]: testsuite-82-nosurvive.service: Forked /usr/bin/sleep as 65
[ 2993.629328] H systemd[1]: testsuite-82-nosurvive.service: Changed dead -> start
...
[ 2993.699892] H testsuite-82.sh[43]: + systemctl --no-block --check-inhibitors=yes soft-reboot
[ 2993.704326] H systemd-logind[41]: The system will soft-reboot now!
...
[ 3001.249302] H systemd[1]: Sending SIGKILL to PID 65 (sleep).
...
[ 3001.303158] H testsuite-82.sh[136]: + systemd-notify '--status=Second Boot'
...
[ 3001.409504] H testsuite-82.sh[136]: + systemd-run -p Type=exec --unit=testsuite-82-nosurvive.service sleep infinity
[ 3001.414061] H testsuite-82.sh[165]: Failed to start transient service unit: Unit testsuite-82-nosurvive.service was already loaded or has a fragment file.

Spotted in Ubuntu CI.

test/units/testsuite-82.sh

index b57350c79b9379cb0397f78f21f11e66050ae587..15243ab6a222dee5d3fbff6ba1365ccd06f31ced 100755 (executable)
@@ -75,7 +75,7 @@ elif [ -f /run/testsuite82.touch2 ]; then
     mount
 
     # Restart the unit that is not supposed to survive
-    systemd-run --service-type=exec --unit=testsuite-82-nosurvive.service sleep infinity
+    systemd-run --collect --service-type=exec --unit=testsuite-82-nosurvive.service sleep infinity
 
     # Now issue the soft reboot. We should be right back soon.
     touch /run/testsuite82.touch3
@@ -131,7 +131,7 @@ elif [ -f /run/testsuite82.touch ]; then
     mount --bind / /run/nextroot/original-root
 
     # Restart the unit that is not supposed to survive
-    systemd-run --service-type=exec --unit=testsuite-82-nosurvive.service sleep infinity
+    systemd-run --collect --service-type=exec --unit=testsuite-82-nosurvive.service sleep infinity
 
     # Now issue the soft reboot. We should be right back soon.
     touch /run/testsuite82.touch2
@@ -170,8 +170,8 @@ EOF
     # This sets DefaultDependencies=no so that they remain running until the very end, and
     # IgnoreOnIsolate=yes so that they aren't stopped via the "testsuite.target" isolation we do on next boot,
     # and will be killed by the final sigterm/sigkill spree.
-    systemd-run --service-type=notify -p DefaultDependencies=no -p IgnoreOnIsolate=yes --unit=testsuite-82-nosurvive-sigterm.service "$survive_sigterm"
-    systemd-run --service-type=exec -p DefaultDependencies=no -p IgnoreOnIsolate=yes --unit=testsuite-82-nosurvive.service sleep infinity
+    systemd-run --collect --service-type=notify -p DefaultDependencies=no -p IgnoreOnIsolate=yes --unit=testsuite-82-nosurvive-sigterm.service "$survive_sigterm"
+    systemd-run --collect --service-type=exec -p DefaultDependencies=no -p IgnoreOnIsolate=yes --unit=testsuite-82-nosurvive.service sleep infinity
 
     # Configure these transient units to survive the soft reboot - they will not conflict with shutdown.target
     # and it will be ignored on the isolate that happens in the next boot. The first will use argv[0][0] =