-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Enhance subnet discovery #4109
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
Enhance subnet discovery #4109
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: M00nF1sh 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 |
0bb20f7
to
598e0e6
Compare
3bff4f6
to
1140a0d
Compare
1140a0d
to
707ad82
Compare
707ad82
to
2f6ce5c
Compare
pkg/networking/subnet_resolver.go
Outdated
// - The subnet has a Kubernetes cluster tag matching the current cluster | ||
clusterTagCheckEnabled bool | ||
// whether to enable a single subnet as ALB subnet | ||
// by default ALB requires two subent, only whitelisted users can use a single subnet |
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.
nit whitelisted -> allowlisted
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.
changed
pkg/networking/subnet_resolver.go
Outdated
req := &ec2sdk.DescribeSubnetsInput{ | ||
Filters: []ec2types.Filter{ | ||
{ | ||
Name: awssdk.String("vpc-id"), |
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.
nit: you re-define this query names multiple times. maybe use a constant?
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.
changed
if err != nil { | ||
return nil, err | ||
} | ||
resolvedSubnets = append(resolvedSubnets, subnets...) | ||
} | ||
if len(resolvedSubnets) != len(subnetNameOrIDs) { |
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.
Why did you remove this check? in the other function that queries for subnets by ID, you actually added this exact check.
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.
oh, it's due to i moved this check into the listSubnetsByIDs and listSubnetsByNames
The length must equal when listSubnetsByIDs and listSubnetsByNames didn't return error
chosenSubnets = append(chosenSubnets, subnets[0]) | ||
} | ||
} | ||
sortSubnetsByID(chosenSubnets) |
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.
Doesn't this sort mess up the EIP allocation feature? #3925
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.
it doesn't
This sort only triggers for "Discovery" via tag selector or role tag or reachability.
When subnet explicitly specified, no sort will occur
/lgtm |
/lgtm |
fix bug(introduced by #4109) in subnet resolver
This PR refactor and enhances the subnet discovery module as follows
Added a fallback mechanism to find subnets in VPC based on reachability(public/subnet) that matches ELB's requirement.
ec2:DescribeRouteTables
) to work.SubnetDiscoveryByReachability
feature flag. We have enabled this featureFlag by default. It shall have no impact to customers since this fallback only invokes when no subnets with role tag found. (even cx forgets to add the new IAM permission during upgrade, subnet discovery will work just as before)Refactor the subnetResolver to be more clear and have consistent behavior in multiple scenarios.
Rendered doc:

Issue
Description
Checklist
README.md
, or thedocs
directory)BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯