Skip to content

fix: deduplicate existing scriptless hotfix entries - #9840

Open
Devinwong wants to merge 1 commit into
mainfrom
devinwong-deduplicate-hotfix-script-entries
Open

Devinwong wants to merge 1 commit into
mainfrom
devinwong-deduplicate-hotfix-script-entries

Conversation

@Devinwong

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:

Prevent hotfix generation from injecting a write_files block already supplied by the handwritten scriptless branch, such as the conditional init-aks-cloud.sh entry. Compare complete canonical blocks, including guards and content, rather than paths or variable keys alone. Regeneration also removes stale auto-generated duplicates while preserving distinct hotfix entries and the mutually exclusive traditional branch.

Add regression coverage for stale-duplicate cleanup, mixed selections, repeat-run idempotence, no-hotfix cleanup, and differently guarded or defined entries. Embedded payload eligibility and empty-output handling are unchanged.

Validation:

  • python -X utf8 -m unittest hotfix.hotfix_generate_test — passed all 28 tests.
  • python -B -X utf8 -m unittest hotfix.hotfix_generate_test — passed after committing.
  • git diff --check — passed.
  • python -X utf8 C:\Users\devinwon\.copilot\session-state\9f611d25-fb17-4857-86d5-ae9f0746edad\files\verify_hotfix_dedup.py — passed 16 production-renderer/YAML cases using a local, uncommitted verification harness: Ubuntu/Azure Linux, scriptless/traditional CSE, public/custom clouds, before/after regeneration. Reproduced duplicate eligible init entries before regeneration and verified exactly one afterward, with distinct helper entries retained.

No live VM test was run; this change only affects template generation.

Which issue(s) this PR fixes:

N/A

Compare complete canonical write_files blocks before hotfix injection and remove stale generated duplicates without changing distinct entries.

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

Copilot-Session: 9f611d25-fb17-4857-86d5-ae9f0746edad
@Devinwong
Devinwong requested review from a team as code owners October 20, 2026 23:16
Copilot AI balanced review requested due to automatic review settings October 20, 2026 23:16
@github-actions

Copy link
Copy Markdown
Contributor

Windows Unit Test Results

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

Results for commit 76b6bd7.

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
parts_windows Package 1 73% ➖
staging_cse_windows Package 1 65% ➖
debug 0% ❌
provisioningscripts 2% ❌
test 0% ❌
windows 27% ❌
Summary 38% (1652 / 6834) ❌

@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 78% ➖
github.com/Azure/agentbaker/pkg/agent/toggles 0% ❌
github.com/Azure/agentbaker/pkg/vhdbuilder/datamodel 87% ✔
Summary 74% (5660 / 7595) ➖

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
shellspec spec 28% ❌
Summary 28% (4507 / 15936) ❌

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 test assumes a marker-free repository template, causing subsequent hotfix workflow runs to fail when generated entries already exist.

1 open issue
What changed in this PR

Prevents duplicate hotfix entries in AgentBaker’s scriptless cloud-init template.

Changes:

  • Filters generated entries against complete existing blocks, preserving distinct guards and content.
  • Adds regression coverage for cleanup, mixed selections, and repeat-run idempotence.
File Description
hotfix/​hotfix_generate.py Skips blocks already supplied by the scriptless branch.
hotfix/​hotfix_generate_test.py Tests deduplication and preservation of distinct entries.

Review effort: Balanced


def test_update_nodecustomdata_deduplicates_existing_scriptless_block(self):
repository = Path(__file__).resolve().parents[1]
original = (repository / hotfix_generate.TEMPLATE).read_text()

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