Skip to content

fix: reduce legacy Linux custom data encoding overhead - #9880

Merged
Shun Lyu (sinmentis) merged 4 commits into
mainfrom
sinmentis/40305782
Oct 29, 2026
Merged

Shun Lyu (sinmentis) merged 4 commits into
mainfrom
sinmentis/40305782

Conversation

@sinmentis

@sinmentis Shun Lyu (sinmentis) commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Remove per-file gzip/Base64 encoding from traditional Linux CustomData, which is already gzipped as a whole. Preserve the minifier from #9940 in the shared script-rendering path, so both delivery modes use the same minified bytes. Render plain file contents as YAML-native double-quoted strings, omit the optional encoding key, and reject invalid UTF-8 instead of silently replacing bytes.

Keep scriptless, Flatcar, and ACL encoding unchanged. Preserve main's file selection, contents, permissions, ownership, paths, and boot commands. No size-limit increase, additional dependency, or CSE command change.

The outer gzip checksum remains. There is no additional runtime per-file checksum gate.

This adds headroom on top of the minifier. Final encoded production payload lengths, compared with main at 48e4c052f2 using identical fixtures:

Distro / cloud Main with minifier This PR Saved
Ubuntu 24.04 Gen2 / public 77,632 70,340 7,292
Ubuntu 24.04 Gen2 / custom 85,748 77,952 7,796
Azure Linux 3 Gen2 / public 75,672 68,212 7,460
Azure Linux 3 Gen2 / custom 83,796 75,836 7,960

All four fixtures fit the 87,380-character limit. These are representative configurations, not worst-case bounds.

Validation:

  • AgentBaker and hotfix-renderer Go tests and CI-matching Go lint pass on the combined implementation.
  • Independent main/PR exports match all delivered file hashes, permissions, ownership, and boot commands across the four fixtures above.
  • All 12 public/custom-cloud size cases pass across Ubuntu 22.04, 24.04, 26.04 minimal, CBL-Mariner 2, and Azure Linux 2/3. Production script round-trip tests check that plain delivery does not bypass minification.
  • Regression coverage checks decoded file equivalence, LocalDNS on/off, pre-provisioning, custom clouds, unchanged alternate modes, and whitespace preservation.
  • YAML-native quoting preserves Unicode line breaks, including U+0085. Eight edge cases pass the installed cloud-init write_files module on Ubuntu 24.04 (26.1) and Azure Linux 3 (24.3.1), with matching file hashes and metadata. Paths were isolated and cleaned up; these are not full-bootstrap tests.
  • Before integration with fix: use shfmt minifier and move unused functions #9940, a standalone Node Auto Provisioning (NAP) basic scale-up test passed on Ubuntu 24.04 (cloud-init 26.1): a new node was Ready, all 10 test pods were ready, cloud-init exited 0 with no errors, and all 17 delivered files matched their contents, permissions, and ownership. This covered one scenario, not the full NAP check-in suite. The test clusters and isolated environment were cleaned up. The combined implementation has not had a new standalone run.
  • Hotfix Python tests pass 28/29. The remaining custom cloud only expectation in test_production_renderer_omits_empty_platform_payloads was reproduced on unchanged main at 48e4c052f2.

Which issue(s) this PR fixes:

AB#40305782

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Windows Unit Test Results

  3 files   18 suites   1m 16s ⏱️
662 tests 662 ✅ 0 💤 0 ❌
685 runs  685 ✅ 0 💤 0 ❌

Results for commit 61f82bf.

♻️ This comment has been updated with latest results.

This comment was marked as resolved.

Copilot AI balanced review requested due to automatic review settings October 23, 2026 03:57

This comment was marked as duplicate.

@timmy-wright

Copy link
Copy Markdown
Contributor

Review: fix: reduce legacy Linux custom data encoding overhead

What is good

The change reduces encoding overhead without dropping delivered modules or depending on a newer VHD. LocalDNS remains an unconditional file entry, preserving old-image provisioning behavior (template, lines 140-144).

One mode predicate selects both script representation and YAML formatting. Scriptless, Flatcar and ACL retain their existing encoding; JSON serialization handles quoting at both the YAML-scalar and outer JSON boundaries (baker.go, lines 348-364, lines 702-735).

The regression tests inspect the final production payload and compare decoded file contents and metadata across distro, custom-cloud, LocalDNS and pre-provisioning combinations, rather than checking encoding labels alone (tests, lines 16-120). An additional review-time comparison of actual base/head output confirmed identical decoded cloud-config for both Ubuntu and Azure Linux custom-cloud fixtures, including all 18 files.

Review outcome

PR: #9880

Reviewed head: d4da1bb717df4fac1a8861bdaacaa93aac5ce104
Base: 732fedcbe0fcc8258a8f627b18a66d889b9edaed
Report version: v1, draft-only pending reviewer approval.

Intent: Remove inner gzip/base64 only for traditional Linux CustomData, retaining outer compression, decoded file bytes, paths, ownership, permissions and existing delivery behavior. Preserve alternate modes and six-month VHD compatibility. No increased payload limit, dependency or shell-body change.

Risk and depth: Medium-high review risk because this serialization path feeds Linux node bootstrap. Planned units were encoder selection, YAML/JSON/compression boundaries, alternate modes/hotfix consumers, and behavioral validation. All seven distinct lenses completed against the current revision, including refreshes where needed; agents ran in waves of at most three. The eighth agent completed sequential previous-comment verification. All planned units received source review; deployed cloud-init/image-version validation remains outside the completed evidence.

Conclusion: No supported introduced defect was found. Current-head focused tests, Go CI, CodeQL and all three lint jobs pass. This is not an unconditional merge-readiness assessment: infrastructure checks remain pending, and an existing request for supported-image cloud-init confirmation remains unverified. Ubuntu custom-cloud overflow remains outside this PR under #9790; it is not resolved by this change.

The PR moved from 18c6ca86a65853bd6f094d1a5da59e7a586771a2 during review. Current source was read and tested from an immutable archive without switching or modifying the original checkout.

Comments, ordered by importance

No retained blocking defects, additional blocking validation gates, non-blocking recommendations or nitpicks.

The readability lens suggested documenting the YAML-value helper's input/output contract. Current callers already obey the documented paired-helper convention; no present defect was demonstrated. This optional documentation preference was not promoted to a finding.

H1. Existing question: supported-image cloud-init confirmation

Canonical discussion: existing review summary. Classification: Question, report-only; do not create a duplicate inline comment.

The earlier reviewer requested human confirmation using actual cloud-init on supported Linux images. Current source, Go tests and review-time PyYAML comparisons support the serialization contract, but none executes the guest write_files module across the supported-image window. If an implementation rejects or misdecodes the representation, bootstrap file delivery could fail; no such implementation or failure was demonstrated.

The narrow next action is to supply representative supported-image cloud-init/write-files evidence tied to this revision, including image and cloud-init versions and resulting file bytes/metadata. Existing provisioning-gate evidence may suffice if it actually exercises that path. This review does not impose a new exhaustive image matrix or assert an unproven compatibility defect. Source: encoding helpers, lines 702-720. Confidence: high that the requested evidence is missing, not that a defect exists.

Security findings

# Severity File Lines Vulnerability Confidence
- - - - No supported exploitable finding in the reviewed changes -

This is a bounded manual security review, not a completed automated security audit. Gitleaks, Semgrep, OSV-Scanner, Trivy and Checkov were unavailable; no tools were installed.

Automation evidence

Current-head Go CI, CodeQL Analyze(go), shell tests/checks, Pester, and root/nested lint checks pass. The exact head was verified for Go CI, CodeQL and lint runs. Passing checks support their respective contracts, not operational safety or production performance.

Historical lint run 39897053855 reported two cognitive-complexity violations at the earlier head. Helper extraction in the current head addresses them; run 39897767878 passes all three lint jobs. No obsolete lint finding is retained.

The Python hotfix suite has one failing custom-cloud subcase. The same failure was independently reproduced at the immutable base revision, so it is not attributed to this PR.

Previous review comments

Inventory cutoff: 2026-10-23 04:01:27 UTC. All pages retrieved for general comments, review bodies, inline comments and review threads. Five unique source comments, five concern-level todos; all five sequential adjudications are done, zero blocked or pending. Four outcomes are not actionable, one cannot verify; addressed, partial, unaddressed and duplicate counts are each zero. No inline threads, replies or provider-resolution discrepancies were present. A completed todo means adjudicated, not fixed; the history must not be described as "all comments resolved."

Detailed concern ledger: session ledger. Every concern ID below has prefix pr9880-history-d4da-.

Source comment Concern todo suffix Provider state Independent result Current evidence / missing evidence
6356952326 6356952326-1 General comment; resolved/outdated N/A Not actionable Windows results at current head; no independent request and no Windows production changes
6356972643 6356972643-1 General comment; resolved/outdated N/A Not actionable Go coverage metrics, no requested behavior/threshold; body does not identify revision
6356974310 6356974310-1 General comment; resolved/outdated N/A Not actionable ShellSpec coverage metrics, no requested behavior/threshold; no shell-body changes
5623706117 5623706117-1 COMMENTED review at old head; resolved/outdated N/A Cannot verify H1: offline preservation checks pass, supported-image actual-cloud-init confirmation unavailable
6357050091 6357050091-1 General comment; resolved/outdated N/A Not actionable Pester coverage metrics, no requested behavior/threshold; no Windows production changes

All five comments are bots. The summary's generated "No open issues" wording is not a provider resolution flag and does not close H1. New or edited comments after the cutoff are not covered by this frozen inventory.

Validation and coverage

Check / review unit Revision / artifact Result and actual depth Limitation
Strengths / security / design Current head; completed lens reports and revision addenda Full scoped diff plus lifecycle ownership, trust boundaries, helper/caller contracts Security scanner limitations below
Reliability / performance / readability / correctness Current head; completed lens reports Full scoped diff plus mode transitions, ANC/hotfix consumers, serialization and test semantics No guest lifecycle or production-performance measurement
Previous comments Current head; complete inventory at 04:01:27 UTC Five comments/todos independently adjudicated, one at a time H1 cannot verify; later discussion outside cutoff
Focused encoding/delivery/round-trip Go tests Current head; current-tests.log Passed; agent package 3.462s, hotfix renderer 0.062s Not a guest boot
Exact base/head decoded comparison Immutable base and head; base-rendered/, current-rendered/ PyYAML parsing plus legacy gzip decoding: complete cloud-config objects equal for both platforms, 18 files each Existing custom-cloud CLI fixtures, not every configuration
Go CI Current head; run 39897767818 Success, inspected CI and API head SHA Not independently rerun as a full suite
Root and nested lint Current head; run 39897767878 All three jobs successful, inspected CI and API head SHA Local linter is older; not substituted for CI
CodeQL Analyze(go) Current head; run 39897767883 Success, inspected CI and API head SHA No complete local scanner pipeline
Hotfix Python suite Current head; current-python.log 29 tests, one failing custom-cloud subcase Failure also reproduced at base, base-python.log
Diff whitespace Base to current head git diff --check passed Formatting check only
Final encoded fixture size Current head; current-tests.log Ubuntu public 80,240; Azure Linux 2/3 public 77,344; Azure Linux custom 85,392; limit 87,380 Ubuntu custom 88,352 exceeds limit; separate #9790
Rendering benchmark Earlier head 18c6ca86; five iterations Legacy surrogate 40.0ms/op and 15.66MB/op; new path 35.2ms/op and 13.28MB/op Short historical sample; not production latency, peak memory or a current-head benchmark
Guest compatibility Source tracing, Go/PyYAML parsing, archived cloud-init documentation No supported compatibility failure identified; current ANC accepts empty encoding Historical cloud-init versions/deployed ANC binaries and PIS boots not executed
Linux VHD / GPU / Windows E2E Current-head check inventory Pending at collection No success or failure inferred
Windows VHD / generic Agentbaker E2E Current-head check inventory Neutral Not counted as passes

The in-tree legacy comparator uses the head template with legacy helpers, not immutable base output. The independent base/head comparison above covers that specific shared-template blind spot for its two fixtures. No provisioning-speed, peak-memory or complete historical-runtime guarantee is asserted. Historical cloud-init/deployed ANC certification would need image-domain evidence; no other domain-expert need emerged.

Final remote-head recheck matched the reviewed revision. Final check inventory: 21 successes, one skipped, three queued, twelve in progress, two neutral; no failed conclusion. Evidence: final-checks.json in the session directory.

The parent completed the report's comment-quality and completeness checks: obsolete automation findings removed; the optional documentation suggestion not promoted; existing concern linked rather than duplicated; source and runtime evidence distinguished; all eight assignments accounted for. Self-evaluation was performed inline without an additional reviewer.

Evidence directory: /home/tim/.copilot/session-state/28f698ed-78aa-4f5b-9ac8-52b2697bd727/files/pr9880/.

Publication plan

General PR comment: this report, only after explicit reviewer approval for version v1 and the reviewed revision.
Inline comments: none.
Report-only comment: H1, preserving the existing discussion rather than duplicating it.
Known thread/comment to avoid duplicating: review 5623706117, linked above.
Review action: comment only; no approval/rejection vote.
Status: draft, awaiting reviewer approval. No remote writes have occurred.

@cameronmeissner

Copy link
Copy Markdown
Contributor

attempting to test with NAP check-in tests before merge

Comment thread pkg/agent/baker.go Outdated
Copilot AI balanced review requested due to automatic review settings October 26, 2026 20:47

This comment was marked as duplicate.

Copilot AI balanced review requested due to automatic review settings October 26, 2026 22:07

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

Targeted verification confirms that inline encoding guards break hotfix parsing and conflict with a retained test assertion.

2 open issues

Review effort: Balanced

Comment thread hotfix/hotfix_generate_test.py Outdated
Comment thread parts/linux/cloud-init/nodecustomdata.yml Outdated
Copilot AI balanced review requested due to automatic review settings October 26, 2026 22:50
Copilot AI balanced review requested due to automatic review settings October 26, 2026 22:54

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 bootstrap serialization change warrants human confirmation of full-node provisioning compatibility across supported VHDs beyond the reported isolated cloud-init checks.

No open issues 🎉

Review effort: Balanced

Comment thread pkg/agent/baker.go
Copilot AI balanced review requested due to automatic review settings October 27, 2026 09:57

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

Production bootstrap encoding and the new checksum gate warrant human compatibility review across supported images beyond the single reported live-bootstrap scenario.

No open issues 🎉

Review effort: Balanced

Shun Lyu (sinmentis) and others added 3 commits October 29, 2026 10:45
Avoid per-file gzip/Base64 when the complete payload is already compressed. Use YAML-native quoting and omit the plain-text encoding key. Preserve file bytes and alternate delivery modes.

AB#40305782

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 162f68f8-110a-4d60-b4fe-b9fb42253542
Check delivered file contents and lengths before initialization. Keep expected checksums in the CSE command so CustomData remains unchanged.

AB#40305782

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 162f68f8-110a-4d60-b4fe-b9fb42253542
Revert 89864be. The checksum gate can reject valid files when the CSE command and delivered scripts differ across provisioning attempts. Keep the CustomData compression improvement.

AB#40305782

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 162f68f8-110a-4d60-b4fe-b9fb42253542

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

Human assessment is needed because payload equivalence tests do not cover the distinct OSGuard and custom-image provisioning paths.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 28, 2026 21:47

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 changes lack an end-to-end provisioning run, and compatibility with older supported cloud-init images needs human validation.

No open issues 🎉

Review effort: Balanced

Comment thread pkg/agent/variables.go Outdated
Comment thread pkg/agent/baker.go Outdated
Keep rendered file contents unencoded until template output and return Linux YAML directly without a JSON round trip.

AB#40305782

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 162f68f8-110a-4d60-b4fe-b9fb42253542
Copilot AI balanced review requested due to automatic review settings October 28, 2026 22:02
@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
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% (6059 / 8026) ➖

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 combined bootstrap changes lack end-to-end provisioning validation across supported Linux images, requiring human review of compatibility before rollout.

No open issues 🎉

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
shellspec spec 29% ❌
Summary 29% (4702 / 16369) ❌

@sinmentis
Shun Lyu (sinmentis) merged commit f56ec25 into main Oct 29, 2026
42 checks passed
@sinmentis
Shun Lyu (sinmentis) deleted the sinmentis/40305782 branch October 29, 2026 02:25
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.

6 participants