Skip to content

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

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

dharaneeshvrd
Copy link
Contributor

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

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:


@k8s-ci-robot k8s-ci-robot added area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 12, 2024
Copy link

netlify bot commented Sep 12, 2024

Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready!

Name Link
🔨 Latest commit 89a7c50
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-ibmcloud/deploys/66e3e57a7c8ed60008bf11a1
😎 Deploy Preview https://deploy-preview-1961--kubernetes-sigs-cluster-api-ibmcloud.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 12, 2024
Copy link
Contributor

@Karthik-K-N Karthik-K-N left a 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.

switch networkType {
case powervsNetworkConnectionType:
if s.IBMPowerVSCluster.Status.TransitGateway.PowerVSConnection != nil {
s.IBMPowerVSCluster.Status.TransitGateway.PowerVSConnection.ControllerCreated = resource.ControllerCreated
Copy link
Contributor

@Karthik-K-N Karthik-K-N Sep 13, 2024

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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.

Copy link
Contributor Author

@dharaneeshvrd dharaneeshvrd Sep 13, 2024

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.

@dharaneeshvrd dharaneeshvrd force-pushed the tg-connections branch 2 times, most recently from cff4218 to a9a9756 Compare September 13, 2024 05:54
Copy link
Contributor

@Amulyam24 Amulyam24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM!

@@ -1886,53 +1847,55 @@ func (s *PowerVSClusterScope) checkTransitGatewayConnectionStatus(con tgapiv1.Tr
}

// createTransitGatewayConnection creates transit gateway connection.
Copy link
Contributor

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?

}

return powerVSConn.ID, vpcConn.ID, nil
return nil
}

// createTransitGateway create transit gateway.
Copy link
Contributor

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?

@dharaneeshvrd
Copy link
Contributor Author

Addressed the comments @Amulyam24 ptal!

Copy link
Contributor

@Karthik-K-N Karthik-K-N left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 13, 2024
@Amulyam24
Copy link
Contributor

LGTM!

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 13, 2024
@k8s-ci-robot k8s-ci-robot merged commit c6bcd31 into kubernetes-sigs:main Sep 13, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants