Config variable $nrconf{restart} is no longer accurate: it always restarts

Bug #2068543 reported by halfgaar
20
This bug affects 2 people
Affects Status Importance Assigned to Milestone
needrestart (Ubuntu)
Status tracked in Oracular
Noble
Fix Committed
Undecided
Unassigned
Oracular
Fix Released
Undecided
Unassigned

Bug Description

[Impact]
The normal configuration knob to change the behaviour of needrestart wrt restarting services vs asking the user vs just listing them doesn't work anymore
on Noble due to the "Ubuntu mode" changes made during that cycle.

[Test plan]

echo '$nrconf{restart} = "l";' > /etc/needrestart/conf.d/listmode.conf
apt reinstall libc6
# The previous command should not have restarted any service.

[ Where problems could occur ]

If the patch is buggy, automatic restart could be disabled for all users. However, that use case is checked by the autopkgtests.

[Original report]
On Ubuntu 24.04:

The conf /etc/needrestart/needrestart.conf contains:

# Restart mode: (l)ist only, (i)nteractive or (a)utomatically.
#
# ATTENTION: If needrestart is configured to run in interactive mode but is run
# non-interactive (i.e. unattended-upgrades) it will fallback to list only mode.
#
#$nrconf{restart} = 'i';

Whether that variable is left at default (commented out) or defined with 'l' or 'i', services are still restarted.

This config variable conflicts with the new behavior in [1].

To reproduce: set "$nrconf{restart} = 'l'" run 'apt reinstall libssl3t64' on servers with Nginx, Redis, etc.

Not sure if this setting should be respected, changed, or removed.

[1] https://discourse.ubuntu.com/t/needrestart-changes-in-ubuntu-24-04-service-restarts/44671

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in needrestart (Ubuntu):
status: New → Confirmed
Revision history for this message
Nick Tait (nick.t) wrote :

I have noticed the same thing on 3 servers after they were upgraded to 24.04.

I also tested the following:

sudo NEEDRESTART_MODE=l apt full-upgrade --autoremove

i.e. specifying the restart mode in an environment variable (which I found by Googling), but this also had no effect.

I could be wrong about this, but it seems to me as though when needrestart is run manually, it DOES observe the settings in /etc/needrestart/needrestart.conf, but when it is run automatically by apt, it DOESN'T observe the settings and always restarts services. Could apt be passing in a NEEDRESTART_MODE=a environment variable to cause this behaviour?

Simon Chopin (schopin)
Changed in needrestart (Ubuntu Oracular):
status: Confirmed → Fix Committed
status: Fix Committed → Confirmed
status: Confirmed → Fix Committed
Simon Chopin (schopin)
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package needrestart - 3.6-8ubuntu3

---------------
needrestart (3.6-8ubuntu3) oracular; urgency=medium

  * d/p/ubuntu-mode.patch: Don't touch /run/reboot-required on kernel updates
    (LP: #2065863)
  * Ubuntu mode: disable it if restart mode has been explicitly set
    (LP: #2068543)
  * Add some inline documentation for the Ubuntu mode (LP: #2068573)
  * Don't restart the google-guest-agent service (LP: #2063442)
  * Don't restart the GH runner provisioner (LP: #2067800)
  * tests: guard against looping when failing.

 -- Simon Chopin <email address hidden> Fri, 14 Jun 2024 11:57:11 +0200

Changed in needrestart (Ubuntu Oracular):
status: Fix Committed → Fix Released
Simon Chopin (schopin)
Changed in needrestart (Ubuntu Noble):
status: New → In Progress
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Please test proposed package

Hello halfgaar, or anyone else affected,

Accepted needrestart into noble-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/needrestart/3.6-7ubuntu4.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-noble to verification-done-noble. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-noble. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in needrestart (Ubuntu Noble):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-noble
Revision history for this message
Simon Chopin (schopin) wrote :
Download full text (3.5 KiB)

Verified on a fresh container (with the conf then removed to show the difference):

root@needrestart-nrconf:~# dpkg -l needrestart | tail -n 1
ii needrestart 3.6-7ubuntu4.1 all check which daemons need to be restarted after library upgrades
root@needrestart-nrconf:~# e^C
root@needrestart-nrconf:~# echo '$nrconf{restart} = "l";' > /etc/needrestart/conf.d/listmode.conf
root@needrestart-nrconf:~# apt reinstall libc6
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 3263 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 libc6 amd64 2.39-0ubuntu8.2 [3263 kB]
Fetched 3263 kB in 0s (20.3 MB/s)
Preconfiguring packages ...
(Reading database ... 34412 files and directories currently installed.)
Preparing to unpack .../libc6_2.39-0ubuntu8.2_amd64.deb ...
Unpacking libc6:amd64 (2.39-0ubuntu8.2) over (2.39-0ubuntu8.2) ...
Setting up libc6:amd64 (2.39-0ubuntu8.2) ...
Processing triggers for libc-bin (2.39-0ubuntu8.2) ...
Disabling Ubuntu mode, explicit restart mode configuredScanning processes... [ Scanning processes...
Scanning candidates...

Services to be restarted:
 systemctl restart console-getty.service
 systemctl restart cron.service
 systemctl restart packagekit.service
 systemctl restart polkit.service
 systemctl restart rsyslog.service
 systemctl restart systemd-journald.service
 systemctl restart systemd-networkd.service
 systemctl restart systemd-resolved.service
 systemctl restart systemd-udevd.service
 systemctl restart udisks2.service

Service restarts being deferred:
 /etc/needrestart/restart.d/dbus.service
 systemctl restart systemd-logind.service
 systemctl restart unattended-upgrades.service

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
root@needrestart-nrconf:~# rm /etc/needrestart/conf.d/listmode.conf
root@needrestart-nrconf:~# apt reinstall libc6
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 3263 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 libc6 amd64 2.39-0ubuntu8.2 [3263 kB]
Fetched 3263 kB in 0s (17.3 MB/s)
Preconfiguring packages ...
(Reading database ... 34412 files and directories currently installed.)
Preparing to unpack .../libc6_2.39-0ubuntu8.2_amd64.deb ...
Unpacking libc6:amd64 (2.39-0ubuntu8.2) over (2.39-0ubuntu8.2) ...
Setting up libc6:amd64 (2.39-0ubuntu8.2) ...
Processing triggers for libc-bin (2.39-0ubuntu8.2) ...
Scanning processes...
Scanning candidates...

Restarting services...
 systemctl restart console-getty.service cron.service packagekit.service polkit.service rsyslog.service systemd-journald.service systemd-networkd.service sys...

Read more...

tags: added: verification-done verification-done-noble
removed: verification-needed verification-needed-noble
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.