Skip to content
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 reconcilation of resources #1937

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

Amulyam24
Copy link
Contributor

@Amulyam24 Amulyam24 commented Sep 2, 2024

What this PR does / why we need it:

This PR refactors the reconciliation of resources to follow a unit format as below

  1. Fetch ID from IBMPowerVSCluster status object. If ID exists, check the status of the resource in cloud and return
  2. If ID is not present in the status, try to fetch it from the IBMPowerVSCluster spec and check if the resource exists in cloud. Here we can check either via name or ID passed in the spec. If resource with given ID doesn't exist, return err, or else check the status of the resource in cloud and set IBMPowerVSCluster.status accordingly
  3. If resource with given name doesn't exist, proceed with creating the resource. If it exists, check the status of the resource in cloud. Set IBMPowerVSCluster.status accordingly in both cases

The changes in this PR has been tested with the following scenarios

  1. Resource names are set in spec and they do not exist
  2. Resource names are set in spec and they exist
  3. Resource IDs are set in spec and they do not exist
  4. Resource IDs are set in spec and they exist
  5. Spec with only required fields

Note:

  1. Adjustments were made to support if ID or Name are set in spec
  2. The changes in this PR were also tested with TG changes from existing PR Attach connections to existing transit gateway when its not there #1901
  3. Caveats noticed where in terms of handling existing DHCP server ID set in spec and it has been documented in Validate DHCP server status before reusing existing DHCP network #1933

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 #1907 #1726

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:

Refactor reconcilation of resources

@k8s-ci-robot k8s-ci-robot added the area/provider/ibmcloud Issues or PRs related to ibmcloud provider label Sep 2, 2024
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 2, 2024
Copy link

netlify bot commented Sep 2, 2024

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

Name Link
🔨 Latest commit ec8b9db
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-ibmcloud/deploys/6704fdbfca8fba0008a735d2
😎 Deploy Preview https://deploy-preview-1937--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.

@Amulyam24
Copy link
Contributor Author

/cc @Karthik-K-N

@Amulyam24
Copy link
Contributor Author

/cc @dharaneeshvrd

cloud/scope/powervs_cluster.go Show resolved Hide resolved
cloud/scope/powervs_cluster.go Outdated Show resolved Hide resolved
cloud/scope/powervs_cluster.go Show resolved Hide resolved
cloud/scope/powervs_cluster.go Outdated Show resolved Hide resolved
cloud/scope/powervs_cluster.go Show resolved Hide resolved
cloud/scope/powervs_cluster.go Outdated Show resolved Hide resolved
@Amulyam24 Amulyam24 force-pushed the reconcile_refactor branch 2 times, most recently from f91b98c to 77355f6 Compare September 3, 2024 07:47
cloud/scope/powervs_cluster.go Outdated Show resolved Hide resolved
cloud/scope/powervs_cluster.go Outdated Show resolved Hide resolved
cloud/scope/powervs_cluster.go Show resolved Hide resolved
cloud/scope/powervs_cluster.go Show resolved Hide resolved
controllers/ibmpowervscluster_controller.go Outdated Show resolved Hide resolved
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 lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 10, 2024
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 13, 2024
@Amulyam24
Copy link
Contributor Author

/hold

Testing the changes after rebase.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 13, 2024
api/v1beta2/ibmpowervscluster_webhook.go Outdated Show resolved Hide resolved
api/v1beta2/ibmpowervscluster_webhook.go Outdated Show resolved Hide resolved
cloud/scope/powervs_cluster.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 23, 2024
@Amulyam24 Amulyam24 force-pushed the reconcile_refactor branch 5 times, most recently from 0efc9f9 to 6b84b4d Compare September 24, 2024 10:01
@Amulyam24
Copy link
Contributor Author

/unhold

PR is ready for review, PTAL

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 24, 2024
Copy link
Contributor

@dharaneeshvrd dharaneeshvrd 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

cloud/scope/powervs_cluster.go Outdated Show resolved Hide resolved
cloud/scope/powervs_cluster.go Show resolved Hide resolved
@Amulyam24 Amulyam24 force-pushed the reconcile_refactor branch 2 times, most recently from 199af10 to 50f61e3 Compare September 25, 2024 05:27
controllers/ibmpowervscluster_controller.go Show resolved Hide resolved
cloud/scope/powervs_cluster.go Outdated Show resolved Hide resolved
cloud/scope/powervs_cluster_test.go Show resolved Hide resolved
cloud/scope/powervs_cluster_test.go Show resolved Hide resolved
cloud/scope/powervs_cluster_test.go Outdated Show resolved Hide resolved
@Amulyam24 Amulyam24 force-pushed the reconcile_refactor branch 2 times, most recently from 523596d to d469456 Compare October 3, 2024 13:16
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.

One suggestion , Otherwise LGTM

api/v1beta2/ibmpowervscluster_webhook.go Outdated Show resolved Hide resolved
api/v1beta2/ibmpowervscluster_webhook.go Show resolved Hide resolved
@Amulyam24
Copy link
Contributor Author

@Karthik-K-N, added a couple of minor changes. 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.

Thank you.
/lgtm

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

@mkumatag, PTAL!
The following/open UT PRs will require changes as per refactoring being added in this PR.

Copy link
Member

@mkumatag mkumatag left a comment

Choose a reason for hiding this comment

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

relying on @Karthik-K-N 's LGTM, thanks.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Amulyam24, 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 Oct 15, 2024
@k8s-ci-robot k8s-ci-robot merged commit 3edcccb into kubernetes-sigs:main Oct 15, 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor Power VS reconcile helpers for better readbility and better code grouping
5 participants