Skip to content

Have needrestart defer restarts of the job lock units - #1495

Draft
epompeii wants to merge 2 commits into
u/ep/runner-quiet-maintenancefrom
u/ep/runner-quiet-needrestart
Draft

epompeii wants to merge 2 commits into
u/ep/runner-quiet-maintenancefrom
u/ep/runner-quiet-needrestart

Conversation

@epompeii

Copy link
Copy Markdown
Member

Stacked on #1490.

While a maintenance unit waits for the runner's job lock, its main process is flock. When an unattended upgrade replaces util-linux or libc6, Ubuntu 24.04's needrestart flags the waiting unit and runs systemctl restart on it. That restart waits for the new start, the new start waits for the lock, and the upgrade run that holds the lock is an ancestor of needrestart, so nothing ends the wait.

cargo ops host now writes /etc/needrestart/conf.d/zz-bencher-quiet.conf, made from the list of maintenance units, which matches each unit by its exact name and has needrestart defer its restart. A deferred restart costs nothing for these oneshot units, since the next run starts the new binaries. cargo ops audit checks the file like every other file host writes.

  • The file covers every unit under the job lock, the 2 apt units too. needrestart already defers those by default, and an apt-daily.service that waits for the lock has the same problem, so the file follows the one list.
  • host writes the file on a host without needrestart as well, where it does nothing, so a later install of needrestart is covered. needrestart reads its configuration on each run, so nothing reloads it.
  • A new test loads the generated file through perl the way needrestart does and checks that each unit is deferred by its exact name alone, that its timer and similar names are not, and that needrestart's own defaults stay.
  • Checked on Ubuntu 24.04 with needrestart: without the file, the restart of a waiting logrotate.service hangs; with the file, needrestart defers it, exits 0, and logrotate finishes once the lock is free.

While a maintenance unit waits for the runner's job lock, its main
process is flock. When an unattended upgrade replaces util-linux or
libc6, needrestart flags the waiting unit and runs systemctl restart
on it. That restart waits for the new start, the new start waits for
the lock, and the upgrade run that holds the lock is an ancestor of
needrestart, so nothing ends the wait.

host now writes /etc/needrestart/conf.d/zz-bencher-quiet.conf, made
from the list of maintenance units, which matches each unit by its
exact name and defers its restart. A deferred restart costs nothing
for these oneshot units, since the next run starts the new binaries.
audit checks the file like every other file host writes.
@epompeii
epompeii added this pull request to stack #1496 November 14, 2026 13:57
It starts perl, which a Windows machine may lack. Also say which
snippets the zz- prefix sorts after.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant