-
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 local routing in transit gateway when PowerVS and VPC are from same region #1777
Use local routing in transit gateway when PowerVS and VPC are from same region #1777
Conversation
✅ Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
c04c94f
to
a176099
Compare
@@ -251,6 +251,9 @@ type TransitGateway struct { | |||
// id of resource. | |||
// +optional | |||
ID *string `json:"id,omitempty"` | |||
// globalRouting indicates whether to set global routing true or not while creating the transit gateway. |
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.
Lets also mention a liner about global routing and local routing and when to use which.
Also what system will do when the field is omitted like as we mentioned in other api types. Lets keep as descriptive as possible.
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.
Done
cloud/scope/powervs_cluster.go
Outdated
return nil, fmt.Errorf("failed to use local routing for transit gateway since powervs and vpc region used requires global routing") | ||
} | ||
// setting global routing to true when it is set by user. | ||
if s.IBMPowerVSCluster.Spec.TransitGateway.GlobalRouting != nil && *s.IBMPowerVSCluster.Spec.TransitGateway.GlobalRouting && !*globalRouting { |
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 here we need not check whats globalRouting
, simply use Spec.TransitGateway.GlobalRouting
cloud/scope/powervs_cluster.go
Outdated
} | ||
region := endpoints.ConstructRegionFromZone(*zone) | ||
vpcRegion, err := genUtil.VPCRegionForPowerVSRegion(region) | ||
|
||
if s.IBMPowerVSCluster.Spec.VPC != nil { |
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 can use s.VPC()
cloud/scope/powervs_cluster.go
Outdated
// getTransitGatewayLocationAndRouting returns appropriate location and routing suitable for transit gateway. | ||
// routing indicates whether to enable global routing on transit gateway or not. | ||
// returns true when powervs and vpc region are not common otherwise false. | ||
func (s *PowerVSClusterScope) getTransitGatewayLocationAndRouting() (*string, *bool) { |
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 dont see any advantage of using pointer to bool , I think we can simply use bool instead.
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.
Anyway I need to make it a pointer in called func, so just made it here and used as it is.
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.
that makes sense.
cloud/scope/powervs_cluster.go
Outdated
vpcRegion, err := genUtil.VPCRegionForPowerVSRegion(region) | ||
|
||
if s.IBMPowerVSCluster.Spec.VPC != nil { | ||
routing := !genUtil.IsCommonPowerVSAndVPCRegion(region, *s.IBMPowerVSCluster.Spec.VPC.Region) |
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.
Isn't it confusing, can we simplify, Instead of negating the return value, Can we make this function to return localRouting instead of globalRouting?
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.
Refactored the func a bit, I would like to keep the var as globalRouting since we are going to assign it to CreateTransitGatewayOptions.Global
field.
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.
that makes sense.
a176099
to
fd798e1
Compare
@@ -251,6 +251,11 @@ type TransitGateway struct { | |||
// id of resource. | |||
// +optional | |||
ID *string `json:"id,omitempty"` | |||
// globalRouting indicates whether to set global routing true or not while creating the transit gateway. | |||
// set this flag to true only when PowerVS and VPC are from different regions, if they are same it's suggested to use local routing by setting the flag to false. |
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.
// set this flag to true only when PowerVS and VPC are from different regions, if they are same it's suggested to use local routing by setting the flag to false. | |
// set this field to true only when PowerVS and VPC are from different regions, if they are same it's suggested to use local routing by setting the field to false. |
@@ -251,6 +251,11 @@ type TransitGateway struct { | |||
// id of resource. | |||
// +optional | |||
ID *string `json:"id,omitempty"` | |||
// globalRouting indicates whether to set global routing true or not while creating the transit gateway. | |||
// set this flag to true only when PowerVS and VPC are from different regions, if they are same it's suggested to use local routing by setting the flag to false. | |||
// if this flag is not set, based on where PowerVS and VPC regions are from would decide whether to enable globalRouting or not. |
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.
// if this flag is not set, based on where PowerVS and VPC regions are from would decide whether to enable globalRouting or not. | |
// when the field is omitted, based on PowerVS region (region associated with IBMPowerVSCluster.Spec.Zone) and VPC region(IBMPowerVSCluster.Spec.VPC.Region) system will decide whether to enable globalRouting or not. |
fd798e1
to
ef2033a
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.
One suggestion otherwise LGTM
Thank you.
return nil, fmt.Errorf("failed to get transit gateway location") | ||
} | ||
|
||
// throw error when user tries to use local routing where global routing is required. |
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 can have this check in webhook as well, If required we can add a TODO.
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.
Yes, we need to have this in another PR, currently util is importing v1beta2 pkg, which is causing circular import issue when accessing the region map from util in Webhook, added a todo handle this later.
Moved the GetTransitGatewayLocationAndRouting() to util to consume from Webhook validation later.
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.
nice, Thanks
cloud/scope/powervs_cluster.go
Outdated
if s.VPC() != nil { | ||
routing := genUtil.IsGlobalRoutingRequiredForTG(region, *s.IBMPowerVSCluster.Spec.VPC.Region) | ||
return s.IBMPowerVSCluster.Spec.VPC.Region, &routing | ||
} |
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.
if s.VPC() != nil { | |
routing := genUtil.IsGlobalRoutingRequiredForTG(region, *s.IBMPowerVSCluster.Spec.VPC.Region) | |
return s.IBMPowerVSCluster.Spec.VPC.Region, &routing | |
} | |
if vpc := s.VPC(); vpc != nil { | |
routing := genUtil.IsGlobalRoutingRequiredForTG(region, *vpc.Region) | |
return vpc.Region, &routing | |
} |
a2e596f
to
abc6f94
Compare
return nil, fmt.Errorf("failed to get transit gateway location") | ||
} | ||
|
||
// throw error when user tries to use local routing where global routing is required. |
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.
nice, Thanks
util/util.go
Outdated
} | ||
|
||
// returning routing as true since VPC region is not set and used PowerVS region to calculate the transit gateway location. | ||
return &location, ptr.To(true), nil |
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.
Just curious to know for setting true, This case may not occur as we have a webhook check for making sure the vpc region is set, but incase it occurs any how we are getting VPC region associated with PowerVS so can't we use local routing?
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.
thanks for pointing it out, its supposed to be local routing!😁
abc6f94
to
b561b94
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.
minor comment, otherwise LGTM
cloud/scope/powervs_cluster.go
Outdated
// throw error when user tries to use local routing where global routing is required. | ||
// TODO: Add a webhook validation for below condition. | ||
if s.IBMPowerVSCluster.Spec.TransitGateway.GlobalRouting != nil && !*s.IBMPowerVSCluster.Spec.TransitGateway.GlobalRouting && *globalRouting { | ||
return nil, fmt.Errorf("failed to use local routing for transit gateway since powervs and vpc region used requires global routing") |
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.
return nil, fmt.Errorf("failed to use local routing for transit gateway since powervs and vpc region used requires global routing") | |
return nil, fmt.Errorf("failed to use local routing for transit gateway since powervs and vpc are in different region and requires global routing") |
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.
Fixed it. PTAL now!
b561b94
to
99c0c62
Compare
cloud/scope/powervs_cluster.go
Outdated
// throw error when user tries to use local routing where global routing is required. | ||
// TODO: Add a webhook validation for below condition. | ||
if s.IBMPowerVSCluster.Spec.TransitGateway.GlobalRouting != nil && !*s.IBMPowerVSCluster.Spec.TransitGateway.GlobalRouting && *globalRouting { | ||
return nil, fmt.Errorf("ailed to use local routing for transit gateway since powervs and vpc are in different region and requires global routing") |
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.
there is a typo!
return nil, fmt.Errorf("ailed to use local routing for transit gateway since powervs and vpc are in different region and requires global routing") | |
return nil, fmt.Errorf("failed to use local routing for transit gateway since powervs and vpc are in different region and requires global routing") |
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.
Fixed it.
99c0c62
to
c0ec9d7
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dharaneeshvrd, mkumatag 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 |
What this PR does / why we need it:
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 #1763
Special notes for your reviewer:
/area provider/ibmcloud
Release note: