mirror of
https://github.com/systemd/systemd.git
synced 2025-09-08 13:44:41 +03:00
TEST-13-NSPAWN: fix race between container exit and varlink call
Follow-up for 3cb72c7862
.
The test container exits shortly, hence when varlinkctl is called, the
container may be already terminated. Let's make the container live
infinitely.
Also, this makes the os-release files removed after the container is started.
This commit is contained in:
@@ -304,7 +304,26 @@ varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.Unreg
|
|||||||
|
|
||||||
# test io.systemd.Machine.List with addresses, OSRelease, and UIDShift fields
|
# test io.systemd.Machine.List with addresses, OSRelease, and UIDShift fields
|
||||||
create_dummy_container "/var/lib/machines/container-without-os-release"
|
create_dummy_container "/var/lib/machines/container-without-os-release"
|
||||||
|
cat >>/var/lib/machines/container-without-os-release/sbin/init <<\EOF
|
||||||
|
PID=0
|
||||||
|
|
||||||
|
trap 'kill 0' RTMIN+3
|
||||||
|
trap 'kill $PID' EXIT
|
||||||
|
|
||||||
|
# We need to wait for the sleep process asynchronously in order to allow
|
||||||
|
# bash to process signals
|
||||||
|
sleep infinity &
|
||||||
|
|
||||||
|
# notify that the process is ready
|
||||||
|
touch /ready
|
||||||
|
|
||||||
|
PID=$!
|
||||||
|
while :; do
|
||||||
|
wait || :
|
||||||
|
done
|
||||||
|
EOF
|
||||||
machinectl start "container-without-os-release"
|
machinectl start "container-without-os-release"
|
||||||
|
timeout 30 bash -c "until test -e /var/lib/machines/container-without-os-release/ready; do sleep .5; done"
|
||||||
rm -f /var/lib/machines/container-without-os-release/etc/os-release /var/lib/machines/container-without-os-release/usr/lib/os-release
|
rm -f /var/lib/machines/container-without-os-release/etc/os-release /var/lib/machines/container-without-os-release/usr/lib/os-release
|
||||||
(! varlinkctl --more call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name": "container-without-os-release", "acquireMetadata": "yes"}')
|
(! varlinkctl --more call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name": "container-without-os-release", "acquireMetadata": "yes"}')
|
||||||
varlinkctl --more call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name": "container-without-os-release", "acquireMetadata": "graceful"}'
|
varlinkctl --more call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name": "container-without-os-release", "acquireMetadata": "graceful"}'
|
||||||
|
Reference in New Issue
Block a user