Skip to content

fix(cloud-init): avoid nested script compression - #9753

Open
Ben Brady (benjamin-brady) wants to merge 4 commits into
mainfrom
bbrady/reduce-cloud-init-payload
Open

Ben Brady (benjamin-brady) wants to merge 4 commits into
mainfrom
bbrady/reduce-cloud-init-payload

Conversation

@benjamin-brady

Copy link
Copy Markdown
Member

What this PR does / why we need it:

Render Linux write_files content as literal YAML inside the already-gzipped CustomData payload. Compressing each script before compressing the whole payload increases VM/VMSS CustomData size; the combined GPU/Chrony configuration motivating #9702 exceeded Azure's 87,380-character base64 limit. This PR changes packaging only, retains the same file bytes, paths, modes, owners and ordering, and teaches the hotfix generator to recognize both literal and legacy template entries. Flatcar, ACL and scriptless paths retain gzip write_files encoding. No GPU provisioning changes or CI Go-version pin are included.

Local synthetic fixture on this branch (Ubuntu 22.04 ordinary; not the combined payload from #9702):

ID Payload Base64 characters Gzip bytes
A Before (current main) 85,904 64,428
B After 79,432 59,573

The baseline regression test failed before the change and passed after. Ubuntu 22.04/24.04 and Azure Linux 3 ordinary/PIS payloads all pass strict base64/gzip/YAML decoding, file-content and metadata checks, and the API-size assertions. This is local synthetic validation, not a live E2E result.

Validation: go test ./pkg/agent/... -count=1 — passed; python3 -m unittest hotfix.hotfix_generate_test -v — passed (28 tests); cd aks-node-controller && go test ./... — passed; golangci-lint run ./pkg/agent/... — passed (0 issues); gofmt -l pkg/agent/baker.go pkg/agent/baker_test.go pkg/agent/bakerapi_test.go pkg/agent/utils.go pkg/agent/variables.go — passed (no output).

Which issue(s) this PR fixes:

Prerequisite for #9702; does not close an issue.

Keep scripts literal inside the outer compressed CustomData payload to stay within Azure VMSS limits. Preserve gzip write_files for Flatcar, ACL and scriptless paths.

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

Copilot-Session: 29247196-6c9e-475a-8892-77fc9c3316d4
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Windows Unit Test Results

  3 files   18 suites   1m 9s ⏱️
556 tests 556 ✅ 0 💤 0 ❌
559 runs  559 ✅ 0 💤 0 ❌

Results for commit 487af9a.

♻️ 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.

🟡 Changes recommended

The new helper bypasses automatic transformed-script syntax-test discovery for critical CSE scripts.

1 open finding
What changed in this PR

Updates Linux cloud-init packaging to avoid nested script compression while preserving file contents and compatibility paths.

Changes:

  • Renders eligible write_files entries as literal YAML.
  • Preserves gzip encoding for Flatcar, ACL, and scriptless paths.
  • Updates hotfix generation and adds payload/round-trip tests.
File Description
pkg/​agent/​variables.go Selects literal or gzip file content.
pkg/​agent/​utils.go Separates rendering from compression and safely marshals JSON.
pkg/​agent/​baker.go Renders literal YAML file properties.
pkg/​agent/​baker_test.go Tests YAML round trips and gzip fallback.
pkg/​agent/​bakerapi_test.go Validates payload size, metadata, and bytes.
parts/​linux/​cloud-init/​nodecustomdata.yml Uses the new file-property renderer.
hotfix/​hotfix_generate.py Recognizes legacy and literal template entries.
hotfix/​hotfix_generate_test.py Tests mixed syntax and rendered hotfixes.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/agent/variables.go
Keep transformed-script round-trip and bash syntax checks on scripts routed through getCloudInitFile.

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

Copilot-Session: 29247196-6c9e-475a-8892-77fc9c3316d4
Copilot AI balanced review requested due to automatic review settings October 13, 2026 00:02
@aks-node-assistant

Copy link
Copy Markdown
Contributor

AgentBaker Linux gate detective

Run: 185409097
Failed job/stage/task: e2e / Run AgentBaker E2E / LocalDNSHostsPlugin/Ubuntu2604Minimal

Detective summary: One E2E scenario failed. The LocalDNS hosts plugin cold-start validation truncated /etc/localdns/hosts, attempted to start localdns, and localdns.service exited with status=216/GROUP; the validation then failed the cold-start empty-hosts check. This repeats the existing LocalDNS cold-start empty-hosts start/readiness signature.

Likely cause / signature: e2e-localdns-coldstart-empty-hosts-start-timeout - LocalDNS cannot reliably start after empty-hosts cold start.

Confidence: High for the signature: failed test result, focused E2E log, failed timeline, and prior matching wiki row all point to the same cold-start validation family; medium on root cause because service diagnostics show systemd group failure but not the lower-level localdns process cause.

Recommended owner/action: LocalDNS owner should inspect the cold-start empty-hosts path and the service cgroup/delegate behavior on Ubuntu2604Minimal; PR owner likely only needs action if the cloud-init compression change affects service/cgroup setup, which current evidence does not show.

Strongest alternative: PR-caused cloud-init regression, but the failed scenario is LocalDNS cold-start specific and many adjacent scenarios completed before/after, making a recurring LocalDNS lifecycle flake more likely.

Evidence: build run, failed test run 687073470, E2E task log 624, failed e2e timeline records, build metadata, and wiki tracker.

Wiki: e2e-localdns-coldstart-empty-hosts-start-timeout

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.

🟢 Approval recommended

The packaging change preserves file semantics and compatibility paths with comprehensive regression coverage.

1 open finding

🧠 Review effort: Balanced

@aks-node-assistant

Copy link
Copy Markdown
Contributor

AgentBaker Linux gate detective

Run: 185424174
Failed job/stage/task: e2e / Run AgentBaker E2E / Ubuntu2204_NetworkIsolatedCluster_NonAnonymousACR

Detective summary: One E2E scenario failed after the VMSS and node reached Ready and initial SSH connectivity succeeded. The validation then failed while retrieving kubelet logs and other VM state: SSH commands returned remote command exited without exit status or exit signal, context canceled, and context deadline exceeded across multiple follow-up checks.

Likely cause / signature: e2e-ubuntu2204-networkisolated-ssh-context-canceled - bastion/SSH session context cancellation after node readiness.

Confidence: Medium-high for infrastructure/session flake: failed test record, E2E log, timeline, and successful node readiness/initial SSH all isolate the failure to later remote command/session handling rather than provisioning.

Recommended owner/action: Treat as gate infrastructure/SSH session flake unless it recurs with cloud-init-specific failures; PR owner likely does not need a code change based on this run.

Strongest alternative: PR cloud-init compression caused node-side command instability, but node readiness, pod setup, and initial SSH connectivity all succeeded, and the fatal errors are SSH/session context cancellations during diagnostics.

Evidence: build run, failed test run 687244905, E2E task log 624, failed e2e timeline records, PR cloud-init metadata, and wiki tracker.

Wiki: e2e-ubuntu2204-networkisolated-ssh-context-canceled

Preserve Phase 3 validation and literal payload coverage across the shared test file.

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

Copilot-Session: 29247196-6c9e-475a-8892-77fc9c3316d4
Copilot AI balanced review requested due to automatic review settings October 14, 2026 20:39

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.

🔵 Needs a closer look

Legacy-template compatibility remains broken, and production cloud-init compatibility needs human validation.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread pkg/agent/variables.go

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.

🔵 Needs a closer look

The shared Linux provisioning serialization change has synthetic coverage but warrants human sign-off on live cross-distro cloud-init compatibility.

1 open issue

Review effort: Balanced

Only compress a raw script when a legacy template requests cloudInitData. Keep the literal CustomData path free of nested compression.

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

Copilot-Session: 29247196-6c9e-475a-8892-77fc9c3316d4
Copilot AI balanced review requested due to automatic review settings October 19, 2026 00:55
@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
github.com/Azure/agentbaker/aks-node-controller 72% ➖
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 88% ✔
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 0% ❌
github.com/Azure/agentbaker/pkg/agent 77% ➖
github.com/Azure/agentbaker/pkg/agent/datamodel 76% ➖
github.com/Azure/agentbaker/pkg/agent/toggles 0% ❌
github.com/Azure/agentbaker/pkg/vhdbuilder/datamodel 87% ✔
Summary 74% (5675 / 7635) ➖

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
test 0% ❌
windows 27% ❌
staging_cse_windows Package 1 65% ➖
debug 0% ❌
provisioningscripts 2% ❌
parts_windows Package 1 74% ➖
Summary 38% (1649 / 6831) ❌

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
shellspec spec 25% ❌
Summary 25% (3865 / 15529) ❌

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.

🔵 Needs a closer look

Boot-critical serialization changes warrant human confirmation of live cloud-init compatibility beyond the reported synthetic validation.

1 open issue

Review effort: Balanced

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