needrestart terminates itself on updates

Bug #2067482 reported by Simon Chopin
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
needrestart (Ubuntu)
Status tracked in Oracular
Noble
Fix Committed
Undecided
Simon Chopin
Oracular
Fix Released
Undecided
Simon Chopin

Bug Description

[Impact]

There's likely a fair number of custom services out there that are similar in nature to cloud-init, unattended-upgrade and the likes. Rather than forcing every user to track down and debug this issue, needrestart should instead have some sort of "self-preservation instinct" and exclude itself from the default restart list.

While this issue isn't particularly new, it has become much more urgent in Noble onwards as we've modified it to default to silently restarting services.

[Test plan]

The fix also includes an autopkgtest for that very issue.
In addition, to test this, one can do in a fresh container with the updated needrestart installed:

# THIS WILL REINSTALL libc6 ON A LOOP ON BUGGY SYSTEMS!!!
sudo systemd-run -u no-self-restart sh -c 'set -e; apt update; apt reinstall -y libc6; sleep 5; touch /tmp/did-not-self-restart'

If the bug is fixed, you should find /tmp/did-not-self-restart with a recent mtime after a few seconds. Otherwise, it'll keep reinstalling libc6 in a loop.

[Regression potential]

The most likely regression would be some crash due to some obscure Perl idiosyncrasy.

[Other info]

[Original report]

This is an expansion on bug 2059337. There's likely a fair number of custom services out there that are similar in nature to cloud-init, unattended-upgrade and the likes. Rather than forcing every user to track down and debug this issue, needrestart should instead have some sort of "self-preservation instinct" and exclude itself from the default restart list.

While this issue isn't particularly new, it has become much more urgent in Noble onwards as we've modified it to default to silently restarting services.

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

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

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

  * Prevent needrestart restarting itself (LP: #2067482)

 -- Simon Chopin <email address hidden> Wed, 29 May 2024 17:02:42 +0200

Changed in needrestart (Ubuntu):
status: New → Fix Released
Simon Chopin (schopin)
tags: added: foundations-todo
Simon Chopin (schopin)
Changed in needrestart (Ubuntu Oracular):
assignee: nobody → Simon Chopin (schopin)
Changed in needrestart (Ubuntu Noble):
assignee: nobody → Simon Chopin (schopin)
Simon Chopin (schopin)
description: updated
Revision history for this message
Simon Chopin (schopin) wrote :

The diff might be easier to review using the git-ubuntu branch: https://code.launchpad.net/~schopin/ubuntu/+source/needrestart/+git/needrestart/+ref/sru

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 Simon, 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 :

Hi, verification done in a fresh Noble container:

root@needrestart-self:~# 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-self:~# sudo systemd-run -u no-self-restart sh -c 'set -e; apt update; apt reinstall -y libc6; sleep 5; touch /tmp/did-not-self-restart'
Running as unit: no-self-restart.service; invocation ID: d833631b9b1443f4b68fd3c7ab4877a1
root@needrestart-self:~# ls -lh /tmp/did-not-self-restart
-rw-r--r-- 1 root root 0 Jul 11 09:24 /tmp/did-not-self-restart
root@needrestart-self:~# date
Thu Jul 11 09:24:20 UTC 2024
root@needrestart-self:~# systemctl status no-self-restart
Unit no-self-restart.service could not be found.

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.