Repository navigation
fix: extract LoadBalancer IP from Status.LoadBalancer.Ingress - #9
Merged
Merged
Conversation
Modern LoadBalancer controllers (Cilium, MetalLB, cloud providers) populate the assigned IP in Status.LoadBalancer.Ingress rather than Spec.LoadBalancerIP (which is deprecated). This fix updates ipFromService() to: 1. First check Status.LoadBalancer.Ingress[].IP (modern approach) 2. Fall back to Spec.LoadBalancerIP (legacy/deprecated) 3. Handle empty ExternalIPs gracefully Without this fix, services with LoadBalancer IPs assigned via Status would result in empty IP values, causing port forwarding creation to fail with "invalid response code 400" due to invalid fwd field. Adds tests for: - LoadBalancer with only Status IP (no Spec.LoadBalancerIP) - LoadBalancer with both Status and Spec IP (Status takes precedence)
Re-fetch Service object before updating Status to get the latest resourceVersion, avoiding optimistic locking conflicts when the controller has already added a finalizer during reconciliation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Status.LoadBalancer.Ingress[].IPinstead ofSpec.LoadBalancerIPProblem
Services with LoadBalancer IPs assigned via Status result in empty IP values, causing port forwarding creation to fail with:
The log shows
"ip":""becauseipFromService()only checkedSpec.LoadBalancerIP.Solution
Update
ipFromService()to:Status.LoadBalancer.Ingress[].IP(modern approach)Spec.LoadBalancerIP(legacy/deprecated)ExternalIPsgracefullyTest plan
make test)Closes #7 (related to UDM support - the 400 errors occurred after UDM auth was fixed)