fix(installer): bound the apt dpkg-lock wait so a held lock can't hang the install (#210)#211
Merged
Merged
Conversation
Contributor
|
👋 Heads-up — Code review queue is at 17 / 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.) |
32b1d87 to
8d819cc
Compare
…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>
8d819cc to
2481d41
Compare
LukasWodka
approved these changes
Jun 5, 2026
This was referenced Jun 5, 2026
Draft
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #210. Complementary to #212 (now merged) — that PR fixed the needrestart hidden-prompt hang; this one fixes the dpkg-lock hang. Same symptom (
Installing conntrack…freezes on a fresh Ubuntu host), different root cause.Rebased onto
developafter #212 merged, so the diff is the lock dimension only.Root cause
On a freshly-booted host,
apt-daily/unattended-upgradeshold the dpkg lock. The installer'sapt-get installhad no lock timeout, so it waited indefinitely — andspin_cmdredirects apt'sWaiting for cache lock…line into a log file, so it looked frozen with no error.What this adds (on top of #212)
setup_pm: add-o DPkg::Lock::Timeout=600to the aptupdate/installcommands → bounded wait, then a clear failure (whichspin_cmdsurfaces) instead of an infinite silent hang. Appends to fix(installer): keep apt non-interactive so needrestart can't hang installs on Ubuntu 22.04+ #212's non-interactivesudo envcommand, leaving its env exactly as-is.apt_wait_for_lock: a visible, boundedWaiting for background system updates to finish…spinner before the docker / system-deps installs (no-op when apt orfuseris absent, or the lock is free). Placed beforeinstall_docker_engineso theget.docker.comapt path benefits too.setup-linux.bats: assert both apt commands carry the lock timeout (regression guard).Testing
bash -n scripts/lib/setup-linux.sh— clean.setup_pm/apt_wait_for_lockwith the bats mocks and asserted fix(installer): keep apt non-interactive so needrestart can't hang installs on Ubuntu 22.04+ #212's guarantees (sudo env,DEBIAN_FRONTEND=noninteractive,NEEDRESTART_MODE=a) and this PR's (DPkg::Lock::Timeout=in both apt commands) hold together;dnfbranch free of the apt option;apt_wait_for_lockno-ops on the no-fuser/ lock-free paths. All pass.batsisn't installed locally — the cross-distro installer CI exercises the real path.Compatibility
DPkg::Lock::Timeoutis a config key (-o), unknown to pre-2.0 apt (e.g. 18.04) where it's silently ignored — no breakage on older distros.dnf/yum/zypper/pacmanbranches unchanged.Immediate client workaround (no merge needed)
🤖 Generated with Claude Code
Note
Low Risk
Linux installer script and test-only changes; no auth, data, or runtime service logic affected.
Overview
Fixes #210: on fresh Debian/Ubuntu boots, apt-daily / unattended-upgrades can hold the dpkg lock while the Linux installer runs apt behind
spin_cmd, so the install looks frozen (e.g. at “Installing conntrack…”) with no visible “Waiting for cache lock…” message.setup_pmnow passes-o DPkg::Lock::Timeout=600on apt update and install so lock waits are bounded and failures surface instead of hanging silently. A newapt_wait_for_lockruns early ininstall_linux(before Docker/system deps): iffusersees holders on the standard lock paths, it shows a “Waiting for background system updates to finish…” spinner for up to 600s; otherwise it no-ops. Non-apt package managers are unchanged.setup-linux.batsasserts both apt commands include the lock timeout.Reviewed by Cursor Bugbot for commit 2481d41. Bugbot is set up for automated code reviews on this repo. Configure here.