Skip to content

fix: allow updating a MultiClusterIngress that already carries an invalid load balancer IP - #7812

Open
karpovantonme wants to merge 1 commit into
karmada-io:masterfrom
karpovantonme:fix/mci-status-update-existing-ip
Open

fix: allow updating a MultiClusterIngress that already carries an invalid load balancer IP#7812
karpovantonme wants to merge 1 commit into
karmada-io:masterfrom
karpovantonme:fix/mci-status-update-existing-ip

Conversation

@karpovantonme

Copy link
Copy Markdown

What type of PR is this?

/kind bug

What this PR does / why we need it:

A MultiClusterIngress whose status already holds an address that fails IP validation cannot be updated any more. The validating webhook rejects every update, including one that would fix the object. It is stuck.

The status is not written by Karmada. aggregateIngressStatus collects it from member clusters:

newStatus.LoadBalancer.Ingress = append(newStatus.LoadBalancer.Ingress, temp.LoadBalancer.Ingress...)

Whatever the ingress controller in a member cluster wrote ends up here, and nothing validates it on the way in. So an address our parser rejects can land in the status without anyone doing something wrong.

Then validateMCIUpdate has the old object in hand but does not pass it down:

func validateMCIUpdate(oldMci, newMci *networkingv1alpha1.MultiClusterIngress) field.ErrorList {
	...
	allErrs = append(allErrs, lifted.ValidateIngressLoadBalancerStatus(&newMci.Status.LoadBalancer, field.NewPath("status", "loadBalancer"))...)

so the same address is re-validated on every update and the update is denied.

Upstream ran into this and fixed it in kubernetes@ad22c0d4, "Fix IP/CIDR validation to allow updates to existing invalid objects", by taking oldStatus and tolerating addresses already present in it. The lifted copy here comes from release-1.27 and predates that commit, so the fix never reached us.

hack/verify-lifted.sh does not catch this. It only checks that doc.go matches the annotations; it does not compare a lifted copy against upstream.

Which issue(s) this PR fixes:

None filed. Happy to open one first if you would rather discuss it there.

Special notes for your reviewer:

The change follows upstream rather than inventing anything: ValidateIngressLoadBalancerStatus now takes oldStatus, and an address carried over from it is left alone. A freshly introduced invalid address is still rejected, so this does not weaken validation for new objects.

Verification:

  • TestValidateIngressLoadBalancerStatusToleratesExistingIP fails without the change and passes with it
  • go test ./pkg/util/lifted/ ./pkg/webhook/multiclusteringress/ - ok
  • hack/verify-lifted.sh - up to date, doc.go regenerated with hack/update-lifted.sh, which flipped the entry to changed=Y
  • hack/verify-gofmt.sh - clean

Two more lifted copies look like they also missed upstream fixes. I did not touch them, since each needs its own reading of how Karmada uses the code, and one of the two turned out not to apply once I read the caller:

  • SetFeatureGateDuringTest in visitpod_test.go returns a restore function for defer, upstream moved to tb.Cleanup in 9fcf279e because a parallel subtest can outlive the parent test. Test helper, lower stakes.
  • GetDeletableResources in discovery.go swallows the discovery error, and upstream made it return one in c9a084d5. I checked the caller in pkg/detector/detector.go and it does not need the error: it only adds informers for resources it has not seen yet, so a partial list is picked up on the next tick. Mentioning it so nobody re-derives that.

Say the word if you want the first one done too.

Fixed an issue where a `MultiClusterIngress` whose status already contained an invalid load balancer IP could not be updated.

…alid load balancer IP

The validating webhook rejects any update to a MultiClusterIngress whose
status already holds an address that fails IP validation, so such an
object can never be changed again, not even to fix it.

The status is not written by Karmada. aggregateIngressStatus collects it
from member clusters, where the ingress controller writes whatever it
writes, and nothing validates it on the way in. Once an address that our
parser rejects lands there, the object is stuck.

Upstream hit the same problem and fixed it in kubernetes@ad22c0d4, "Fix
IP/CIDR validation to allow updates to existing invalid objects", by
passing the old status in and tolerating addresses that are already
present. The lifted copy predates that commit.

This applies the same approach: ValidateIngressLoadBalancerStatus now
takes oldStatus, and an address carried over from it is left alone. A
fresh invalid address is still rejected.

The regression test fails without the change and passes with it.
doc.go regenerated with hack/update-lifted.sh, which flipped the entry to
changed=Y.

Signed-off-by: Anton Karpov <karpovantonme@gmail.com>
Copilot AI lite review requested due to automatic review settings August 4, 2026 03:51
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@karmada-bot karmada-bot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 4, 2026
@karmada-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign xishanyongye-chang for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@karmada-bot

Copy link
Copy Markdown
Contributor

Welcome @karpovantonme! It looks like this is your first PR to karmada-io/karmada 🎉

@karmada-bot karmada-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 4, 2026

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.

🟢 Ready to approve

The change is narrowly scoped, aligns with upstream behavior, updates all call sites, and includes targeted unit coverage for the regression scenario.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR fixes a validating-webhook edge case where a MultiClusterIngress update could be permanently blocked if its existing status.loadBalancer already contained an IP string that fails validation (e.g., written by a member-cluster ingress controller and aggregated into Karmada).

Changes:

  • Update lifted ValidateIngressLoadBalancerStatus to accept oldStatus and skip IP validation for IPs already present in the old status.
  • Wire the webhook update path to pass the old load balancer status into the validator.
  • Add a unit test covering tolerance of an existing invalid IP and update lifted metadata to reflect the divergence.
File summaries
File Description
pkg/webhook/multiclusteringress/validating.go Passes old load balancer status to the lifted validator during update admission.
pkg/util/lifted/validatingmci.go Extends the lifted validator to tolerate IPs already present in oldStatus.
pkg/util/lifted/validatingmci_test.go Adds/adjusts tests for the new validator signature and the “tolerate existing invalid IP” behavior.
pkg/util/lifted/doc.go Marks the lifted function as changed (Y) to match the updated lifted annotations.
Review details

Files not reviewed (1)

  • pkg/util/lifted/doc.go: Generated file
  • Files reviewed: 3/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.10%. Comparing base (a5cf21e) to head (32a6eb0).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7812   +/-   ##
=======================================
  Coverage   42.10%   42.10%           
=======================================
  Files         879      879           
  Lines       54857    54862    +5     
=======================================
+ Hits        23095    23099    +4     
- Misses      30019    30020    +1     
  Partials     1743     1743           
Flag Coverage Δ
unittests 42.10% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@zhzhuang-zju

Copy link
Copy Markdown
Contributor

/ok-to-test
/retest

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

Labels

kind/bug Categorizes issue or PR as related to a bug. ok-to-test size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants