-
Notifications
You must be signed in to change notification settings - Fork 89
Refactor transit gateway status #1961
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
Refactor transit gateway status #1961
Conversation
✅ 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.
Overall approach LGTM and its simplified complex TG workflow, Couple of questions/doubts.
cloud/scope/powervs_cluster.go
Outdated
switch networkType { | ||
case powervsNetworkConnectionType: | ||
if s.IBMPowerVSCluster.Status.TransitGateway.PowerVSConnection != nil { | ||
s.IBMPowerVSCluster.Status.TransitGateway.PowerVSConnection.ControllerCreated = resource.ControllerCreated |
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 do we need to assign seperatly , why can't we assign directly as like in else case?
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.
Agree, removed these nil check and directly assigned, ptal!
if err != nil { | ||
return false, err | ||
} | ||
s.SetTransitGatewayStatus(tg.ID, ptr.To(false), powerVSConn, vpcConn) |
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.
Instead of moving this to isTransitGatewayExists() can we just move it couple of lines above just after checking tg!=nil? and then proceed towards checking connection/creating connections.
Like most of other functions, it would be good if we keep SetStatus mostly under ReconcileResource function
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.
Also how about calling checking TG status and later checking TG connections separately from here, Rather than embedding both inside checkAndUpdateTransitGateway?
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.
But while creating I am setting(need to) the status immediately after create call in s.createTransitGateway(), so I feel its ok to keep inside isTransitGatewayExists() because that func meant to process the existing resource, so when we set controllercreated to false, it would be good if we keep it inside that func.
Rather than embedding both inside checkAndUpdateTransitGateway?
Then the main Reconcile would be too long if I add these three calls and check the error, it's better to keep them in this func IMO.
return transitGateway, nil | ||
} | ||
|
||
// checkAndUpdateTransitGateway checks given transit gateway's status and its connections. | ||
// if update is set to true, it updates the transit gateway connections too if it is not exist already. | ||
func (s *PowerVSClusterScope) checkAndUpdateTransitGateway(transitGateway *tgapiv1.TransitGateway, update bool) (bool, *infrav1beta2.ResourceReference, *infrav1beta2.ResourceReference, error) { | ||
func (s *PowerVSClusterScope) checkAndUpdateTransitGateway(transitGateway *tgapiv1.TransitGateway) (bool, error) { | ||
requeue, err := s.checkTransitGatewayStatus(transitGateway) |
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 a thought, I feel checkTransitGatewayStatus() is getting confused for checking Status of TG from IBMPowerVSCluster resource.
checkTransitGatewayStatus() is actually checking status of TG in cloud, Can we rename the function if possibel or if you thinks its better.
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 seems whenever we are checking the cloud we are following this format check<something>
and when we query from cluster status we are using Get<something>
, I think it's ok.
cff4218
to
a9a9756
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.
Overall LGTM!
cloud/scope/powervs_cluster.go
Outdated
@@ -1886,53 +1847,55 @@ func (s *PowerVSClusterScope) checkTransitGatewayConnectionStatus(con tgapiv1.Tr | |||
} | |||
|
|||
// createTransitGatewayConnection creates transit gateway connection. |
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.
can we elaborate the description accordingly as we are also setting the status?
cloud/scope/powervs_cluster.go
Outdated
} | ||
|
||
return powerVSConn.ID, vpcConn.ID, nil | ||
return nil | ||
} | ||
|
||
// createTransitGateway create 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.
can we elaborate the description accordingly to specify about setting the status?
a9a9756
to
89a7c50
Compare
Addressed the comments @Amulyam24 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.
/lgtm
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:
#1960
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 #
Special notes for your reviewer:
/area provider/ibmcloud
Release note: