Code review comment for ~chad.smith/ubuntu/+source/needrestart:lp-2059337-dont-autorestart-cloud-final

Revision history for this message
Chad Smith (chad.smith) wrote (last edit ):

Thanks @holmanb, I just force-pushed these changes after testing:

Test procedure:

1. Create user-data that tells cloud-init to run apt-get dist-upgrade and install the sl package

cat > lp-2059337.yaml <<EOF
#cloud-config
# trigger needrestart SIGTERM against cloud-final due to apt-get dist-upgrade call and cloud-init pkg upgrade
package_update: true
package_upgrade: true
packages: [sl]
EOF

2. init a noble lxc container with cloud-config to trigger apt-get dist-upgrade and package installs
lxc init ubuntu-daily:noble nn-test -c cloud-init.user-data="$(cat lp-2059337.yaml)"

3. inject this autoinstall.conf to /etc/needrestart/needrestart.conf
lxc file push ex/needrestart.conf nn-test/etc/needrestart/

4. start the lxd instance, letting cloud-init run.
lxc start nn-test; sleep 2; lxc exec nn-test -- cloud-init status --wait --format=yaml

5. grep need restart behavior in cloud-init-output.log asserting cloud-final.service is skipped
lxc exec nn-test -- grep -A 8 "Service restarts" /var/log/cloud-init-output.log

--- Test run output shows deferred cloud-final.service
/var/log/cloud-init-output.log:Service restarts being deferred:
/var/log/cloud-init-output.log- systemctl restart cloud-final.service
/var/log/cloud-init-output.log- /etc/needrestart/restart.d/dbus.service
/var/log/cloud-init-output.log- systemctl restart systemd-logind.service
/var/log/cloud-init-output.log- systemctl restart unattended-upgrades.service
/var/log/cloud-init-output.log-
/var/log/cloud-init-output.log-No containers need to be restarted.
/var/log/cloud-init-output.log-
/var/log/cloud-init-output.log-No user sessions are running outdated binaries.
--
/var/log/cloud-init-output.log:Service restarts being deferred:
/var/log/cloud-init-output.log- systemctl restart cloud-final.service
/var/log/cloud-init-output.log- /etc/needrestart/restart.d/dbus.service
/var/log/cloud-init-output.log- systemctl restart systemd-logind.service
/var/log/cloud-init-output.log- systemctl restart unattended-upgrades.service
/var/log/cloud-init-output.log-
/var/log/cloud-init-output.log-No containers need to be restarted.
/var/log/cloud-init-output.log-
/var/log/cloud-init-output.log-No user sessions are running outdated binaries.

« Back to merge proposal