Skip to content

fix: validate API server LB private IP is unchanged on update#6389

Open
dee077 wants to merge 2 commits into
kubernetes-sigs:mainfrom
dee077:fix/5314-disallow-private-ip-update
Open

fix: validate API server LB private IP is unchanged on update#6389
dee077 wants to merge 2 commits into
kubernetes-sigs:mainfrom
dee077:fix/5314-disallow-private-ip-update

Conversation

@dee077

@dee077 dee077 commented Jun 22, 2026

Copy link
Copy Markdown

What type of PR is this?
/kind bug

What this PR does / why we need it:

  • Fixes a bug where the API server load balancer private IP can be changed after AzureCluster creation when APIServerILB is enabled and the LB type is Public
  • Previously, the validation only ran for Internal type LBs, leaving the Public + APIServerILB path unguarded
  • Adds a function validateAPIServerLBPrivateIPUnchanged and uses it for both Internal and Public + APIServerILB paths, deduplicating the validation logic
  • Fixes the error field path for the Internal LB immutability check from apiServerLB.name to apiServerLB.frontendIPConfigs[0].privateIP

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #5314

Special notes for your reviewer:

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests
  • cherry-pick candidate

Release note:

fix: validate API server LB private IP is unchanged on update for Public and APIServerILB configuration

@kubernetes-prow kubernetes-prow Bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 22, 2026
@kubernetes-prow kubernetes-prow Bot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 22, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 22, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: dee077 / name: dee077 (944f04c)

@kubernetes-prow kubernetes-prow Bot requested review from bryan-cox and marosset June 22, 2026 14:07
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @dee077!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-azure 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-azure has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow kubernetes-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 22, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Hi @dee077. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubernetes-prow kubernetes-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jun 22, 2026
@bryan-cox

Copy link
Copy Markdown
Contributor

/ok-to-test

@kubernetes-prow kubernetes-prow Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 22, 2026

@bryan-cox bryan-cox 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.

Thanks for the contribution @dee077! Overall this is a solid bug fix — the core logic is correct, the deduplication via validateAPIServerLBPrivateIPUnchanged is well-motivated, and the corrected field path is a nice improvement over the original apiServerLB.name. A few items below to consider.

Comment thread internal/webhooks/azurecluster_validation.go Outdated
Comment thread internal/webhooks/azurecluster_validation.go
Comment thread internal/webhooks/azurecluster_validation_test.go
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 44.08%. Comparing base (47cc48d) to head (944f04c).

Files with missing lines Patch % Lines
internal/webhooks/azurecluster_validation.go 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6389      +/-   ##
==========================================
+ Coverage   44.06%   44.08%   +0.02%     
==========================================
  Files         289      289              
  Lines       25383    25392       +9     
==========================================
+ Hits        11185    11195      +10     
  Misses      13422    13422              
+ Partials      776      775       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dee077 dee077 force-pushed the fix/5314-disallow-private-ip-update branch from 944f04c to eae50c4 Compare June 22, 2026 15:35
@dee077 dee077 requested a review from bryan-cox June 22, 2026 16:21

@bryan-cox bryan-cox 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.

/lgtm

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 22, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: fed77635399a776d0a2188fed9c36dcddff7a59a

Comment thread internal/webhooks/azurecluster_validation.go Outdated
@github-project-automation github-project-automation Bot moved this from Todo to Wait-On-Author in CAPZ Planning Jun 23, 2026
@kubernetes-prow kubernetes-prow Bot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 23, 2026
@kubernetes-prow kubernetes-prow Bot requested a review from bryan-cox June 23, 2026 19:48
@kubernetes-prow

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@dee077 dee077 requested a review from willie-yao June 23, 2026 19:52

@willie-yao willie-yao 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.

/approve

@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: willie-yao

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 23, 2026
@willie-yao

Copy link
Copy Markdown
Contributor

/retest

1 similar comment
@willie-yao

Copy link
Copy Markdown
Contributor

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: Wait-On-Author

Development

Successfully merging this pull request may close these issues.

Disallow update of private IP after the creation of AzureCluster

3 participants