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:

Attach succeeds:

Name:         test-new-1
Namespace:    test
Labels:       <none>
Annotations:  <none>
API Version:  cns.vmware.com/v1alpha1
Kind:         CnsNodeVMBatchAttachment
Metadata:
  Creation Timestamp:  2025-11-17T08:35:04Z
  Finalizers:
    cns.vmware.com
  Generation:        1
  Resource Version:  12318458
  UID:               d8d776a2-7668-4af2-b5e4-74fd83bcb8d2
Spec:
  Instance UUID:  62e7ad21-713f-4fdf-9b0b-346d4ea2e722
  Volumes:
    Name:  disk-1
    Persistent Volume Claim:
      Claim Name:      claim-1
      Controller Key:  1000
      Disk Mode:       independent_persistent
      Sharing Mode:    sharingMultiWriter
      Unit Number:     5
Status:
  Conditions:
    Last Transition Time:  2025-11-17T08:35:06Z
    Message:               
    Reason:                True
    Status:                True
    Type:                  Ready
  Volumes:
    Name:  disk-1
    Persistent Volume Claim:
      Claim Name:     claim-1
      Cns Volume Id:  ba9694ac-9db9-4934-a961-836bbc1f6516
      Conditions:
        Last Transition Time:  2025-11-17T08:35:06Z
        Message:               
        Reason:                True
        Status:                True
        Type:                  VolumeAttached
      Disk UUID:               6000C297-99a1-7dbc-f453-f202b656f702
Events:
  Type    Reason                      Age   From            Message
  ----    ------                      ----  ----            -------
  Normal  NodeVmBatchAttachSucceeded  9s    cns.vmware.com  ReconcileCnsNodeVMBatchAttachment: Successfully processed instance test/test-new-1 in namespace "test/test-new-1".

Later I attached another volume, it failed:

Name:         test-new-1
Namespace:    test
Labels:       <none>
Annotations:  <none>
API Version:  cns.vmware.com/v1alpha1
Kind:         CnsNodeVMBatchAttachment
Metadata:
  Creation Timestamp:  2025-11-17T08:35:04Z
  Finalizers:
    cns.vmware.com
  Generation:        2
  Resource Version:  12319515
  UID:               d8d776a2-7668-4af2-b5e4-74fd83bcb8d2
Spec:
  Instance UUID:  62e7ad21-713f-4fdf-9b0b-346d4ea2e722
  Volumes:
    Name:  disk-1
    Persistent Volume Claim:
      Claim Name:      claim-1
      Controller Key:  1000
      Disk Mode:       independent_persistent
      Sharing Mode:    sharingMultiWriter
      Unit Number:     5
    Name:              disk-2
    Persistent Volume Claim:
      Claim Name:      claim-2
      Controller Key:  1000
      Disk Mode:       independent_persistent
      Sharing Mode:    sharingMultiWriter
      Unit Number:     6
Status:
  Conditions:
    Last Transition Time:  2025-11-17T08:36:47Z
    Message:               failed to attach volumes: a8d6c733-0967-4dbb-86c4-d1e8b09af8e3
    Reason:                Failed
    Status:                False
    Type:                  Ready
  Volumes:
    Name:  disk-1
    Persistent Volume Claim:
      Claim Name:     claim-1
      Cns Volume Id:  ba9694ac-9db9-4934-a961-836bbc1f6516
      Conditions:
        Last Transition Time:  2025-11-17T08:35:06Z
        Message:               
        Reason:                True
        Status:                True
        Type:                  VolumeAttached
      Disk UUID:               6000C297-99a1-7dbc-f453-f202b656f702
    Name:                      disk-2
    Persistent Volume Claim:
      Claim Name:     claim-2
      Cns Volume Id:  a8d6c733-0967-4dbb-86c4-d1e8b09af8e3
      Conditions:
        Last Transition Time:  2025-11-17T08:36:47Z
        Message:               failed to attach cns volume: "a8d6c733-0967-4dbb-86c4-d1e8b09af8e3" Error: The attempted operation cannot be performed in the current state (Powered on).
        Reason:                AttachFailed
        Status:                False
        Type:                  VolumeAttached
Events:
  Type     Reason                      Age   From            Message
  ----     ------                      ----  ----            -------
  Normal   NodeVmBatchAttachSucceeded  102s  cns.vmware.com  ReconcileCnsNodeVMBatchAttachment: Successfully processed instance test/test-new-1 in namespace "test/test-new-1".
  Warning  NodeVmBatchAttachFailed     1s    cns.vmware.com  failed to attach volumes: a8d6c733-0967-4dbb-86c4-d1e8b09af8e3

Detached all volumes:

Name:         test-new-1
Namespace:    test
Labels:       <none>
Annotations:  <none>
API Version:  cns.vmware.com/v1alpha1
Kind:         CnsNodeVMBatchAttachment
Metadata:
  Creation Timestamp:  2025-11-17T08:35:04Z
  Finalizers:
    cns.vmware.com
  Generation:        6
  Resource Version:  12360334
  UID:               d8d776a2-7668-4af2-b5e4-74fd83bcb8d2
Spec:
  Instance UUID:  62e7ad21-713f-4fdf-9b0b-346d4ea2e722
Status:
  Conditions:
    Last Transition Time:  2025-11-17T09:39:56Z
    Message:               
    Reason:                True
    Status:                True
    Type:                  Ready
Events:
  Type     Reason                      Age                   From            Message
  ----     ------                      ----                  ----            -------
  Warning  NodeVmBatchAttachFailed     8m26s (x18 over 56m)  cns.vmware.com  failed to attach volumes: 235161e6-691b-4c9d-b1b7-ad54d1964a01
  Normal   NodeVmBatchAttachSucceeded  3m26s (x5 over 68m)   cns.vmware.com  ReconcileCnsNodeVMBatchAttachment: Successfully processed instance test/test-new-1 in namespace "test/test-new-1".

Intentionally failed detach of a volume:

ame:         test-new-2
Namespace:    test
Labels:       <none>
Annotations:  <none>
API Version:  cns.vmware.com/v1alpha1
Kind:         CnsNodeVMBatchAttachment
Metadata:
  Creation Timestamp:  2025-11-17T10:12:18Z
  Finalizers:
    cns.vmware.com
  Generation:        2
  Resource Version:  12381781
  UID:               019a930c-1680-4ab8-abaa-71e12e259eb9
Spec:
  Instance UUID:  71d38fc3-21fb-49a8-88ce-cb9155aa6756
  Volumes:
    Name:  disk-1
    Persistent Volume Claim:
      Claim Name:      claim-1
      Controller Key:  1000
      Disk Mode:       independent_persistent
      Sharing Mode:    sharingMultiWriter
      Unit Number:     6
Status:
  Conditions:
    Last Transition Time:  2025-11-17T10:12:55Z
    Message:               failed to detach volumes: claim-3
    Reason:                Failed
    Status:                False
    Type:                  Ready
  Volumes:
    Name:  disk-1
    Persistent Volume Claim:
      Claim Name:     claim-1
      Cns Volume Id:  ba9694ac-9db9-4934-a961-836bbc1f6516
      Conditions:
        Last Transition Time:  2025-11-17T10:12:21Z
        Message:               
        Reason:                True
        Status:                True
        Type:                  VolumeAttached
      Disk UUID:               6000C297-99a1-7dbc-f453-f202b656f702
    Name:                      disk-2:detaching
    Persistent Volume Claim:
      Claim Name:     claim-3
      Cns Volume Id:  235161e6-691b-4c9d-b1b7-ad54d1964a01
      Conditions:
        Last Transition Time:  2025-11-17T10:12:21Z
        Message:               
        Reason:                True
        Status:                True
        Type:                  VolumeAttached
        Last Transition Time:  2025-11-17T10:12:54Z
        Message:               Intentional failure
        Reason:                DetachFailed
        Status:                False
        Type:                  VolumeDetached
      Disk UUID:               6000C291-5c41-cafc-a637-bbeda1f951f4
Events:
  Type     Reason                      Age              From            Message
  ----     ------                      ----             ----            -------
  Normal   NodeVmBatchAttachSucceeded  40s              cns.vmware.com  ReconcileCnsNodeVMBatchAttachment: Successfully processed instance test/test-new-2 in namespace "test/test-new-2".
  Warning  NodeVmBatchAttachFailed     2s (x3 over 6s)  cns.vmware.com  failed to detach volumes: claim-3

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: skogta
Once this PR has been reviewed and has the lgtm label, please assign akankshapanse 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 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 removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 17, 2025
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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 the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

2 participants