]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-50-DISSECT: notify message cannot be sent by ncat
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 17 Dec 2024 06:09:47 +0000 (15:09 +0900)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 18 Dec 2024 14:50:02 +0000 (15:50 +0100)
Follow-up for d0a63cf0412ccb9b4edd1f6048e25aa7f68b0133.

The command ncat may be already dead when the service manager receives
the notify message. Hence, the service cannot be found by the sender PID,
and the notify message will be ignored.
```
Dec 17 03:26:49 systemd[1]: Cannot find unit for notify message of PID 1159, ignoring.
Dec 17 03:26:49 systemd[1]: Received SIGCHLD from PID 1152 (bash).
Dec 17 03:26:49 systemd[1]: Child 1152 (bash) died (code=exited, status=0/SUCCESS)
Dec 17 03:26:49 systemd[1]: run-p1151-i1451.service: Child 1152 belongs to run-p1151-i1451.service.
Dec 17 03:26:49 systemd[1]: run-p1151-i1451.service: Main process exited, code=exited, status=0/SUCCESS (success)
Dec 17 03:26:49 systemd[1]: run-p1151-i1451.service: Failed with result 'protocol'.
Dec 17 03:26:49 systemd[1]: run-p1151-i1451.service: Service will not restart (restart setting)
Dec 17 03:26:49 systemd[1]: run-p1151-i1451.service: Changed start -> failed
```

This also drops unnecessary --pipe option and redundant check by 'env' command.

test/units/TEST-50-DISSECT.dissect.sh

index 2ca07453ec0aed8e330de1e2d8882c918a773d92..a7122855d9c1fa6327e1e038926fb3cc8cfa7a78 100755 (executable)
@@ -85,31 +85,25 @@ systemd-run \
     --wait \
     -p RootImage="$MINIMAL_IMAGE.raw" \
     -p NotifyAccess=all \
-    --service-type=notify \
-    --pipe \
     bash -xec \
     '
-        printf MAINPID=$$$$\\nREADY=1 | ncat --unixsock --udp $NOTIFY_SOCKET --source /run/notify
         [[ "$$NOTIFY_SOCKET" == "/run/host/notify" ]]
-        [[ "$$(env)" =~ "NOTIFY_SOCKET=/run/host/notify" ]]
         test -S /run/host/notify
     '
 if [[ "$(findmnt -n -o FSTYPE /)" == btrfs ]]; then
     [[ -d /test-dissect-btrfs-snapshot ]] && btrfs subvolume delete /test-dissect-btrfs-snapshot
     btrfs subvolume snapshot / /test-dissect-btrfs-snapshot
 
-    # Same test with systemd-notify and RootDirectory=
+    # Same test with RootDirectory=, also try to send READY=1, as we can use systemd-notify.
     systemd-run \
         --wait \
         -p RootDirectory=/test-dissect-btrfs-snapshot \
         -p NotifyAccess=all \
         --service-type=notify \
-        --pipe \
         bash -xec \
         '
             systemd-notify --pid=auto --ready
             [[ "$$NOTIFY_SOCKET" == "/run/host/notify" ]]
-            [[ "$(env)" =~ "NOTIFY_SOCKET=/run/host/notify" ]]
             test -S /run/host/notify
         '