** Description changed: [ Impact ] On Noble, systemd 255 can treat a stopped service as active when it still has saved file descriptors (dead-resources-pinned with FileDescriptorStorePreserve=yes). systemd can refuse to reopen the socket, or a connection to a socket left open can fail to start the service. In the authd migration tests, upgrading from the stable PPA left authd.socket and authd.service stopped: https://github.com/canonical/authd/issues/2317 The authd packaging patch (https://github.com/canonical/authd/pull/2318) keeps the socket open during upgrades on Noble. Manual socket restarts can still fail. [ Test Plan ] - Run this on a Noble VM. Noble's default journald unit does not set - FileDescriptorStorePreserve=yes, so the test uses a service that keeps a - descriptor after stopping. + All steps as root on a disposable Noble VM. The attached sru-fdstore-test.sh + creates temporary units under /run/systemd/system that opt into + FileDescriptorStorePreserve=yes (no default Noble unit does) and cleans them + up afterwards. - ```bash - sudo bash <<'SRU' - set -eu - cd /run/systemd/system - work=$(mktemp -d /run/sru-fdstore-XXXXXX) - unit=${work##*/} - trap 'systemctl stop "$unit."{socket,service,target} || : - rm -f -- "$unit."{socket,service,target}; systemctl daemon-reload; rm -r -- "$work"' EXIT + 1. Run: bash sru-fdstore-test.sh + On the stock package both activation paths fail: the script prints + "FAIL: ..." lines and exits non-zero; the journal shows + "Socket service ... already active, refusing." - printf '[Socket]\nListenStream=%s/listener\n' "$work" >"$unit.socket" - # Keep the stopped service loaded after the socket closes. - printf '[Unit]\nWants=%s.service\n' "$unit" >"$unit.target" - cat >"$unit.service" <<'UNIT' - [Service] - Type=notify - NotifyAccess=all - FileDescriptorStoreMax=1 - FileDescriptorStorePreserve=yes - TimeoutStartSec=10 - # This status is set only if systemd returns the saved descriptor. - ExecStart=:/bin/bash -ec '\ - if [[ :$LISTEN_FDNAMES: == *:saved:* ]]; then systemd-notify --ready --status=restored; \ - else systemd-notify --ready --fd=8 --fdname=saved 8</dev/null; fi; exec sleep infinity' - UNIT + 2. Install the update and reboot so the new PID 1 runs: + sudo apt install -t noble-proposed systemd && reboot - systemctl daemon-reload - systemctl start "$unit.socket" "$unit.target" - failed=0 - for mode in reactivate reopen; do - # Close first so a queued connection cannot wake the service. - if [[ $mode == reopen ]]; then systemctl stop "$unit.socket"; fi - systemctl stop "$unit.service" - [[ $(systemctl show -P SubState "$unit.service") == dead-resources-pinned ]] - [[ $(systemctl show -P NFileDescriptorStore "$unit.service") == 1 ]] - if { [[ $mode == reactivate ]] || systemctl start "$unit.socket"; } && - timeout 5 python3 -c 'import socket, sys; socket.socket(socket.AF_UNIX).connect(sys.argv[1])' "$work/listener" && - timeout 10 bash -c 'until [[ $(systemctl show -P StatusText "$1") == restored ]]; do sleep .2; done' _ "$unit.service" && - systemctl is-active --quiet "$unit.service"; then - echo "PASS: $mode" - else - echo "FAIL: $mode"; failed=1 - fi - done + 3. Run the script again. Expect: + PASS: start activated the service with its original descriptor + PASS: reactivate activated the service with its original descriptor + PASS: systemd still refused to start the socket while the service was active - # Only the patched run reaches the live-service rejection check. - if (( failed == 0 )); then - if systemctl restart "$unit.socket"; then echo 'FAIL: live-service guard'; exit 1; fi - systemctl is-active --quiet "$unit.service" - fi - journalctl --sync - journalctl --no-pager -b -u "$unit.socket" -o cat | grep -F 'already active, refusing' - test "$failed" = 0 - echo 'PASS: live-service guard' - SRU - ``` - - On stock Noble, reactivate times out and reopen logs "already active, - refusing". - - Install the proposed package: - sudo apt install -t noble-proposed systemd - - Reboot and repeat the test. Expect PASS: reactivate, PASS: reopen, and - PASS: live-service guard. + 4. Common-use check: after the reboot the system boots normally, + `systemctl is-system-running` reports running/degraded without new + failures, and journald works. [ Where problems could occur ] If systemd reopens an Accept=no socket while its service is still running, new clients could connect but get no response: the service still holds the old listening socket. The test checks that systemd still refuses to reopen it. [ Other Info ] The fix shipped in systemd v257 and is already in Resolute, Stonking, and Tenacious. Upstream: https://github.com/systemd/systemd/pull/33874
** Attachment added: "verify-socket-fdstore.sh" https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2176110/+attachment/6021018/+files/verify-socket-fdstore.sh -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2176110 Title: Noble: socket activation fails with a preserved fd store To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2176110/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
