fix(installer): keep apt non-interactive so needrestart can't hang installs on Ubuntu 22.04+#212
Conversation
…stalls on Ubuntu 22.04+ Ubuntu 22.04+ ships needrestart, which hooks `apt-get install` and opens an interactive "restart services?" prompt that `-y` does not suppress. The installer runs apt inside spin_cmd (output redirected, process backgrounded), so the prompt is invisible and blocks on the TTY (SIGTTIN) → the install hangs forever (reported as the spinner stuck "still pulling conntrack" on Ubuntu 24.04). Pass DEBIAN_FRONTEND=noninteractive + NEEDRESTART_MODE=a through `sudo env` (sudo resets the env) on every apt path the installer drives: - PM_INSTALL: conntrack/openssl/curl/tar (+ nvidia-container-toolkit via $PM_INSTALL) - get.docker.com convenience script (runs apt-get internally) - WSL2 NVIDIA Container Toolkit heredoc in install-k8s.ps1 (parity) Reuses the existing `sudo env VAR=val` pattern (install_k3d, #718). Adds a bats guard asserting apt stays non-interactive. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
👋 Heads-up — Code review queue is at 18 / 8 Above the WIP limit. The team convention is to review existing PRs before opening new work. Open PRs currently in Code review (oldest first):
Pull from review before opening new work. (This is a nudge from the kanban WIP check, not a block.) |
…g the install (#210) Stacked on #212 (the needrestart non-interactive fix). This adds the lock dimension #212 doesn't cover: on a freshly-booted Ubuntu, apt-daily / unattended-upgrades hold the dpkg lock and apt-get waits on it forever — and spin_cmd hides apt's "Waiting for cache lock" line, so it looks frozen. - setup_pm: add -o DPkg::Lock::Timeout=600 to the apt update/install commands so the wait is bounded and fails with a clear error instead of hanging. - add apt_wait_for_lock: a visible, bounded "Waiting for background system updates to finish…" step before the docker / system-deps installs. - bats: assert the apt commands carry the lock timeout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Heads-up @LukasWodka: #211 was chasing the same Our two PRs overlapped on the non-interactive Suggested merge order: this PR (#212) into |
…g the install (#210) Stacked on #212 (the needrestart non-interactive fix). This adds the lock dimension #212 doesn't cover: on a freshly-booted Ubuntu, apt-daily / unattended-upgrades hold the dpkg lock and apt-get waits on it forever — and spin_cmd hides apt's "Waiting for cache lock" line, so it looks frozen. - setup_pm: add -o DPkg::Lock::Timeout=600 to the apt update/install commands so the wait is bounded and fails with a clear error instead of hanging. - add apt_wait_for_lock: a visible, bounded "Waiting for background system updates to finish…" step before the docker / system-deps installs. - bats: assert the apt commands carry the lock timeout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
On Ubuntu 22.04+ (incl. 24.04) the needrestart package hooks
apt-get installand opens an interactive "Which services should be restarted?" prompt.-ydoes not suppress it.The installer runs apt inside
spin_cmd, which redirects stdout/stderr to a log and backgrounds the process. So the prompt is invisible (only the spinner shows) and, being backgrounded, blocks the moment it reads the TTY (SIGTTIN) — the install hangs forever. The reported symptom was the spinner stuck "still pulling conntrack" on a fresh Ubuntu 24.04 host: the package was downloading fine; it was waiting on a hidden prompt.(The authors already knew "spinners hide prompts" —
preflight_sudowarms the sudo cache for exactly this reason — butneedrestart/debconfwere missed.)Fix
Pass
DEBIAN_FRONTEND=noninteractive+NEEDRESTART_MODE=athroughsudo env(sudo resets the environment, so the vars must be set through it) on every apt path the installer drives:PM_INSTALL— conntrack / openssl / curl / tar (andnvidia-container-toolkit, which calls$PM_INSTALL)scripts/lib/setup-linux.shget.docker.comconvenience script (runsapt-getinternally)scripts/lib/setup-linux.shscripts/install-k8s.ps1Reuses the established
sudo env VAR=valpattern already used forinstall_k3d(#718).Tests
scripts/tests/setup-linux.bats:setup_pm: apt is non-interactive (needrestart/debconf guard)— assertsDEBIAN_FRONTEND=noninteractive,NEEDRESTART_MODE=a, andsudo envinPM_INSTALL.get.docker.comtest now also asserts the non-interactive env.bats scripts/tests/setup-linux.batsis green for every touched test. Two unrelated tests (Amazon Linux → dnf docker, RHEL clone → docker-ce) fail only on macOS dev machines because of BSD-vs-GNUgrepin the/etc/os-releasemock; they pass in CI on Linux and are untouched here.Out of scope / follow-up
scripts/lib/gpu-amd.sh:53(sudo apt-get install … amdgpu-install.deb) is a direct, visible apt-get (not wrapped inspin_cmd), so a needrestart prompt there is annoying but not a silent hang. The same env could be added for consistency in a later pass.scripts/tests/distro-prereqs.shis a CI-only helper that runs as root in minimal containers (no needrestart) — no exposure.