Skip to content

Adopt CAPI v1beta2 status changes and respective controller changes for IBMPowerVSMachine #2272

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

Conversation

Karthik-K-N
Copy link
Contributor

What this PR does / why we need it:

This PR consists of following changes

  1. Adopt CAPI v1beta2 status changes
  2. Standardize the controller flow by utilising CAPI provided helper functions
  3. Removed usage of deprecated github.com/pkg/errors package.

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 #2264

Special notes for your reviewer:

Tried to keep different commits for each use case

/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:

Adopt CAPI v1beta2 status changes into IBMPowerVSMachine object.

@k8s-ci-robot k8s-ci-robot added the area/provider/ibmcloud Issues or PRs related to ibmcloud provider label Mar 26, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 26, 2025
Copy link

netlify bot commented Mar 26, 2025

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

Name Link
🔨 Latest commit 62f9e9f
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-ibmcloud/deploys/67f3cae35e29b70008fc0cb8
😎 Deploy Preview https://deploy-preview-2272.cluster-api-ibmcloud.sigs.k8s.io
📱 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.

@Karthik-K-N
Copy link
Contributor Author

/test pull-cluster-api-provider-ibmcloud-apidiff

@Karthik-K-N
Copy link
Contributor Author

Output from testing

kubectl get ibmpowervsmachine karthikkn-capi-powervs-control-plane-4vfvx -o yaml

status:
  addresses:
  - address: karthikkn-capi-powervs-control-plane-4vfvx
    type: InternalDNS
  - address: karthikkn-capi-powervs-control-plane-4vfvx
    type: Hostname
  - address: 192.168.0.12
    type: InternalIP
  conditions:
  - lastTransitionTime: "2025-03-26T06:06:11Z"
    status: "True"
    type: Ready
  - lastTransitionTime: "2025-03-26T06:06:11Z"
    status: "True"
    type: InstanceReady
  health: WARNING
  instanceID: b13dc26f-d491-442d-afde-83487aed2628
  instanceState: ACTIVE
  ready: true
  v1beta2:
    conditions:
    - lastTransitionTime: "2025-03-26T06:06:11Z"
      message: ""
      observedGeneration: 2
      reason: Ready
      status: "True"
      type: Ready
    - lastTransitionTime: "2025-03-26T06:06:11Z"
      message: ""
      observedGeneration: 2
      reason: InstanceReady
      status: "True"
      type: InstanceReady
    - lastTransitionTime: "2025-03-26T05:59:04Z"
      message: ""
      observedGeneration: 2
      reason: NotPaused
      status: "False"
      type: Paused
$ kubectl get machines
NAME                                         CLUSTER                  NODENAME                                     PROVIDERID                                                                                         PHASE         AGE     VERSION
karthikkn-capi-powervs-control-plane-4vfvx   karthikkn-capi-powervs   karthikkn-capi-powervs-control-plane-4vfvx   ibmpowervs://osa/osa21/ca6af7ac-75bd-41b3-9c73-61f8cde01aea/b13dc26f-d491-442d-afde-83487aed2628   Running       13m     v1.29.3
karthikkn-capi-powervs-control-plane-7ncq6   karthikkn-capi-powervs                                                ibmpowervs://osa/osa21/ca6af7ac-75bd-41b3-9c73-61f8cde01aea/2bb05c0b-4507-4fb7-86ad-c38052385bea   Provisioned   4m34s   v1.29.3
karthikkn-capi-powervs-control-plane-pbxld   karthikkn-capi-powervs   karthikkn-capi-powervs-control-plane-pbxld   ibmpowervs://osa/osa21/ca6af7ac-75bd-41b3-9c73-61f8cde01aea/b200a882-d711-4324-80a2-bcaa839d8d9c   Running       52m     v1.29.3
karthikkn-capi-powervs-md-0-4bt5m-l65ms      karthikkn-capi-powervs   karthikkn-capi-powervs-md-0-4bt5m-l65ms      ibmpowervs://osa/osa21/ca6af7ac-75bd-41b3-9c73-61f8cde01aea/825139af-3f01-4b38-8cf4-35f238825650   Running       52m     v1.29.3


@Karthik-K-N
Copy link
Contributor Author

$ kubectl get ibmpowervsmachines.v1beta1.infrastructure.cluster.x-k8s.io karthikkn-capi-powervs-control-plane-4vfvx -o yaml

status:
  addresses:
  - address: karthikkn-capi-powervs-control-plane-4vfvx
    type: InternalDNS
  - address: karthikkn-capi-powervs-control-plane-4vfvx
    type: Hostname
  - address: 192.168.0.12
    type: InternalIP
  conditions:
  - lastTransitionTime: "2025-03-26T06:06:11Z"
    status: "True"
    type: Ready
  - lastTransitionTime: "2025-03-26T06:06:11Z"
    status: "True"
    type: InstanceReady
  health: WARNING
  instanceID: b13dc26f-d491-442d-afde-83487aed2628
  instanceState: ACTIVE
  ready: true
$ kubectl get ibmpowervsmachines.v1beta2.infrastructure.cluster.x-k8s.io karthikkn-capi-powervs-control-plane-4vfvx -o yaml

status:
  addresses:
  - address: karthikkn-capi-powervs-control-plane-4vfvx
    type: InternalDNS
  - address: karthikkn-capi-powervs-control-plane-4vfvx
    type: Hostname
  - address: 192.168.0.12
    type: InternalIP
  conditions:
  - lastTransitionTime: "2025-03-26T06:06:11Z"
    status: "True"
    type: Ready
  - lastTransitionTime: "2025-03-26T06:06:11Z"
    status: "True"
    type: InstanceReady
  health: WARNING
  instanceID: b13dc26f-d491-442d-afde-83487aed2628
  instanceState: ACTIVE
  ready: true
  v1beta2:
    conditions:
    - lastTransitionTime: "2025-03-26T06:06:11Z"
      message: ""
      observedGeneration: 2
      reason: Ready
      status: "True"
      type: Ready
    - lastTransitionTime: "2025-03-26T06:06:11Z"
      message: ""
      observedGeneration: 2
      reason: InstanceReady
      status: "True"
      type: InstanceReady
    - lastTransitionTime: "2025-03-26T05:59:04Z"
      message: ""
      observedGeneration: 2
      reason: NotPaused
      status: "False"
      type: Paused

@Karthik-K-N Karthik-K-N force-pushed the standardise-controller branch from 8db3c4e to e6c4127 Compare March 26, 2025 11:56
@Karthik-K-N
Copy link
Contributor Author

@Prajyot-Parab @Amulyam24 @dharaneeshvrd please take a look when you get chance.

Copy link
Contributor

@Prajyot-Parab Prajyot-Parab 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 Apr 3, 2025
@Prajyot-Parab
Copy link
Contributor

/cc @dharaneeshvrd

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.

I see few logs have been completely removed, hope that is intentional
Overall LGTM.
I don't see any changes that would affect the hypershift flow. Please think once from that perspective too. Thanks!

@@ -635,7 +617,7 @@ func (m *PowerVSMachineScope) GetRawBootstrapData() ([]byte, error) {
secret := &corev1.Secret{}
key := types.NamespacedName{Namespace: m.Machine.Namespace, Name: *m.Machine.Spec.Bootstrap.DataSecretName}
if err := m.Client.Get(context.TODO(), key, secret); err != nil {
return nil, fmt.Errorf("failed to retrieve bootstrap data secret for IBMPowerVSMachine %s/%s: %w", m.Machine.Namespace, m.Machine.Name, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to remove this info?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are embedding the machine names, namespaces, cluster name so on into logger and thats added to context, Like

log = log.WithValues("Machine", klog.KObj(machine))
ctx = ctrl.LoggerInto(ctx, log)

These can be found in function
func (r *IBMPowerVSMachineReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error) {

So the log line will by default contains these information and we need not explicitly add it again.

@Karthik-K-N
Copy link
Contributor Author

I see few logs have been completely removed, hope that is intentional Overall LGTM. I don't see any changes that would affect the hypershift flow. Please think once from that perspective too. Thanks!

Thank you, Yes, I just refactored logs to avoid unnecessary or duplicate lines.

@dharaneeshvrd
Copy link
Contributor

/lgtm

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.

Minor comments, overall LGTM @Karthik-K-N !


instanceReply, err := m.ensureInstanceUnique(m.IBMPowerVSMachine.Name)
if err != nil {
return nil, err
} else if instanceReply != nil {
// TODO need a reasonable wrapped error.
log.Info("PowerVS instance already exists")
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to log the name of the machine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logger will automatically print the machine and other owner details as mentioned here #2272 (comment)

@@ -271,38 +255,42 @@ func (m *PowerVSMachineScope) CreateMachine() (*models.PVMInstanceReference, err
if con.Type == infrav1beta2.InstanceReadyCondition && con.Status == corev1.ConditionUnknown {
Copy link
Contributor

Choose a reason for hiding this comment

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

would we have to remove this going further as it is similar to the below check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when CAPI completely migrates into v1beta2 we will remove the earlier one.

m.IBMPowerVSMachine.Status.FailureReason = &reason
}

// SetFailureMessage will set status FailureMessage for the machine.
func (m *PowerVSMachineScope) SetFailureMessage(message string) {
//nolint:staticcheck
Copy link
Contributor

Choose a reason for hiding this comment

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

can you share why staticcheck is being ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we are setting the FailureMessage which has been deprecated as per CAPI v1beta2 guidelines.

@@ -235,6 +236,7 @@ func TestIBMPowerVSMachineReconciler_Reconcile(t *testing.T) {
Name: tc.powervsMachine.Name,
},
})
fmt.Println(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

missed removing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated it in the latest commit

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 7, 2025
@Karthik-K-N Karthik-K-N force-pushed the standardise-controller branch from 40ede8b to 5abb1a8 Compare April 7, 2025 09:50
Comment on lines +287 to +301
func (r *IBMPowerVSMachine) GetV1Beta2Conditions() []metav1.Condition {
if r.Status.V1Beta2 == nil {
return nil
}
return r.Status.V1Beta2.Conditions
}

// SetV1Beta2Conditions sets conditions for an API object.
func (r *IBMPowerVSMachine) SetV1Beta2Conditions(conditions []metav1.Condition) {
if r.Status.V1Beta2 == nil {
r.Status.V1Beta2 = &IBMPowerVSMachineV1Beta2Status{}
}
r.Status.V1Beta2.Conditions = conditions
}

Copy link
Contributor

Choose a reason for hiding this comment

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

@Karthik-K-N , where are we using this functions? I'm unable to find it in this PR, it is required for future changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are part of Setter interface. We need to implement these interfaces to use utility functions to set the conditions, As they accept setter interface as parameter: https://github.com/kubernetes-sigs/cluster-api/blob/09e6c8a14c2dd955924e7534727974d1e89643e5/util/conditions/v1beta2/setter.go#L73

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, Thanks @Karthik-K-N 👍🏼

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 7, 2025
@Karthik-K-N Karthik-K-N force-pushed the standardise-controller branch from 5abb1a8 to 62f9e9f Compare April 7, 2025 12:53
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 7, 2025
Copy link
Contributor

@Prajyot-Parab Prajyot-Parab 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 Apr 8, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Karthik-K-N, Prajyot-Parab

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 Apr 8, 2025
@k8s-ci-robot k8s-ci-robot merged commit f792076 into kubernetes-sigs:main Apr 8, 2025
14 checks passed
@Karthik-K-N Karthik-K-N changed the title Adopt CAPI v2beta2 status changes and respective controller changes for IBMPowerVSMachine Adopt CAPI v1beta2 status changes and respective controller changes for IBMPowerVSMachine Apr 29, 2025
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.

Update CAPIBM PowerVS resources Status fields to adopt to CAPI v1beta2 changes
5 participants