Skip to content
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

Generate events on PV when volume cannot be created for static volumes #2725

Merged
merged 1 commit into from Dec 29, 2023

Conversation

skogta
Copy link
Contributor

@skogta skogta commented Dec 22, 2023

What this PR does / why we need it:

If static volume provisioning fails for a PV, then there is now ay for the user to verify that it has failed other than checking syncer logs. So in this PR, we are generating failure event for static volumes.

Note: There are only 2 types events: https://pkg.go.dev/k8s.io/api/core/v1
So setting the type to Warning in this case.

Also, as part of this change, I am changing the method getPVsInBoundAvailableOrReleasedForVc to not return error if a volume cannot be mapped to a VC. One bad volume should not block the rest of the full sync.

Testing done:
On a multi VC testbed, created a RWX static volume with incorrect VolumeHandle that does not exist.
PV describe output:

root@k8s-control-556-1702644001:~# kubectl edit pv pvc-4810dd5e-b51a-46d5-bbd2-f97c90a647ec
persistentvolume/pvc-4810dd5e-b51a-46d5-bbd2-f97c90a647ec edited
root@k8s-control-556-1702644001:~# kubectl describe pv 14-file-static-file-share-pv-name
Name:            14-file-static-file-share-pv-name
Labels:          static-pv-label-key=static-pv-label-value
Annotations:     pv.kubernetes.io/provisioned-by: csi.vsphere.vmware.com
Finalizers:      [kubernetes.io/pv-protection]
StorageClass:    
Status:          Available
Claim:           
Reclaim Policy:  Retain
Access Modes:    RWO
VolumeMode:      Filesystem
Capacity:        1Gi
Node Affinity:   <none>
Message:         
Source:
    Type:              CSI (a Container Storage Interface (CSI) volume source)
    Driver:            csi.vsphere.vmware.com
    FSType:            
    VolumeHandle:      jkcns-jkncsk-3722
    ReadOnly:          false
    VolumeAttributes:      type=vSphere CNS File Volume
Events:
  Type     Reason                             Age   From                Message
  ----     ------                             ----  ----                -------
  Warning  static volume provisioning failed  17m   VSphere CSI Syncer  Failed to identify VC for volume

On multi VC testbed, created a block volume without nodeaffinity rules

root@k8s-control-556-1702644001:~# kubectl describe pv 10-block-static-file-share-pv-name



Name:            10-block-static-file-share-pv-name
Labels:          static-pv-label-key=static-pv-label-value
Annotations:     pv.kubernetes.io/provisioned-by: csi.vsphere.vmware.com
Finalizers:      [kubernetes.io/pv-protection]
StorageClass:    
Status:          Available
Claim:           
Reclaim Policy:  Retain
Access Modes:    RWO
VolumeMode:      Filesystem
Capacity:        1Gi
Node Affinity:   <none>
Message:         
Source:
    Type:              CSI (a Container Storage Interface (CSI) volume source)
    Driver:            csi.vsphere.vmware.com
    FSType:            
    VolumeHandle:      file:ocfd3946-bc5f-4c73-acca-95daae477f80
    ReadOnly:          false
    VolumeAttributes:      type=vSphere CNS File Volume
Events:
  Type     Reason                             Age   From                Message
  ----     ------                             ----  ----                -------
  Warning  static volume provisioning failed  15s   VSphere CSI Syncer  Failed to identify VC for volume.

Single VC failure

root@k8s-control-409-1703204631:~# kubectl describe pv static-file-share-pv-name
Name:            static-file-share-pv-name
Labels:          static-pv-label-key=static-pv-label-value
Annotations:     pv.kubernetes.io/provisioned-by: csi.vsphere.vmware.com
Finalizers:      [kubernetes.io/pv-protection]
StorageClass:    
Status:          Available
Claim:           
Reclaim Policy:  Retain
Access Modes:    RWX
VolumeMode:      Filesystem
Capacity:        1Gi
Node Affinity:   <none>
Message:         
Source:
    Type:              CSI (a Container Storage Interface (CSI) volume source)
    Driver:            csi.vsphere.vmware.com
    FSType:            
    VolumeHandle:      file:236b3e6b-cfb0-4b73-a271-2591b2f31b4c
    ReadOnly:          false
    VolumeAttributes:      type=vSphere CNS File Volume
Events:
  Type     Reason                             Age   From                Message
  ----     ------                             ----  ----                -------
  Warning  static volume provisioning failed  14s   VSphere CSI Syncer  Failed to identify VC for volume

On a single VC, gave wrong volume handle in static PV:

root@k8s-control-556-1702644001:~# kubectl describe pv 13-block-static-file-share-pv-name
Name:              13-block-static-file-share-pv-name
Labels:            static-pv-label-key=static-pv-label-value
Annotations:       pv.kubernetes.io/provisioned-by: csi.vsphere.vmware.com
Finalizers:        [kubernetes.io/pv-protection]
StorageClass:      
Status:            Available
Claim:             
Reclaim Policy:    Retain
Access Modes:      RWO
VolumeMode:        Filesystem
Capacity:          1Gi
Node Affinity:     
  Required Terms:  
    Term 0:        topology.csi.vmware.com/k8s-zone in [zone-2]
Message:           
Source:
    Type:              CSI (a Container Storage Interface (CSI) volume source)
    Driver:            csi.vsphere.vmware.com
    FSType:            
    VolumeHandle:      jkcns-jkncsk-3722
    ReadOnly:          false
    VolumeAttributes:      type=vSphere CNS File Volume
Events:
  Type     Reason                             Age   From                Message
  ----     ------                             ----  ----                -------
  Warning  static volume provisioning failed  63s   VSphere CSI Syncer  Failed to create volume on VC 10.212.239.36

Special notes for your reviewer:

Release note:

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 22, 2023
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 22, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @skogta. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 22, 2023
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 22, 2023
@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 22, 2023
@divyenpatel
Copy link
Member

/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 23, 2023
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.

Can you address review comments?

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 29, 2023
@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 29, 2023
@k8s-ci-robot k8s-ci-robot merged commit 2dd10a4 into kubernetes-sigs:master Dec 29, 2023
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants