Skip to content

Adopt v1beta2 conditions for IBM VPC Machine #2447

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Amulyam24
Copy link
Contributor

@Amulyam24 Amulyam24 commented Jul 28, 2025

What this PR does / why we need it:
This PR includes changes for

  1. Adding v1beta2 status for IBM VPC Machine
  2. Streamline controller changes using CAPI helper functions
  3. Derive parent context while logging

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 part of #2389

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:

Adopt v1beta2 conditions for IBM VPC Machine

@k8s-ci-robot k8s-ci-robot added the area/provider/ibmcloud Issues or PRs related to ibmcloud provider label Jul 28, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Amulyam24
Once this PR has been reviewed and has the lgtm label, please assign mkumatag for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 28, 2025
Copy link

netlify bot commented Jul 28, 2025

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

Name Link
🔨 Latest commit 5f1ec6d
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-cluster-api-ibmcloud/deploys/689c8782d4c9aa0009e6fed4
😎 Deploy Preview https://deploy-preview-2447.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 project configuration.

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 28, 2025
@Amulyam24 Amulyam24 force-pushed the vpc-machine-v1beta2 branch from 02c00f7 to babe366 Compare July 28, 2025 09:17
@Amulyam24
Copy link
Contributor Author

 % kubectl describe ibmvpcmachine amulya-vpc-0-control-plane-kz9cm
Name:         amulya-vpc-0-control-plane-kz9cm
Namespace:    default
Labels:       cluster.x-k8s.io/cluster-name=amulya-vpc-0
              cluster.x-k8s.io/control-plane=
              cluster.x-k8s.io/control-plane-name=amulya-vpc-0-control-plane
Annotations:  cluster.x-k8s.io/cloned-from-groupkind: IBMVPCMachineTemplate.infrastructure.cluster.x-k8s.io
              cluster.x-k8s.io/cloned-from-name: amulya-vpc-0-control-plane
API Version:  infrastructure.cluster.x-k8s.io/v1beta2
Kind:         IBMVPCMachine
Metadata:
  Creation Timestamp:  2025-07-28T08:49:30Z
  Finalizers:
    ibmvpcmachine.infrastructure.cluster.x-k8s.io
  Generation:  2
  Owner References:
    API Version:           cluster.x-k8s.io/v1beta2
    Block Owner Deletion:  true
    Controller:            true
    Kind:                  Machine
    Name:                  amulya-vpc-0-control-plane-kz9cm
    UID:                   cd425297-b69d-4717-8b56-f418220fd19a
  Resource Version:        120923
  UID:                     923736b6-d8a0-46f8-b913-6c1eaec2988d
Spec:
  Boot Volume:
    Delete Volume On Instance Delete:  true
    Profile:                           general-purpose
    Size Gi B:                         20
  Image:
    Name:  capibm-vpc-ubuntu-2404-kube-v1-32-3
  Primary Network Interface:
    Subnet:     0717-977b9b8c-3aea-42f2-8bbe-655c3f829966
  Profile:      bx2-4x16
  Provider ID:  ibm://c265c8cefda241ca9c107adcbbacaa84///amulya-vpc-0/0717_1d96a8d8-be0d-4b3d-9b26-de4acd6f11f1
  Ssh Keys:
    Name:  amulya-ssh
  Zone:    us-south-1
Status:
  Addresses:
    Address:  amulya-vpc-0-control-plane-kz9cm
    Type:     InternalDNS
    Address:  amulya-vpc-0-control-plane-kz9cm
    Type:     Hostname
    Address:  10.240.0.6
    Type:     InternalIP
  Conditions:
    Last Transition Time:  2025-07-28T08:52:29Z
    Status:                True
    Type:                  Ready
    Last Transition Time:  2025-07-28T08:52:29Z
    Status:                True
    Type:                  InstanceReady
  Instance ID:             0717_1d96a8d8-be0d-4b3d-9b26-de4acd6f11f1
  Instance State:          running
  Ready:                   true
  v1beta2:
    Conditions:
      Last Transition Time:  2025-07-28T08:52:29Z
      Message:
      Observed Generation:   2
      Reason:                Ready
      Status:                True
      Type:                  Ready
      Last Transition Time:  2025-07-28T08:52:29Z
      Message:
      Observed Generation:   2
      Reason:                InstanceReady
      Status:                True
      Type:                  InstanceReady
      Last Transition Time:  2025-07-28T08:49:30Z
      Message:
      Observed Generation:   1
      Reason:                NotPaused
      Status:                False
      Type:                  Paused
Events:
  Type    Reason                    Age    From                 Message
  ----    ------                    ----   ----                 -------
  Normal  SuccessfulCreateInstance  3m26s  ibmcloud-controller  Created Instance "amulya-vpc-0-control-plane-kz9cm"

---

% kubectl describe ibmvpcmachine amulya-vpc-0-control-plane-kz9cm
Name:         amulya-vpc-0-control-plane-kz9cm
Namespace:    default
Labels:       cluster.x-k8s.io/cluster-name=amulya-vpc-0
              cluster.x-k8s.io/control-plane=
              cluster.x-k8s.io/control-plane-name=amulya-vpc-0-control-plane
Annotations:  cluster.x-k8s.io/cloned-from-groupkind: IBMVPCMachineTemplate.infrastructure.cluster.x-k8s.io
              cluster.x-k8s.io/cloned-from-name: amulya-vpc-0-control-plane
API Version:  infrastructure.cluster.x-k8s.io/v1beta2
Kind:         IBMVPCMachine
Metadata:
  Creation Timestamp:             2025-07-28T08:49:30Z
  Deletion Grace Period Seconds:  0
  Deletion Timestamp:             2025-07-28T09:08:07Z
  Finalizers:
    ibmvpcmachine.infrastructure.cluster.x-k8s.io
  Generation:  3
  Owner References:
    API Version:           cluster.x-k8s.io/v1beta2
    Block Owner Deletion:  true
    Controller:            true
    Kind:                  Machine
    Name:                  amulya-vpc-0-control-plane-kz9cm
    UID:                   cd425297-b69d-4717-8b56-f418220fd19a
  Resource Version:        124128
  UID:                     923736b6-d8a0-46f8-b913-6c1eaec2988d
Spec:
  Boot Volume:
    Delete Volume On Instance Delete:  true
    Profile:                           general-purpose
    Size Gi B:                         20
  Image:
    Name:  capibm-vpc-ubuntu-2404-kube-v1-32-3
  Primary Network Interface:
    Subnet:     0717-977b9b8c-3aea-42f2-8bbe-655c3f829966
  Profile:      bx2-4x16
  Provider ID:  ibm://c265c8cefda241ca9c107adcbbacaa84///amulya-vpc-0/0717_1d96a8d8-be0d-4b3d-9b26-de4acd6f11f1
  Ssh Keys:
    Name:  amulya-ssh
  Zone:    us-south-1
Status:
  Addresses:
    Address:  amulya-vpc-0-control-plane-kz9cm
    Type:     InternalDNS
    Address:  amulya-vpc-0-control-plane-kz9cm
    Type:     Hostname
    Address:  10.240.0.6
    Type:     InternalIP
  Conditions:
    Last Transition Time:  2025-07-28T09:02:32Z
    Reason:                InstanceStopped
    Severity:              Error
    Status:                False
    Type:                  Ready
    Last Transition Time:  2025-07-28T09:02:32Z
    Reason:                InstanceStopped
    Severity:              Error
    Status:                False
    Type:                  InstanceReady
  Instance ID:             0717_1d96a8d8-be0d-4b3d-9b26-de4acd6f11f1
  Instance State:          stopped
  Ready:                   false
  v1beta2:
    Conditions:
      Last Transition Time:  2025-07-28T09:02:32Z
      Message:               * InstanceReady: InstanceStopped
      Observed Generation:   3
      Reason:                NotReady
      Status:                False
      Type:                  Ready
      Last Transition Time:  2025-07-28T09:02:32Z
      Message:
      Observed Generation:   2
      Reason:                InstanceStopped
      Status:                False
      Type:                  InstanceReady
      Last Transition Time:  2025-07-28T08:49:30Z
      Message:
      Observed Generation:   1
      Reason:                NotPaused
      Status:                False
      Type:                  Paused
Events:
  Type    Reason                    Age   From                 Message
  ----    ------                    ----  ----                 -------
  Normal  SuccessfulCreateInstance  19m   ibmcloud-controller  Created Instance "amulya-vpc-0-control-plane-kz9cm"

// Before computing ready condition, make sure that InstanceReady is always set.
// NOTE: This is required because v1beta2 conditions comply to guideline requiring conditions to be set at the
// first reconcile.
if c := v1beta2conditions.Get(ibmVPCMachine, infrav1.IBMVPCMachineInstanceReadyV1Beta2Condition); c == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to add a test case , where we can make sure that the IBMVPCMachineInstanceReadyV1Beta2Condition is set on the first reconcilation?
Just call a Reconcile and see whether the condition is set or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will check if this can be done and add the test 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.

@Karthik-K-N, adding this seems more like a functional test case rather than UT. IMO, we can take it up as a follow up task in favour of merging this PR - wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, That should be ok, Unless we dont forget this, @arshadd-b is also adding similar test to IBMPowerVSImage, Please check if the similar approach can be followed,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the test case and also tested cluster creation after final changes, PTAL!

@Amulyam24 Amulyam24 force-pushed the vpc-machine-v1beta2 branch 6 times, most recently from 3fd5daf to c38a9e2 Compare August 13, 2025 12:22
@Amulyam24 Amulyam24 force-pushed the vpc-machine-v1beta2 branch from c38a9e2 to 5f1ec6d Compare August 13, 2025 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants