needrestart causes kernel upgrade messages in motd

Bug #2065863 reported by Robie Basak
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
needrestart (Ubuntu)
Status tracked in Oracular
Noble
In Progress
Undecided
Unassigned
Oracular
Fix Released
Critical
Simon Chopin

Bug Description

[Impact]
needrestart shouldn't be writing to /run/reboot-required for kernel updates, that should be reserved to update-manager

[Test plan]

We can use the mockuname thing from the autopkgtests to simulate a kernel
version mismatch:

# in a fresh VM
pull-lp-source needrestart noble
cd needrestart-3.6
gcc -shared -fPIC -ldl debian/tests/mockuname.c -o mockuname.so
LD_PRELOAD=$PWD/mockuname.so apt install hello
# needrestart should complain that the system should be restarted
test ! -x /run/reboot-required || echo test failed

[Where problems could occur]

That particular patch seems on the safer side, nothing in the code relies on this file being written to.

[Original report]

On Noble, I see this in my motd:

*** System restart required ***
Pending kernel upgrade!
Running kernel version:
  6.8.0-22-generic
Diagnostics:
  The currently running kernel version is not the expected kernel version 6.8.0-31-generic.

I found this code in needrestart:

/usr/sbin/needrestart: 'The currently running kernel version is {kversion} which is not the expected kernel version {eversion}.',

I'm told that it is incorrect for needrestart to be injecting this into motd. Steve points out that needrestart isn't installed on desktop and the behaviour shouldn't be different here, thinks that this shouldn't be injected into motd, and asked for a bug report for this.

needrestart 3.6-7ubuntu4

Revision history for this message
Robie Basak (racb) wrote :

Steve asked for this to be Critical and assigned to Simon.

Changed in needrestart (Ubuntu):
assignee: nobody → Simon Chopin (schopin)
importance: Undecided → Critical
Revision history for this message
Steve Langasek (vorlon) wrote :

Simon, I don't know if this is a regression in noble, but for sure it shouldn't be needrestart telling us about kernel updates - we already have update-notifier for this which, crucially, is livepatch aware.

Revision history for this message
Simon Chopin (schopin) wrote (last edit ):

This is a new feature that I implemented based on what I had understood were the requirements: integrating needrestart with /run/reboot-required. Apparently, MOTD picks up whatever we write in that file.

Shall I walk that part back and not write to that file in the case of kernel updates? I suppose needrestart could also go through update-notifier and mimick the kernel postinst code somehow?

Simon Chopin (schopin)
tags: added: foundations-todo
Simon Chopin (schopin)
Changed in needrestart (Ubuntu Oracular):
status: New → Fix Committed
Simon Chopin (schopin)
description: updated
description: updated
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
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.