Skip to content

Conversation

@skogta
Copy link
Contributor

@skogta skogta commented Nov 10, 2025

What this PR does / why we need it:
We need to use K8s conditions to display error messaged for batch attach CRD.

Testing done:

Attached 1 volume to VM:

Name:         vm-conditions-2
Namespace:    test
Labels:       <none>
Annotations:  <none>
API Version:  cns.vmware.com/v1alpha1
Kind:         CnsNodeVMBatchAttachment
Metadata:
  Creation Timestamp:  2025-12-10T14:05:14Z
  Finalizers:
    cns.vmware.com
  Generation:  2
  Owner References:
    API Version:           vmoperator.vmware.com/v1alpha5
    Block Owner Deletion:  true
    Controller:            true
    Kind:                  VirtualMachine
    Name:                  vm-conditions-2
    UID:                   2a89cdc3-0289-42bf-86db-954fb266b510
  Resource Version:        7593516
  UID:                     7f915ffb-6929-4e4a-821a-6e3001df012c
Spec:
  Instance UUID:  fb871f52-2218-481a-aa26-725a51c14ade
  Volumes:
    Name:  pvc1
    Persistent Volume Claim:
      Claim Name:      pvc-cond-2
      Controller Key:  1001
      Disk Mode:       persistent
      Sharing Mode:    sharingNone
      Unit Number:     0
Status:
  Conditions:
    Last Transition Time:  2025-12-10T14:05:13Z
    Message:               
    Reason:                True
    Status:                True
    Type:                  Ready
  Volumes:
    Name:  pvc1
    Persistent Volume Claim:
      Attached:       true
      Claim Name:     pvc-cond-2
      Cns Volume Id:  7101909b-b096-4789-bf22-9f73a59161ec
      Conditions:
        Last Transition Time:  2025-12-10T14:05:18Z
        Message:               
        Reason:                True
        Status:                True
        Type:                  VolumeAttached
      Disk UUID:               6000C296-50a5-e260-f19c-76fc7773260e
Events:
  Type    Reason                      Age                From            Message
  ----    ------                      ----               ----            -------
  Normal  NodeVmBatchAttachSucceeded  30s (x2 over 35s)  cns.vmware.com  ReconcileCnsNodeVMBatchAttachment: Successfully processed instance test/vm-conditions-2 in namespace "test/vm-conditions-2".

Attached volume with invalid config and observed failure:

Name:         vm-conditions-2
Namespace:    test
Labels:       <none>
Annotations:  <none>
API Version:  cns.vmware.com/v1alpha1
Kind:         CnsNodeVMBatchAttachment
Metadata:
  Creation Timestamp:  2025-12-10T14:05:14Z
  Finalizers:
    cns.vmware.com
  Generation:  3
  Owner References:
    API Version:           vmoperator.vmware.com/v1alpha5
    Block Owner Deletion:  true
    Controller:            true
    Kind:                  VirtualMachine
    Name:                  vm-conditions-2
    UID:                   2a89cdc3-0289-42bf-86db-954fb266b510
  Resource Version:        7594752
  UID:                     7f915ffb-6929-4e4a-821a-6e3001df012c
Spec:
  Instance UUID:  fb871f52-2218-481a-aa26-725a51c14ade
  Volumes:
    Name:  pvc1
    Persistent Volume Claim:
      Claim Name:      pvc-cond-2
      Controller Key:  1001
      Disk Mode:       persistent
      Sharing Mode:    sharingNone
      Unit Number:     0
    Name:              pvc2
    Persistent Volume Claim:
      Claim Name:      pvc-cond-3
      Controller Key:  1000
      Disk Mode:       persistent
      Sharing Mode:    sharingNone
      Unit Number:     0
Status:
  Conditions:
    Last Transition Time:  2025-12-10T14:06:46Z
    Message:               failed to attach volumes: 3e99a8e3-2dea-441e-81da-141eae5d0ea6
    Reason:                Failed
    Status:                False
    Type:                  Ready
  Error:                   failed to attach volumes: 3e99a8e3-2dea-441e-81da-141eae5d0ea6
  Volumes:
    Name:  pvc1
    Persistent Volume Claim:
      Attached:       true
      Claim Name:     pvc-cond-2
      Cns Volume Id:  7101909b-b096-4789-bf22-9f73a59161ec
      Conditions:
        Last Transition Time:  2025-12-10T14:05:18Z
        Message:               
        Reason:                True
        Status:                True
        Type:                  VolumeAttached
      Disk UUID:               6000C296-50a5-e260-f19c-76fc7773260e
    Name:                      pvc2
    Persistent Volume Claim:
      Attached:       false
      Claim Name:     pvc-cond-3
      Cns Volume Id:  3e99a8e3-2dea-441e-81da-141eae5d0ea6
      Conditions:
        Last Transition Time:  2025-12-10T14:06:46Z
        Message:               failed to attach cns volume: "3e99a8e3-2dea-441e-81da-141eae5d0ea6" Error: Invalid configuration for device '0'.
        Reason:                AttachFailed
        Status:                False
        Type:                  VolumeAttached
      Error:                   failed to attach cns volume: "3e99a8e3-2dea-441e-81da-141eae5d0ea6" Error: Invalid configuration for device '0'.
Events:
  Type     Reason                      Age                  From            Message
  ----     ------                      ----                 ----            -------
  Normal   NodeVmBatchAttachSucceeded  101s (x2 over 106s)  cns.vmware.com  ReconcileCnsNodeVMBatchAttachment: Successfully processed instance test/vm-conditions-2 in namespace "test/vm-conditions-2".
  Warning  NodeVmBatchAttachFailed     4s (x4 over 13s)     cns.vmware.com  failed to attach volumes: 3e99a8e3-2dea-441e-81da-141eae5d0ea6

Attached volume correctly:

Name:         vm-conditions-2
Namespace:    test
Labels:       <none>
Annotations:  <none>
API Version:  cns.vmware.com/v1alpha1
Kind:         CnsNodeVMBatchAttachment
Metadata:
  Creation Timestamp:  2025-12-10T14:05:14Z
  Finalizers:
    cns.vmware.com
  Generation:  4
  Owner References:
    API Version:           vmoperator.vmware.com/v1alpha5
    Block Owner Deletion:  true
    Controller:            true
    Kind:                  VirtualMachine
    Name:                  vm-conditions-2
    UID:                   2a89cdc3-0289-42bf-86db-954fb266b510
  Resource Version:        7595364
  UID:                     7f915ffb-6929-4e4a-821a-6e3001df012c
Spec:
  Instance UUID:  fb871f52-2218-481a-aa26-725a51c14ade
  Volumes:
    Name:  pvc1
    Persistent Volume Claim:
      Claim Name:      pvc-cond-2
      Controller Key:  1001
      Disk Mode:       persistent
      Sharing Mode:    sharingNone
      Unit Number:     0
    Name:              pvc2
    Persistent Volume Claim:
      Claim Name:      pvc-cond-3
      Controller Key:  1000
      Disk Mode:       persistent
      Sharing Mode:    sharingNone
      Unit Number:     3
Status:
  Conditions:
    Last Transition Time:  2025-12-10T14:07:43Z
    Message:               
    Reason:                True
    Status:                True
    Type:                  Ready
  Volumes:
    Name:  pvc1
    Persistent Volume Claim:
      Attached:       true
      Claim Name:     pvc-cond-2
      Cns Volume Id:  7101909b-b096-4789-bf22-9f73a59161ec
      Conditions:
        Last Transition Time:  2025-12-10T14:05:18Z
        Message:               
        Reason:                True
        Status:                True
        Type:                  VolumeAttached
      Disk UUID:               6000C296-50a5-e260-f19c-76fc7773260e
    Name:                      pvc2
    Persistent Volume Claim:
      Attached:       true
      Claim Name:     pvc-cond-3
      Cns Volume Id:  3e99a8e3-2dea-441e-81da-141eae5d0ea6
      Conditions:
        Last Transition Time:  2025-12-10T14:07:43Z
        Message:               
        Reason:                True
        Status:                True
        Type:                  VolumeAttached
      Disk UUID:               6000C295-be82-b87a-bb31-076020cc4129
Events:
  Type     Reason                      Age                 From            Message
  ----     ------                      ----                ----            -------
  Warning  NodeVmBatchAttachFailed     24s (x6 over 58s)   cns.vmware.com  failed to attach volumes: 3e99a8e3-2dea-441e-81da-141eae5d0ea6
  Normal   NodeVmBatchAttachSucceeded  1s (x3 over 2m31s)  cns.vmware.com  ReconcileCnsNodeVMBatchAttachment: Successfully processed instance test/vm-conditions-2 in namespace "test/vm-conditions-2".

Detached 1 volume:

Name:         vm-conditions-2
Namespace:    test
Labels:       <none>
Annotations:  <none>
API Version:  cns.vmware.com/v1alpha1
Kind:         CnsNodeVMBatchAttachment
Metadata:
  Creation Timestamp:  2025-12-10T14:05:14Z
  Finalizers:
    cns.vmware.com
  Generation:  5
  Owner References:
    API Version:           vmoperator.vmware.com/v1alpha5
    Block Owner Deletion:  true
    Controller:            true
    Kind:                  VirtualMachine
    Name:                  vm-conditions-2
    UID:                   2a89cdc3-0289-42bf-86db-954fb266b510
  Resource Version:        7595833
  UID:                     7f915ffb-6929-4e4a-821a-6e3001df012c
Spec:
  Instance UUID:  fb871f52-2218-481a-aa26-725a51c14ade
  Volumes:
    Name:  pvc2
    Persistent Volume Claim:
      Claim Name:      pvc-cond-3
      Controller Key:  1000
      Disk Mode:       persistent
      Sharing Mode:    sharingNone
      Unit Number:     3
Status:
  Conditions:
    Last Transition Time:  2025-12-10T14:07:43Z
    Message:               
    Reason:                True
    Status:                True
    Type:                  Ready
  Volumes:
    Name:  pvc2
    Persistent Volume Claim:
      Attached:       true
      Claim Name:     pvc-cond-3
      Cns Volume Id:  3e99a8e3-2dea-441e-81da-141eae5d0ea6
      Conditions:
        Last Transition Time:  2025-12-10T14:07:43Z
        Message:               
        Reason:                True
        Status:                True
        Type:                  VolumeAttached
      Disk UUID:               6000C295-be82-b87a-bb31-076020cc4129
Events:
  Type     Reason                      Age                 From            Message
  ----     ------                      ----                ----            -------
  Warning  NodeVmBatchAttachFailed     68s (x6 over 102s)  cns.vmware.com  failed to attach volumes: 3e99a8e3-2dea-441e-81da-141eae5d0ea6
  Normal   NodeVmBatchAttachSucceeded  2s (x5 over 3m15s)  cns.vmware.com  ReconcileCnsNodeVMBatchAttachment: Successfully processed instance test/vm-conditions-2 in namespace "test/vm-conditions-2".

Purposefully failed: detached of the volume:

apiVersion: cns.vmware.com/v1alpha1
kind: CnsNodeVMBatchAttachment
metadata:
  creationTimestamp: "2025-12-10T14:05:14Z"
  finalizers:
  - cns.vmware.com
  generation: 7
  name: vm-conditions-2
  namespace: test
  ownerReferences:
  - apiVersion: vmoperator.vmware.com/v1alpha5
    blockOwnerDeletion: true
    controller: true
    kind: VirtualMachine
    name: vm-conditions-2
    uid: 2a89cdc3-0289-42bf-86db-954fb266b510
  resourceVersion: "7603878"
  uid: 7f915ffb-6929-4e4a-821a-6e3001df012c
spec:
  instanceUUID: fb871f52-2218-481a-aa26-725a51c14ade
  volumes:
  - name: pvc2
    persistentVolumeClaim:
      claimName: pvc-cond-3
      controllerKey: 1000
      diskMode: persistent
      sharingMode: sharingNone
      unitNumber: 3
status:
  conditions:
  - lastTransitionTime: "2025-12-10T14:19:12Z"
    message: 'failed to detach volumes: pvc-cond-2'
    reason: Failed
    status: "False"
    type: Ready
  error: 'failed to detach volumes: pvc-cond-2'
  volumes:
  - name: pvc2
    persistentVolumeClaim:
      attached: true
      claimName: pvc-cond-3
      cnsVolumeId: 3e99a8e3-2dea-441e-81da-141eae5d0ea6
      conditions:
      - lastTransitionTime: "2025-12-10T14:07:43Z"
        message: ""
        reason: "True"
        status: "True"
        type: VolumeAttached
      diskUUID: 6000C295-be82-b87a-bb31-076020cc4129
  - name: pvc:1:detaching
    persistentVolumeClaim:
      attached: false
      claimName: pvc-cond-2
      cnsVolumeId: 7101909b-b096-4789-bf22-9f73a59161ec
      conditions:
      - lastTransitionTime: "2025-12-10T14:18:16Z"
        message: ""
        reason: "True"
        status: "True"
        type: VolumeAttached
      - lastTransitionTime: "2025-12-10T14:19:12Z"
        message: temp failure
        reason: DetachFailed
        status: "False"
        type: VolumeDetached
      diskUUID: 6000C296-50a5-e260-f19c-76fc7773260e
      error: temp failure

WCP precheckin: https://jenkins-vcf-csifvt.devops.broadcom.net/view/instapp/job/wcp-instapp-e2e-pre-checkin/733/
VKS precheckin: https://jenkins-vcf-csifvt.devops.broadcom.net/job/vks-instapp-e2e-pre-checkin/679/

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 10, 2025
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 10, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @skogta. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 10, 2025
@skogta skogta force-pushed the topic/skogta/k8sConditionsV2 branch from 162652a to 2119899 Compare November 14, 2025 08:18
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 14, 2025
@skogta skogta force-pushed the topic/skogta/k8sConditionsV2 branch from 2119899 to c9d8af0 Compare November 17, 2025 10:15
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 17, 2025
@skogta skogta force-pushed the topic/skogta/k8sConditionsV2 branch from c9d8af0 to 5c5a2a3 Compare December 10, 2025 09:41
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 10, 2025
@skogta skogta force-pushed the topic/skogta/k8sConditionsV2 branch 2 times, most recently from 719cc45 to 0525090 Compare December 10, 2025 14:23
@vdkotkar
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 10, 2025
Add back Error and Atatched fields temporarily so that it does not break VM op compatibility
@skogta skogta force-pushed the topic/skogta/k8sConditionsV2 branch from 0525090 to 620ff3a Compare December 11, 2025 02:47
@deepakkinni
Copy link
Collaborator

Triggering CSI-TKG Pre-checkin Pipeline for this PR... Job takes approximately an hour to complete
Jenkins Build #673

@deepakkinni
Copy link
Collaborator

Triggering CSI-WCP Pre-checkin Pipeline for this PR... Job takes approximately an hour to complete
Jenkins Build #733

@deepakkinni
Copy link
Collaborator

Triggering CSI-TKG Pre-checkin Pipeline for this PR... Job takes approximately an hour to complete
Jenkins Build #676

@deepakkinni
Copy link
Collaborator

SUCCESS --- Jenkins Build #677

@deepakkinni
Copy link
Collaborator

SUCCESS --- Jenkins Build #679

Copy link
Member

@divyenpatel divyenpatel left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 11, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: divyenpatel, skogta

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 Dec 11, 2025
@k8s-ci-robot k8s-ci-robot merged commit c059af9 into kubernetes-sigs:master Dec 11, 2025
12 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. 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

5 participants