Skip to content

fix: clean up remaining unstripped comments to reduce customdata size - #9892

Merged
Nishchay (awesomenix) merged 1 commit into
mainfrom
abigailliang/customdata-comment-cleanup
Oct 24, 2026
Merged

Nishchay (awesomenix) merged 1 commit into
mainfrom
abigailliang/customdata-comment-cleanup

Conversation

@abigailliang-aks-sig-node

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Follow-up to #9886. Linux traditional customData is very close to MaxCustomDataLength (87,380). Before scripts are embedded, removeComments() in pkg/agent/utils.go strips comments, but only in limited cases:

  • a whole line is dropped only if the trimmed line starts with # or ##;
  • trimTrailingComment() cuts at the last # on the line, only if that # is followed by a space, and never on lines that start with echo.

This PR cleans up the remaining comment patterns that still end up in customData. It changes comments only, so there is no behavior change.

Pattern Why it survives removeComments() Count Change
#EOF end-of-file markers no space after # 18 removed, plus the blank line before them (16 files)
bare # lines inside comment blocks trimmed line is just # 26 removed
trailing comments #amd64 has no space; ## or a #pull URL anchor inside the comment is the last #; echo lines are skipped 8 moved onto their own # line above

block_wireserver.sh is the VHD copy and is not in customData. It gets the same 3 bare # removals so it stays identical to the kubelet.sh heredoc in cse_config_kubelet.sh, as block_wireserver_spec.sh requires.

These are intentionally kept:

  • #HELPERSEOF (cse_main.sh waits for it);
  • heredoc #!/bin/bash shebangs;
  • #cloud-config.

The remaining #EOF markers are in files that are not part of customData.

Linux traditional customData size, main → this PR (limit 87,380):

OS Go 1.26.10 Go 1.27.3
Ubuntu 22.04 / 24.04 (Gen2) 87,488 → 87,260 86,904 → 86,696
AzureLinux V3 / CBL-Mariner V2 84,824 → 84,596 84,244 → 84,008
OSGuard 76,964 → 76,764 76,480 → 76,280
Flatcar 76,496 → 76,304 76,016 → 75,836
ACL 77,452 → 77,252 76,972 → 76,776

gzip output differs between Go versions. CI uses Go 1.27, but go.mod declares go 1.26.0. Built with Go 1.26.x, Ubuntu customData on main is already over the limit: TestLivePatchingUsesVHDInsteadOfCustomData fails at 87,488. With this PR it is 87,260.

This saves only about 230 characters, so it is a stopgap. #9880 is still needed for real headroom.

Validation:

  • go test ./... (Go 1.27.3): pass.
  • GOTOOLCHAIN=go1.26.10 go test ./pkg/agent -run TestLivePatchingUsesVHDInsteadOfCustomData: fails on main (87,488), passes with this PR (87,260).
  • bash -n on all changed scripts: pass.
  • shellcheck, including the POSIX checks from verify_shell.sh: no new findings compared with main.
  • ShellSpec, full suite: no new failures compared with main.

Which issue(s) this PR fixes:

N/A (follow-up to #9886)

removeComments() only drops whole lines that start with "# " or "##", and
trimTrailingComment() only cuts at the last "#" when it is followed by a
space and the line does not start with echo. So "#EOF" markers, bare "#"
lines and a few trailing comments still ship in Linux customData.

In the scripts embedded in Linux customData:
- remove 18 "#EOF" markers (and the blank line left before them)
- remove 26 bare "#" lines inside comment blocks
- move 8 trailing comments that were not stripped onto their own "# " line

block_wireserver.sh gets the same 3 bare "#" removals so it stays
identical to the kubelet.sh heredoc in cse_config_kubelet.sh (enforced by
block_wireserver_spec.sh).

Comment-only change. #HELPERSEOF, heredoc shebangs and #cloud-config are
kept.

Ubuntu 22.04/24.04 traditional customData (limit 87380):
  Go 1.26.10: 87488 -> 87260
  Go 1.27.3:  86904 -> 86696

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c9945208-1180-4141-9674-2b89f5eceb22
@github-actions

Copy link
Copy Markdown
Contributor

Windows Unit Test Results

  3 files   18 suites   1m 10s ⏱️
563 tests 563 ✅ 0 💤 0 ❌
585 runs  585 ✅ 0 💤 0 ❌

Results for commit 480097a.

@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 73% ➖
Summary 38% (1652 / 6834) ❌

@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% (5980 / 7956) ➖

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 comment-only changes preserve executable logic, required markers, and wireserver script parity, with no blocking issues identified.

No open issues 🎉

What changed in this PR

This follow-up to #9886 reduces Linux customData size by cleaning up comments that survive preprocessing, without changing executable logic. It provides short-term headroom while the broader encoding changes in #9880 remain separate.

Changes:

  • Remove unused #EOF markers, adjacent blank lines, and bare comment separators.
  • Move trailing comments onto standalone lines that preprocessing can strip.
  • Keep the VHD wireserver script synchronized with its provisioning heredoc while preserving required markers.
File Description
parts/​linux/​cloud-init/​artifacts/​ubuntu/​cse_install_ubuntu.sh Reformat architecture comment; remove separators and EOF marker.
parts/​linux/​cloud-init/​artifacts/​ubuntu/​cse_helpers_ubuntu.sh Remove EOF marker.
parts/​linux/​cloud-init/​artifacts/​mariner/​cse_install_mariner.sh Move trailing comment; remove separators and EOF marker.
parts/​linux/​cloud-init/​artifacts/​mariner/​cse_helpers_mariner.sh Remove EOF marker.
parts/​linux/​cloud-init/​artifacts/​init-aks-cloud.sh Remove comment separator and EOF marker.
parts/​linux/​cloud-init/​artifacts/​flatcar/​cse_install_flatcar.sh Remove EOF marker and adjacent blank line.
parts/​linux/​cloud-init/​artifacts/​flatcar/​cse_helpers_flatcar.sh Remove EOF marker and adjacent blank line.
parts/​linux/​cloud-init/​artifacts/​cse_main.sh Remove bare comment separators.
parts/​linux/​cloud-init/​artifacts/​cse_install.sh Move parameter-expansion comments; remove EOF marker.
parts/​linux/​cloud-init/​artifacts/​cse_helpers.sh Move regex source comment; remove separators.
parts/​linux/​cloud-init/​artifacts/​cse_config.sh Remove EOF marker and adjacent blank line.
parts/​linux/​cloud-init/​artifacts/​cse_config_network.sh Remove EOF marker and adjacent blank line.
parts/​linux/​cloud-init/​artifacts/​cse_config_localdns.sh Remove EOF marker and adjacent blank line.
parts/​linux/​cloud-init/​artifacts/​cse_config_kubelet.sh Remove heredoc comment separators and EOF marker.
parts/​linux/​cloud-init/​artifacts/​cse_config_gpu.sh Remove comment separator and EOF marker.
parts/​linux/​cloud-init/​artifacts/​cse_config_chrony.sh Remove a configuration comment separator.
parts/​linux/​cloud-init/​artifacts/​cse_config_addons.sh Remove EOF marker and adjacent blank line.
parts/​linux/​cloud-init/​artifacts/​block_wireserver.sh Match comment cleanup in the kubelet heredoc.
parts/​linux/​cloud-init/​artifacts/​azlosguard/​cse_install_osguard.sh Remove EOF marker and adjacent blank line.
parts/​linux/​cloud-init/​artifacts/​azlosguard/​cse_helpers_osguard.sh Remove EOF marker and adjacent blank line.
parts/​linux/​cloud-init/​artifacts/​acl/​cse_install_acl.sh Remove comment separators and EOF marker.
parts/​linux/​cloud-init/​artifacts/​acl/​cse_helpers_acl.sh Remove EOF marker and adjacent blank line.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
shellspec spec 28% ❌
Summary 28% (4591 / 16082) ❌

@awesomenix
Nishchay (awesomenix) merged commit 42c9f15 into main Oct 24, 2026
37 of 39 checks passed
@awesomenix
Nishchay (awesomenix) deleted the abigailliang/customdata-comment-cleanup branch October 24, 2026 03:23
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.

3 participants