Skip to content

feat: add patch-only version matching for ANC hotfix download#8355

Merged
Devinwong merged 1 commit intomainfrom
devinwon/anc_hotfix_ab
Apr 24, 2026
Merged

feat: add patch-only version matching for ANC hotfix download#8355
Devinwong merged 1 commit intomainfrom
devinwon/anc_hotfix_ab

Conversation

@Devinwong
Copy link
Copy Markdown
Collaborator

@Devinwong Devinwong commented Apr 20, 2026

Summary

Replace the simple Version == hotfixVersion equality check in downloadHotfix with patch-only version matching using Masterminds/semver. The hotfix only targets the specific VHD it was built for — matching on the same YYYYMM.DD base with a strictly higher PATCH.

What changed

  • hotfix.go: Replace Version == hotfixVersion with shouldUpgradeToHotfix() using semver.NewVersion to parse and compare Major/Minor/Patch segments
  • hotfix_test.go: Add DifferentBaseSkips, DevVersionSkips, MatchingBaseUpgrades tests; update existing tests to use YYYYMM.DD.PATCH format
  • app_test.go: Update download-hotfix test to use YYYYMM.DD.PATCH format
  • go.mod: Promote Masterminds/semver/v3 from indirect to direct dependency

How patch-only matching works

shouldUpgradeToHotfix(current, hotfix) returns true only when:

  1. Both versions parse as valid semver
  2. Same Major (YYYYMM) and Minor (DD) — i.e., same VHD base
  3. Hotfix has strictly higher Patch

Examples:

  • 202604.01.0202604.01.1 ✅ upgrade (same base, higher patch)
  • 202603.15.0202604.01.1 ❌ skip (different base, older VHD)
  • 202605.01.0202604.01.1 ❌ skip (different base, newer VHD)
  • 202604.01.1202604.01.1 ❌ skip (already at hotfix)
  • dev202604.01.1 ❌ skip (parse error)

Why

The previous approach (Version == hotfixVersion) would skip the download if versions matched but had no protection against applying a hotfix to the wrong VHD. With patch-only matching:

  • Older VHDs (different base) are skipped — remediated via VHD republish
  • Newer VHDs (different base) are skipped — fix is already baked in
  • Only the specific affected VHD gets the hotfix

Dependencies

Built on top of #8397 (urfave/cli refactor + download-hotfix command).

Copilot AI review requested due to automatic review settings April 20, 2026 19:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new toggle-driven mechanism to pass an AKS Node Controller (ANC) hotfix version into Linux cloud-init, so nodes can self-update ANC to a specified version when a post-release hotfix is required.

Changes:

  • Extend the Toggles interface with GetANCHotfixVersion and plumb its value into NodeBootstrappingConfiguration.
  • Expose ANCHotfixVersion to the cloud-init template function map and emit a JSON config file via write_files when set.
  • Add unit tests to validate presence/absence of the hotfix config in rendered customData.

Reviewed changes

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

Show a summary per file
File Description
pkg/agent/toggles/types.go Adds a new toggle method GetANCHotfixVersion with a default no-op implementation.
pkg/agent/datamodel/types.go Introduces NodeBootstrappingConfiguration.ANCHotfixVersion with JSON serialization.
pkg/agent/bakerapi.go Resolves the ANC hotfix version from toggles prior to template rendering.
pkg/agent/baker.go Exposes ANCHotfixVersion to template rendering via GetANCHotfixVersion.
parts/linux/cloud-init/nodecustomdata.yml Conditionally writes /opt/azure/containers/aks-node-controller-hotfix.json when a hotfix version is set.
pkg/agent/bakerapi_test.go Adds tests and a helper to decode customData for validating the rendered cloud-init content.

Comment thread pkg/agent/bakerapi_test.go Outdated
Comment thread pkg/agent/bakerapi.go Outdated
Comment thread pkg/agent/bakerapi.go Outdated
Comment thread parts/linux/cloud-init/nodecustomdata.yml Outdated
Comment thread pkg/agent/bakerapi_test.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 3 comments.

Comment thread pkg/agent/bakerapi.go Outdated
Comment thread pkg/agent/bakerapi.go Outdated
Comment thread pkg/agent/bakerapi_test.go Outdated
Copilot AI review requested due to automatic review settings April 21, 2026 19:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated 4 comments.

Comment thread pkg/agent/bakerapi_test.go Outdated
Comment thread aks-node-controller/app.go Outdated
Comment thread pkg/agent/bakerapi.go Outdated
Comment thread pkg/agent/toggles/types.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated 6 comments.

Comment thread aks-node-controller/selfupdate_test.go Outdated
Comment thread pkg/agent/bakerapi_test.go Outdated
Comment thread aks-node-controller/selfupdate.go Outdated
Comment thread aks-node-controller/versioncmp.go Outdated
Comment thread aks-node-controller/versioncmp.go Outdated
Comment thread aks-node-controller/versioncmp.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 7 changed files in this pull request and generated 1 comment.

Comment thread parts/linux/cloud-init/artifacts/aks-node-controller-wrapper.sh Outdated
@Devinwong Devinwong changed the title feat: plumb ANC hotfix version from toggle to cloud-init feat: add patch-only version matching for ANC hotfix download Apr 24, 2026
@Devinwong Devinwong force-pushed the devinwon/anc_hotfix_ab branch from 6968fac to 91d53d5 Compare April 24, 2026 21:25
Copilot AI review requested due to automatic review settings April 24, 2026 21:31
@Devinwong Devinwong force-pushed the devinwon/anc_hotfix_ab branch from 91d53d5 to 5cd47e6 Compare April 24, 2026 21:31
@Devinwong Devinwong force-pushed the devinwon/anc_hotfix_ab branch from 5cd47e6 to befa61c Compare April 24, 2026 21:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread parts/linux/cloud-init/artifacts/aks-node-controller-wrapper.sh Outdated
Comment thread aks-node-controller/hotfix.go
Comment thread aks-node-controller/hotfix_test.go Outdated
Replace simple Version == hotfixVersion check in downloadHotfix with
shouldUpgradeToHotfix using Masterminds/semver: only upgrade when same
YYYYMM.DD base and hotfix has strictly higher PATCH. Parse errors
(e.g. 'dev' builds) skip.

- Add versioncmp.go with shouldUpgradeToHotfix (uses semver.NewVersion)
- Add versioncmp_test.go with 18 upgrade test cases
- Update hotfix_test.go with patch-version test data and new tests:
  DifferentBaseSkips, DevVersionSkips, MatchingBaseUpgrades
- Update app_test.go to use YYYYMM.DD.PATCH format
- Promote Masterminds/semver/v3 from indirect to direct dependency

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread aks-node-controller/hotfix.go
@Devinwong
Copy link
Copy Markdown
Collaborator Author

aclarm64tlgen2 build failed likely because of current eastus2 outage. Also seen in other pipelines. Will skip this build and merge.

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.

4 participants