Skip to content

fix: run host apt installs without prompts so core upgrades cannot hang - #229

Merged
Marketen merged 2 commits into
masterfrom
fix/noninteractive-needrestart
Nov 23, 2026
Merged

Marketen merged 2 commits into
masterfrom
fix/noninteractive-needrestart

Conversation

@Marketen

@Marketen Marketen commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

src/scripts/enable_unattended_upgrades.sh runs apt-get install -y needrestart without DEBIAN_FRONTEND=noninteractive.

When a newer kernel is installed but the host hasn't rebooted yet, needrestart's apt hook opens a "Pending kernel upgrade" whiptail dialog waiting for <Ok>. Core runs the script through docker run --rm --privileged --pid=host -t alpine nsenter … — a TTY but no input — so nobody can answer it. The dialog then:

  • holds the dpkg lock indefinitely, so unattended-upgrades can no longer install anything on the host;
  • blocks the core entrypoint's upgrade loop, so the later upgrade_*.sh scripts never run;
  • makes every later core start add another upgrade run waiting on the lock.

It only clears on a host reboot. Seen on a real Ubuntu 26.04 node: the dialog had been waiting for 5 days (/usr/share/debconf/frontend /usr/sbin/needrestart -m u), with kernel and libc6 updates pending since unattended-upgrades installed them.

Fix

The scripts' apt calls now run with:

  • DEBIAN_FRONTEND=noninteractive — no debconf prompts;
  • NEEDRESTART_SUSPEND=1 — needrestart's apt hook is skipped, so these installs neither prompt nor restart services (service restarts after library upgrades remain with unattended-upgrades, configured to restart = 'a' as before);
  • -o DPkg::Lock::Timeout=300 — if something else holds the dpkg lock, the upgrade fails after 5 minutes and the loop continues, instead of blocking forever.

Nothing about reboots changes: Unattended-Upgrade::Automatic-Reboot "false" stays as is, and needrestart never reboots the host.

Testing

Reproduced in an ubuntu:26.04 container run with docker run -t (TTY, no input), with whiptail and a real linux-image-virtual installed so needrestart reports a pending kernel (NEEDRESTART-KSTA: 3):

Result
Old: apt-get install --reinstall -y needrestart "Pending kernel upgrade … <Ok>" dialog, hung until killed by a 60 s timeout
New: same install through the script's apt_get_noninteractive wrapper completed in 2 s, "needrestart is suspended"
Full fixed enable_unattended_upgrades.sh, same conditions completed in 12 s; restart = 'a' and Automatic-Reboot false written as before

Not covered: Debian hosts, and the lock-timeout path against a real held lock.

Nodes that are already stuck stay stuck until the hanging process ends or the host reboots; with this change, the new core's upgrades wait at most 5 minutes per apt call instead of forever.

🤖 Generated with Claude Code

enable_unattended_upgrades.sh ran `apt-get install -y needrestart`
without DEBIAN_FRONTEND=noninteractive. When a newer kernel is installed
but not yet booted, needrestart's apt hook opens a "Pending kernel
upgrade" whiptail dialog. Core runs this script with `docker run -t`
(a TTY but no input), so the dialog waits forever while holding the
dpkg lock. Every later upgrade script then blocks on that lock, as do
unattended-upgrades runs, until the host reboots.

Run the scripts' apt calls with DEBIAN_FRONTEND=noninteractive,
NEEDRESTART_SUSPEND=1 (no needrestart prompts or service restarts from
these installs) and a 300s dpkg lock timeout, so a lock held by something
else delays the core upgrade instead of blocking it forever.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Marketen
Marketen requested a review from a team as a code owner November 23, 2026 10:00
@github-actions

Copy link
Copy Markdown
Contributor

Dappnode bot has built and pinned the built packages to an IPFS node, for commit: 6ab126c

This is a development version and should only be installed for testing purposes.

  1. Package core.dnp.dappnode.eth

Install link

Hash: /ipfs/QmXq1X3YFFXJvPk1P1vtFshhTRCRcvMu4UMLrBMWabpVFE

(by dappnodebot/build-action)

Make it obvious at each call site that apt-get runs non-interactively.
A hyphenated name is not possible: the script runs under /bin/sh (dash),
which rejects it as a bad function name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Marketen
Marketen merged commit 9d15c3f into master Nov 23, 2026
4 of 5 checks passed
@Marketen
Marketen deleted the fix/noninteractive-needrestart branch November 23, 2026 10:28
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.

2 participants