-
Notifications
You must be signed in to change notification settings - Fork 442
fix: don't create outbound LB if using NatGateway #1589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: don't create outbound LB if using NatGateway #1589
Conversation
@jackfrancis looks like unit tests are failing, PTAL |
@@ -118,12 +122,26 @@ func (s *Service) getExisting(ctx context.Context, spec azure.NatGatewaySpec) (* | |||
if err != nil { | |||
return nil, err | |||
} | |||
// We must have a non-nil PublicIPAddresses, and the underlying SubResource slice type must have a length of 1 | |||
// TODO do we want to eventually handle NatGateway resources w/ more than one public IP address? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eventually there might be use cases for having more than 1 IP (eg. if you need more than 64k connections) but currently, it's not supported. We should not aim to support it now but making it explicit is better than opening the door for future bugs IMO.
If there is more than one IP, is the right behavior to return an error and completely block reconciliation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defer to project maintainers. We could leave this here until that support is actually added (as a very obvious reminder that there are implementation details to be sorted out) or it could passively accept a bunch of IP addresses and then always just use the first one (see L130 below).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this error condition is new, I'll remove the novel "length must equal 1" condition and leave the comment that acknowledges that we're simply throwing away all IPs except the first one (index 0) if there are > 1.
1f1ff9a
to
8751579
Compare
8751579
to
a05b9fc
Compare
}, | ||
}, | ||
{ | ||
name: "NodeOutboundLB declared as input with non-respected values", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CecileRobertMichon this is a weird case to test from a UX perspective but in fact it expresses literally what happens if you pass in a predefined LB object w/ either Name
, SKU
, or Type
values. So if we want to statically override those values we want this UT; or, if we don't want to do that now's the time to think about what we do want to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expected behavior, documented in https://capz.sigs.k8s.io/topics/node-outbound-lb.html#warning, is that these values are not configurable and modifying them should result in a validation error. It should not silently override the values. If that's what is happening right now then it's a bug. I think we should leave these values as is if already set and let the validation webhook do its job by failing if the values are not what we expect (validation should already be in place). This also applies to the control plane outbound LB.
This is a bit out of scope for this PR so feel free to open an issue if you don't want to address this as part of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what we're observing is that this condition (user-configurable value overrides of properties that aren't user-overridable) is artificial; as you say, validation will prevent this condition from ever reaching this point in the code flow. I vote that we just not add this artificial test case (I'll delete it).
0aadb6b
to
0f931de
Compare
/test pull-cluster-api-provider-azure-e2e |
}, | ||
}, | ||
{ | ||
name: "spec has empty CIDR and ID data", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CecileRobertMichon PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I understand what scenario this is testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also test that if CIDRBlocks and ID are empty in the existing spec, it will set them with the Azure subnet values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, sorry for the confusion
what I meant there was infrav1.SubnetSpec returned has no ID/CIDR when calling s.Subnet
and the Azure GET returns the values, which are used in s.SetSubnet
(which means we're updating the spec to have these values persisted in AzureCluster.Spec)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm pending comment on UT
b4e6926
to
a795ee3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/assign @shysank
/lgtm
|
I think the core issue is described in the issue: #1587 In summary, a Load Balancer created solely for providing outbound SNAT is unnecessary in a cluster configuration where a NAT Gateway is declared for doing just that. Hopefully that's clear. Certainly happy to clarify if it's not already. |
@jackfrancis can you please add details about the root cause that we observed after investigating? It's not obvious from reading the issue that the LB doesn't get created immediately and is due to the nat gateway being erased from the spec. We're also fixing another bug in this PR (IP ID comparison with IP name) which is missing from the description. /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CecileRobertMichon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold cancel |
/retest |
1 similar comment
/retest |
a795ee3
to
573f76b
Compare
/lgtm |
What type of PR is this?
/kind bug
What this PR does / why we need it:
This PR fixes the nat-gateway + subnet reconciliation logic so that we stop creating unnecessary outbound LB resources if we're exclusively using NatGateway across all of our node subnets.
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 #1587
Special notes for your reviewer:
Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.
TODOs:
Release note: