cluster-api-provider-ibmcloud icon indicating copy to clipboard operation
cluster-api-provider-ibmcloud copied to clipboard

Refactor reconcilation of resources

Open Amulyam24 opened this issue 1 year ago • 4 comments

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 https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/pull/1901
  3. Caveats noticed where in terms of handling existing DHCP server ID set in spec and it has been documented in https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/issues/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

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

Amulyam24 avatar Sep 02 '24 10:09 Amulyam24

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

Name Link
Latest commit ec8b9dbd0c37488521e4b2052148f0e5dd982b42
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.

netlify[bot] avatar Sep 02 '24 10:09 netlify[bot]

/cc @Karthik-K-N

Amulyam24 avatar Sep 02 '24 10:09 Amulyam24

/cc @dharaneeshvrd

Amulyam24 avatar Sep 03 '24 05:09 Amulyam24

/hold

Testing the changes after rebase.

Amulyam24 avatar Sep 13 '24 10:09 Amulyam24

/unhold

PR is ready for review, PTAL

Amulyam24 avatar Sep 24 '24 10:09 Amulyam24

@Karthik-K-N, added a couple of minor changes. PTAL!

Amulyam24 avatar Oct 08 '24 09:10 Amulyam24

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

Amulyam24 avatar Oct 15 '24 06:10 Amulyam24

[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 avatar Oct 15 '24 12:10 k8s-ci-robot