Skip to content

fix(vhd): disable apt-daily units before the pre-install reboot - #10203

Open
Artur Khantimirov (r2k1) wants to merge 1 commit into
devfrom
r2k1-vhd-dpkg-lock-failure
Open

Artur Khantimirov (r2k1) wants to merge 1 commit into
devfrom
r2k1-vhd-dpkg-lock-failure

Conversation

@r2k1

@r2k1 Artur Khantimirov (r2k1) commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 547ef764af92fa836ea1a79e1617e3c39fceb816

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Plain move of the existing block; no new logic.
↑ All Ubuntu Packer templates reboot right after pre-install-dependencies.sh; OS/UBUNTU_OS_NAME are set there; no early exit.
↑ make validate-shell and ShellSpec pass; one GPT review pass found no issues.
↓ No VHD build ran with this change.
Diagnosis confidence 7/10 ↑ Old code masked/disabled the units only after the reboot, so a unit that a Persistent=true timer started at boot kept running.
↓ No log names the exact unit that held the lock.
Evidence fit 7/10 ↑ All 4 attempts failed at different apt calls about 3–4 min after the reboot.
↑ The passing CVM run 193168482 and the FIPS job show the same contention after the reboot.
↓ If the holder is not apt-daily, this change does not help.

What this PR does / why we need it:

Daily Linux VHD build 193348731 failed in build2004cvmgen2containerd. All 4 Packer attempts failed about 3–4 minutes after the reboot, each at a different apt call:

dpkg: error: dpkg frontend lock is locked by another process
E: Could not get lock /var/lib/apt/lists/lock. It is held by process 13116 (apt-get)

The contention is systematic; the failure depends on timing:

  • The passing 20.04 CVM run (193168482) has the same dpkg frontend lock error at a call that tolerates it.
  • The passing 20.04 FIPS job in the same build: Could not get lock /var/lib/apt/lists/lock. It is held by process 2531 (apt-get) right after the reboot.

Cause: the build intentionally masks and disables apt-daily* units and writes 99periodic. But it did this in install-dependencies.sh, after the Packer reboot. The timers are Persistent=true, so at boot they can start apt-daily before the script runs. Mask/disable do not stop a unit that already runs, so it holds the apt/dpkg locks.

Before: install-dependencies.sh (after the reboot) masks/disables the units and writes 99periodic.

After: the same block, unchanged, runs at the end of pre-install-dependencies.sh, before the reboot. After the reboot, masked services cannot start and disabled timers do not fire. A unit that runs during pre-install stops at the reboot.

No new ShellSpec test: the change moves inline top-level code; there is no function to test.

This replaces the retry approach in closed #10202.

Validation:

  • make validate-shell: passed.
  • shellspec --shell bash spec/vhdbuilder/packer/pre_install_dependencies_spec.sh spec/vhdbuilder/packer/install_dependencies_spec.sh: passed (8 examples, 0 failures). (macOS /bin/sh fails on unchanged dev for the pre-install spec, so I used bash.)
  • VHD build: not run.

Which issue(s) this PR fixes:

Fixes AB#40919782

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Windows Unit Test Results

  3 files   21 suites   1m 21s ⏱️
817 tests 817 ✅ 0 💤 0 ❌
844 runs  844 ✅ 0 💤 0 ❌

Results for commit 547ef76.

♻️ This comment has been updated with latest results.

The Ubuntu VHD build masked and disabled apt-daily units in
install-dependencies.sh, after the reboot that follows
pre-install-dependencies.sh. Persistent timers can start these units at
boot, and a running unit holds the apt/dpkg locks during the build.
Move the existing block before the reboot so the units cannot start.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@r2k1 Artur Khantimirov (r2k1) changed the title fix(vhd): stop apt-daily jobs before Ubuntu VHD apt work fix(vhd): disable apt-daily units before the pre-install reboot Nov 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
test 0% ❌
windows 27% ❌
parts_windows Package 1 74% ➖
staging_cse_windows Package 1 72% ➖
debug 0% ❌
provisioningscripts 2% ❌
Summary 40% (2077 / 7284) ❌

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
shellspec spec 30% ❌
Summary 30% (5129 / 16918) ❌

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
github.com/Azure/agentbaker/aks-live-patching/pkg/status 100% ✔
github.com/Azure/agentbaker/apiserver 52% ❌
github.com/Azure/agentbaker/cmd 0% ❌
github.com/Azure/agentbaker/cmd/starter 0% ❌
github.com/Azure/agentbaker/fuzz/api 0% ❌
github.com/Azure/agentbaker/hotfix/render-nodecustomdata 35% ❌
github.com/Azure/agentbaker/pkg/agent 79% ➖
github.com/Azure/agentbaker/pkg/agent/datamodel 78% ➖
github.com/Azure/agentbaker/pkg/agent/toggles 0% ❌
github.com/Azure/agentbaker/pkg/vhdbuilder/datamodel 87% ✔
github.com/Azure/agentbaker/aks-node-controller 73% ➖
github.com/Azure/agentbaker/aks-node-controller/common 100% ✔
github.com/Azure/agentbaker/aks-node-controller/helpers 68% ➖
github.com/Azure/agentbaker/aks-node-controller/parser 88% ✔
github.com/Azure/agentbaker/aks-node-controller/pkg/gpu 100% ✔
github.com/Azure/agentbaker/aks-node-controller/pkg/nodeconfigutils 91% ✔
github.com/Azure/agentbaker/aks-node-controller/utils 0% ❌
Summary 84% (6297 / 8227) ✔

@r2k1
Artur Khantimirov (r2k1) marked this pull request as ready for review November 26, 2026 20:01
Copilot AI balanced review requested due to automatic review settings November 26, 2026 20:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The existing suites do not execute the pre-install block, leaving Ubuntu configuration, non-Ubuntu skip behavior, and ordering that prevents the reboot-related lock race without regression coverage.

1 open issue
What changed in this PR

This PR moves Ubuntu’s automatic apt-update suppression earlier in the VHD build to prevent apt-daily jobs from starting at the pre-install reboot and competing for package-manager locks. It replaces the retry approach proposed in #10202.

Changes:

  • Moves the existing service masking, timer disabling, and 99periodic settings into pre-install, before the reboot.
  • Removes the post-reboot copy and adds comments explaining why the ordering matters.
File Description
vhdbuilder/​packer/​pre-install-dependencies.sh Applies Ubuntu apt-daily suppression before the reboot.
vhdbuilder/​packer/​install-dependencies.sh Removes the suppression block from the post-reboot phase.

Review effort: Balanced

Comment on lines +367 to +369
systemctl mask apt-daily.service apt-daily-upgrade.service || exit 1
systemctl disable apt-daily.service apt-daily-upgrade.service || exit 1
systemctl disable apt-daily.timer apt-daily-upgrade.timer || exit 1

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.

2 participants