-
Notifications
You must be signed in to change notification settings - Fork 84
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
Use multiple zones in case of multiple subnets #1793
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Shilpa-Gokul The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @Shilpa-Gokul. 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 Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
✅ Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
How about handling this in webhooks, Having a default webhook which adds unique zone to subnets if it does not present.
Also I think we can error out if the user specifies more subnets than zone.
@dharaneeshvrd will there be any uses cases of user setting more subnets? like vpc region has 2 zones but user wants to create 4 subnets?
its possible, we can just round robin the zones once subnets created for all zones. |
ed9c04c
to
666b32f
Compare
666b32f
to
b56cac6
Compare
b56cac6
to
2d53312
Compare
0cdecca
to
8fac823
Compare
8fac823
to
292d3fa
Compare
42195bc
to
836bbc9
Compare
Tested the following scenarios Case 1: When user provides more subnets than the available vpczones and provides no zone information with each subnet (subnets are created in the available vpc zones in a round robin method)
Case 2: When user provides 2 subnets in the same zone to be created
Case 3: User provides 1 subnet and the zone to be created in
Case 4: When user provides already created subnet
Log- [manager] I0723 12:15:38.121366 1 powervs_cluster.go:1103] "VPC subnet ID is set, fetching details" controller="ibmpowervscluster" controllerGroup="infrastructure.cluster.x-k8s.io" controllerKind="IBMPowerVSCluster" IBMPowerVSCluster="default/capi-test-cluster-sg" namespace="default" name="capi-test-cluster-sg" reconcileID="19a61637-59a3-4ea0-896f-6bb3a4616902" cluster="default/capi-test-cluster-sg" id="02w7-e123549e-4414-480c-b018-7017492889b3" Case 5: When user provides subnets with no zone information
@Karthik-K-N @Amulyam24 Please check this and let me know if I have to test anything else |
5229869
to
0e9a02c
Compare
Thanks for the detailed explaination, For usecase1 can we use webhooks to validate? |
Added the validation in the webhook itself, below is the error response
|
bd249cc
to
c17611e
Compare
@Karthik-K-N @Prajyot-Parab Addressed all changes suggested, could you please review this PR? Also the checks are in pending state for so many days, retesting is also not working. could you please help on that as well? |
/ok-to-test |
9b870ce
to
76b57c8
Compare
76b57c8
to
d1a773e
Compare
d1a773e
to
ec9c2de
Compare
LGTM |
@Shilpa-Gokul what happens with this case? |
// vpcSubnetIPAddressCount is the total IP Addresses for the subnet. Until support for custom | ||
// address prefixes is added, we use the ip count for subnet creation. |
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.
// vpcSubnetIPAddressCount is the total IP Addresses for the subnet. Until support for custom | |
// address prefixes is added, we use the ip count for subnet creation. | |
// vpcSubnetIPAddressCount is the total IP Addresses for the subnet. | |
// Support for custom address prefixes will be added at a later time. Currently, we use the ip count for subnet creation. |
|
||
// create subnet | ||
vpcID := s.GetVPCID() | ||
if vpcID == nil { | ||
return nil, fmt.Errorf("VPC ID is empty") | ||
} | ||
cidrBlock, err := s.IBMVPCClient.GetSubnetAddrPrefix(*vpcID, zone) |
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.
You also need to remove the function definitions as well, if they are not being used anywhere else.
@@ -1172,7 +1181,10 @@ func (s *PowerVSClusterScope) ReconcileVPCSubnets() (bool, error) { | |||
} | |||
s.Info("Created VPC subnet", "subnetID", subnetID) | |||
s.SetVPCSubnetStatus(*subnet.Name, infrav1beta2.ResourceReference{ID: subnetID, ControllerCreated: ptr.To(true)}) | |||
return true, nil | |||
// Requeue only when all subnets' creation are triggered |
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.
// Requeue only when all subnets' creation are triggered | |
// Requeue only when the creation of all subnets has been triggered. |
What this PR does / why we need it:
Currently when there are multiple subnets specified, it uses the first available vpcZone for all subnets by default and as a result, there is a clash in the CIDR. Hence added logic to use the subsequent vpcZones for the subnets.
If there are multiple subnets provided than the available vpcZones (ex: when 4 subnets are provided but only 3 vpcZones are available in the region), in this case we return error as below
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 #1779
Special notes for your reviewer:
/area provider/ibmcloud
Release note: