Skip to content

fix: report PIS bake completion - #9260

Open
Artur Khantimirov (r2k1) wants to merge 1 commit into
mainfrom
r2k1-pis-dual-completion-markers
Open

Artur Khantimirov (r2k1) wants to merge 1 commit into
mainfrom
r2k1-pis-dual-completion-markers

Conversation

@r2k1

@r2k1 Artur Khantimirov (r2k1) commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

What

Make aks-node-controller provision-wait report the result of a PIS image bake.

How

  • Pre-provision writes both base_prep.complete and provision.complete after provision.json.
  • Normal provisioning continues to write provision.complete.
  • supportsScriptlessProvisioning accepts NBC scriptless phase 2 during pre-provision, while other scriptless modes keep their existing restrictions.

AKS-RP generalization removes the per-run result and configuration files before image capture while preserving base_prep.complete.

Rollout

Rollout is controlled by the RP's existing PreProvisionOnly fallback in PR 16870787 — no AgentBaker flag is needed.

  1. Ship AKS-RP cleanup in PR 16870787.
  2. Ship this change in a Linux VHD.
  3. Remove the RP fallback for that VHD version, together with mapping PreProvisionOnly into AKSNodeConfig.

Validation

  • go test ./pkg/... — passed
  • shellspec spec/parts/linux/cloud-init/artifacts/cse_start_spec.sh — passed
  • cd e2e && go test ./... && go vet ./... — passed

@github-actions

github-actions Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Windows Unit Test Results

  3 files   18 suites   56s ⏱️
662 tests 662 ✅ 0 💤 0 ❌
685 runs  685 ✅ 0 💤 0 ❌

Results for commit a407939.

♻️ This comment has been updated with latest results.

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.

Pull request overview

Unifies Linux CSE completion reporting for normal provisioning and PIS image-bake runs.

Changes:

  • Always writes provision.complete; PIS runs also write base_prep.complete.
  • Cleans transient provisioning state before E2E image capture.
  • Adds ShellSpec coverage and documents marker semantics.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
parts/linux/cloud-init/artifacts/cse_start.sh Updates completion-marker handling.
spec/parts/linux/cloud-init/artifacts/cse_start_spec.sh Tests marker behavior across modes.
e2e/test_helpers.go Validates and cleans PIS bake state.
aks-node-controller/README.md Documents dual-stage reporting and cleanup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings August 20, 2026 03:25
Copilot AI review requested due to automatic review settings August 21, 2026 04:37

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

Suppressed comments (3)

pkg/agent/baker.go:264

  • This comment still says a bake produces provision.complete, but the new pre-provision branch deliberately never writes that durable marker; it writes /run/azure/pre-provision.complete, and the controller must watch it. Keeping the capability contract accurate is important for callers implementing the minimum-VHD rollout gate.
// the CSE command is `aks-node-controller provision-wait` and it reports the result recorded in
// provision.json once provision.complete appears.
//
// A PreProvisionOnly (PIS image bake) run only produces provision.complete on a VHD whose
// cse_start.sh writes it for the pre-provision phase. Older VHDs write only base_prep.complete, so

aks-node-controller/app.go:939

  • 🟡 Medium Risk — 🔧 Script Logic: The volatile marker lasts for the entire boot, but this fast path treats any existing copy as belonging to the current attempt. If provisioning is restarted on the same bake VM, the previous marker remains, so provision-wait can immediately read the previous result (or race with resetStaleProvisionResult removing it) before the new cse_start.sh run finishes. Clear or rotate this marker at the start of each attempt, with ordering that guarantees the waiter cannot observe the old copy, and cover the retry path in tests.
	if marker, found := firstExistingMarker(markers); found {

e2e/test_helpers.go:115

  • This capability description names provision.complete, but the bake path now explicitly avoids that durable marker and relies on /run/azure/pre-provision.complete plus matching controller support. As written, it can lead maintainers to gate only on the script change and overlook the controller-side prerequisite.
// A bake only reports its result through provision.complete on a VHD whose cse_start.sh writes that
// marker for a pre-provision run. Released VHDs predating that change write only base_prep.complete,

@r2k1

Copy link
Copy Markdown
Contributor Author

CI evidence for the volatile-marker design (branch head bedb573d21).

AKS Linux VHD Build - PR check-in gate: pass (build 177594993) — builds VHDs from this PR and runs E2E against them, the only place a bake can exercise the new markers.

gotestsum hides t.Logf for passing tests, so I pulled the raw e2e-test-log/test-log.json artifact to confirm the assertions ran rather than being skipped:

scriptless CSE (provision-wait):  true   Test_Ubuntu2404_VHDCaching/VHDCreation
                                  true   Test_Ubuntu2604Minimal_VHDCaching/VHDCreation

pass  Test_Ubuntu2404_VHDCaching/VHDCreation
pass  Test_Ubuntu2404_VHDCaching/VHDCreation/VMProvision
pass  Test_Ubuntu2604Minimal_VHDCaching/VHDCreation
pass  Test_Ubuntu2604Minimal_VHDCaching/VHDCreation/VMProvision
failing top-level tests: none

Stage ordering shows the assertions gate the capture — === Creating VHD Image === only runs once every stage-1 check passes, and generalization runs immediately after:

[151.1s] preparing AKS node done -> validating VM...
         === Creating VHD Image ===
[155.0s] Removing per-run provisioning state before image capture...
[256.4s] validating VM done (105.3s)
VMProvision: [151.8s] preparing AKS node done -> validating VM done (98.3s)

So on a VHD built from this PR: the bake wrote base_prep.complete plus the volatile /run/azure/pre-provision.complete, did not write provision.complete (generalization now asserts its absence rather than deleting it, and never fired), and provision-wait — driven purely by the volatile marker — exited 0 printing provision.json. The node created from the captured image then saw no volatile marker, kept the baked base_prep.complete, skipped basePrep, wrote a fresh provision.complete / provision.json / nbc-cmd this boot, and reached Ready.

Backward compatibility on released VHDs (Agentbaker E2E, where UsesFreshlyBuiltVHD() is false): both Linux VHDCaching scenarios passed and the new test ! -e /opt/azure/containers/provision.complete assertion never fired, confirming old VHDs never wrote the durable marker for a bake.

Flakes seen and resolved on retry (none marker-related — grep -c for provision.complete|pre-provision.complete|base_prep|provision.json in the failure output was 0):

  • Agentbaker E2E: 8 × error executing command on pod: Internal error occurred: error sending request (apiserver exec transport) plus perf thresholds; retry left only ubuntuSnapshotUpdate took 2.214s, exceeds threshold 2s, the identical signature on refs/heads/main build 177574603. Now passing.
  • Gate E2E first attempt: Task_configureKubeletAndKubectl took 31.093s, exceeds threshold 27s — a CSE perf threshold, not a VHDCaching test. Now passing.
  • Agentbaker Windows E2E: first attempt was a 17-minute VMSS context deadline exceeded. Now passing.
  • lint jobs once failed in ~12s with golangci-lint config verify → failing loading https://golangci-lint.run/jsonschema/golangci.v2.8.jsonschema.json: context deadline exceeded; a network flake fetching the schema, which also hit lint (aks-live-patching), a module this PR does not touch. Now passing.

Still red: Agentbaker GPU E2E (GalleryImageNotFound), which fails on every recent run including refs/heads/main — pre-existing and unrelated.

All GitHub checks pass.

Copilot AI review requested due to automatic review settings August 24, 2026 22:56
@r2k1 Artur Khantimirov (r2k1) changed the title fix: always write provision.complete so PIS bake reports CSE result fix: report PIS bake completion through a volatile marker Aug 24, 2026

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.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

@r2k1 Artur Khantimirov (r2k1) changed the title fix: report PIS bake completion through a volatile marker fix: report PIS bake completion Aug 25, 2026
Copilot AI review requested due to automatic review settings August 25, 2026 00:11

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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread pkg/agent/datamodel/types.go Outdated
Comment on lines +1817 to +1821
// EnableScriptlessPreProvision lets a PreProvisionOnly (image bake) run use scriptless phase 2,
// so the bake reports its result through the same `aks-node-controller provision-wait` CSE
// command as a normal node. Default false. Enabling it requires a VHD whose cse_start.sh writes
// /run/azure/pre-provision.complete and whose aks-node-controller watches it, and requires the
// caller to propagate PreProvisionOnly into the AKSNodeConfig it builds.
Copilot AI review requested due to automatic review settings August 25, 2026 01:26

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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread e2e/test_helpers.go Outdated
Comment on lines +159 to +160
cleanup := "sudo rm -f /opt/azure/containers/provision.complete /var/log/azure/aks/provision.json" +
" /opt/azure/containers/aks-node-controller-config.json /opt/azure/containers/aks-node-controller-nbc-cmd.sh"
@r2k1

Copy link
Copy Markdown
Contributor Author

CI on 1cd647093e (+81/−23).

Everything passes except Agentbaker Windows E2E, which is broken on main.

  • AKS Linux VHD Build - PR check-in gate — pass (1h18m, build 178044449)
  • gate e2e Run AgentBaker E2E — pass
  • Agentbaker E2E — pass
  • Agentbaker GPU E2E — pass
  • all GitHub checks (go-test, shellspec, shellcheck, lint ×3, cue, CodeQL, Pester, version-consistency, …) — pass

The gate builds VHDs from this PR and runs E2E against them, so it is the only place a bake exercises the new marker. From its e2e-test-log artifact:

pass  Test_Ubuntu2404_VHDCaching/VHDCreation
pass  Test_Ubuntu2404_VHDCaching/VHDCreation/VMProvision
pass  Test_Ubuntu2604Minimal_VHDCaching/VHDCreation
pass  Test_Ubuntu2604Minimal_VHDCaching/VHDCreation/VMProvision

Stage ordering shows the assertions gate the capture — === Creating VHD Image === runs only after stage-1 validation, then the RP-matching cleanup, then stage 2 provisions from the captured image:

[120.8s] preparing AKS node done -> validating VM...
         === Creating VHD Image ===
[228.3s] validating VM done (107.5s)
VMProvision: [123.1s] preparing AKS node done -> validating VM...

So on a VHD built from this PR the bake wrote both base_prep.complete and provision.complete, provision-wait reported its result, and after generalization removed the per-run files the derived node provisioned normally and skipped basePrep.

Windows: Test_Windows2022_VHDCaching_LegacyTLSBootstrap/VHDCreation/VMProvision with WINDOWS_CSE_ERROR_START_NODE_RESET_SCRIPT_TASK. The identical test and signature fails on refs/heads/main build 177913450, and Windows E2E has failed on every recent scheduled main run (177913450, 177823134, 177757831, 177623061 — four consecutive days). This PR only changes parts/linux/...; the E2E helper changes are gated behind !IsWindows(), so the Windows path is untouched.

Copilot AI review requested due to automatic review settings August 25, 2026 03:43

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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (1)

e2e/test_helpers.go:161

  • 🟡 Medium Risk — 🏗️ Architecture: This generalization cleanup leaves /opt/azure/containers/enabled_features.sh in the captured image. The scriptless boothook only writes that file when the current request has feature toggles, so a derived node with no toggles will not overwrite a bake-time file; aks-node-controller-launcher.sh will then export the stale bake-time flags. Remove this per-run configuration file before capture alongside the other controller inputs.
			cleanup := "sudo rm -f /opt/azure/containers/provision.complete /var/log/azure/aks/provision.json" +
				" /opt/azure/containers/aks-node-controller-config.json /opt/azure/containers/aks-node-controller-nbc-cmd.sh" +
				" /opt/azure/containers/boothook.sh /opt/bin/boothook.sh"

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2add17d1-59c8-4a9e-b7ec-2ca102204765
@r2k1
Artur Khantimirov (r2k1) force-pushed the r2k1-pis-dual-completion-markers branch from e6090c3 to a407939 Compare October 28, 2026 19:59
Copilot AI balanced review requested due to automatic review settings October 28, 2026 19:59
@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
test 0% ❌
windows 27% ❌
staging_cse_windows Package 1 68% ➖
debug 0% ❌
provisioningscripts 2% ❌
parts_windows Package 1 73% ➖
Summary 39% (1819 / 7001) ❌

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
shellspec spec 28% ❌
Summary 28% (4697 / 16480) ❌

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
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 89% ✔
github.com/Azure/agentbaker/aks-node-controller/utils 0% ❌
github.com/Azure/agentbaker/apiserver 24% ❌
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 78% ➖
github.com/Azure/agentbaker/pkg/agent/datamodel 77% ➖
github.com/Azure/agentbaker/pkg/agent/toggles 0% ❌
github.com/Azure/agentbaker/pkg/vhdbuilder/datamodel 87% ✔
Summary 75% (6024 / 7990) ➖

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.

Comment thread pkg/agent/baker.go
Comment on lines +289 to +290
return config.EnableScriptlessNBCCSECmd ||
(config.EnableScriptlessAKSNodeConfig || config.IsCustomDataOnlyProvisioningEnabled()) && !config.PreProvisionOnly
Comment thread e2e/scenario/provision.go
if scriptless {
checks = append(checks, ValidateFileExists(ctx, scenario, "/opt/azure/containers/provision.complete"))
} else {
checks = append(checks, ValidateFileDoesNotExist(ctx, scenario, "/opt/azure/containers/provision.complete"))
Comment thread e2e/scenario/provision.go
}
nbc.PreProvisionOnly = true
nbc.EnableScriptlessNBCCSECmd = false
nbc.EnableScriptlessNBCCSECmd = scriptless

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