-
Notifications
You must be signed in to change notification settings - Fork 176
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
Delete volume requests are sent twice with new sig-storage-lib-external-provisioner v10.0.1 because of the finalizer "external-provisioner.volume.kubernetes.io/finalizer" #176
Comments
@zjuliuf you would need latest k8s release to verify the fix, such as 1.28.12. |
@Jainbrt Thanks a lot, I will try. By the way, which PR of k8s fixed this issue? |
@Jainbrt I watched the status of the PV, its status was changed to 'Released' from 'Bound' without 'Failed'. |
is this the issue you are talking about kubernetes-csi/external-provisioner#1184 ? |
@Jainbrt Looks like the same problem. |
In order to reduce redundant deletion processes when 'addFinalizer' is true, can we modify the code like below? In the codes below, If only the DeletionTimestamp and Finalizers of pv change, the pv will not be added to the queue.
|
same problem occurs in my production environment |
What events did the provisioner receive and who / what caused them? You can either get a diff in UpdateFunc in the provisioner or get it from the API server audit logs. It looks like something is racy here. I would prefer to see what causes these events before we start ignoring them. |
Hi - I've been investigating this issue because we've also been seeing it in the EBS CSI Driver. Our driver is correctly idempotent, but these requets result in a lot of extra unnecessary API spam when deleting volumes - based on our testing this issue will occur on roughly one third of volume deletions. This issue is called by the When the PV finalizer is enabled, we first removes the finalizer and then deletes the volume (after it successfully deletes a volume through the provisioner). That first change - removing the finalizer, triggers an additional update to the volume that goes through |
@jsafrane
{"kind":"Event","apiVersion":"audit.k8s.io/v1","level":"RequestResponse","auditID":"65a49e9a-f9b4-4bfb-856b-4f0700dfdea4","stage":"ResponseComplete","requestURI":"/api/v1/persistentvolumes/pvc-7109fd69-f0c9-41c5-812d-6b2f391b43e6","verb":"delete","user":{"username":"system:serviceaccount:kube-system:csiaddon-csi-controller","uid":"4f8bc8ab-2833-4660-ad30-258d6753a4b2","groups":["system:serviceaccounts","system:serviceaccounts:kube-system","system:authenticated"],"extra":{"authentication.kubernetes.io/pod-name":["csiaddon-csi-controller-57bbc79b79-6zkrp"],"authentication.kubernetes.io/pod-uid":["0222bfdd-d5e9-416b-b0c5-e7530712aa36"]}},"sourceIPs":["192.168.227.211"],"userAgent":"csiaddon-csi-controller/v0.0.0 (linux/amd64) kubernetes/$Format/csiaddon-csi-provisioner","objectRef":{"resource":"persistentvolumes","name":"pvc-7109fd69-f0c9-41c5-812d-6b2f391b43e6","apiVersion":"v1"},"responseStatus":{"metadata":{},"code":200},"requestObject":{"kind":"DeleteOptions","apiVersion":"meta.k8s.io/__internal"},"responseObject":{"kind":"PersistentVolume","apiVersion":"v1","metadata":{"name":"pvc-7109fd69-f0c9-41c5-812d-6b2f391b43e6","uid":"5d4cbfe5-7376-4823-b2d2-4cbcabdcf95a","resourceVersion":"1538004","creationTimestamp":"2024-11-13T12:26:16Z","deletionTimestamp":"2024-11-13T12:32:18Z","deletionGracePeriodSeconds":0,"labels":{"failure-domain.beta.kubernetes.io/region":"fake-az","failure-domain.beta.kubernetes.io/zone":"fake-region"},"annotations":{"pv.kubernetes.io/provisioned-by":"csiaddon-csi-provisioner"},"finalizers":["external-provisioner.volume.kubernetes.io/finalizer","kubernetes.io/pv-protection"],"managedFields":[{"manager":"csiaddon-csi-controller","operation":"Update","apiVersion":"v1","time":"2024-11-13T12:26:16Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:pv.kubernetes.io/provisioned-by":{}},"f:finalizers":{".":{},"v:"external-provisioner.volume.kubernetes.io/finalizer"":{}},"f:labels":{".":{},"f:failure-domain.beta.kubernetes.io/region":{},"f:failure-domain.beta.kubernetes.io/zone":{}}},"f:spec":{"f:accessModes":{},"f:capacity":{".":{},"f:storage":{}},"f:claimRef":{".":{},"f:apiVersion":{},"f:kind":{},"f:name":{},"f:namespace":{},"f:resourceVersion":{},"f:uid":{}},"f:csi":{".":{},"f:driver":{},"f:fsType":{},"f:volumeAttributes":{".":{},"f:csiaddon.io/disk-mode":{},"f:csiaddon.io/disk-volume-type":{},"f:csiaddon.io/enterprise-project-id":{},"f:storage.kubernetes.io/csiProvisionerIdentity":{}},"f:volumeHandle":{}},"f:nodeAffinity":{".":{},"f:required":{}},"f:persistentVolumeReclaimPolicy":{},"f:storageClassName":{},"f:volumeMode":{}}}},{"manager":"kube-controller-manager","operation":"Update","apiVersion":"v1","time":"2024-11-13T12:32:18Z","fieldsType":"FieldsV1","fieldsV1":{"f:status":{"f:phase":{}}},"subresource":"status"}]},"spec":{"capacity":{"storage":"10Gi"},"csi":{"driver":"disk.csi.csiaddon.io","volumeHandle":"1ec53b26-a8d6-4ab9-8e29-97d3f8172952","fsType":"ext4","volumeAttributes":{"csiaddon.io/disk-mode":"SCSI","csiaddon.io/disk-volume-type":"SAS","csiaddon.io/enterprise-project-id":"0","storage.kubernetes.io/csiProvisionerIdentity":"csiaddon-csi-provisioner"}},"accessModes":["ReadWriteOnce"],"claimRef":{"kind":"PersistentVolumeClaim","namespace":"default","name":"disk-18","uid":"7109fd69-f0c9-41c5-812d-6b2f391b43e6","apiVersion":"v1","resourceVersion":"1536629"},"persistentVolumeReclaimPolicy":"Delete","storageClassName":"csi-disk","volumeMode":"Filesystem","nodeAffinity":{"required":{"nodeSelectorTerms":[{"matchExpressions":[{"key":"failure-domain.beta.kubernetes.io/zone","operator":"In","values":["fake-region"]}]}]}}},"status":{"phase":"Released"}},"requestReceivedTimestamp":"2024-11-13T12:32:18.597415Z","stageTimestamp":"2024-11-13T12:32:18.601982Z","annotations":{"authorization.k8s.io/decision":"allow","authorization.k8s.io/reason":"RBAC: allowed by ClusterRoleBinding "system:csiaddon-csi-controller" of ClusterRole "system:csiaddon-csi-controller" to ServiceAccount "csiaddon-csi-controller/kube-system""}}
{"kind":"Event","apiVersion":"audit.k8s.io/v1","level":"RequestResponse","auditID":"6fdcc98d-c924-499b-911b-9b2113944a22","stage":"ResponseComplete","requestURI":"/api/v1/persistentvolumes/pvc-7109fd69-f0c9-41c5-812d-6b2f391b43e6","verb":"patch","user":{"username":"system:serviceaccount:kube-system:csiaddon-csi-controller","uid":"4f8bc8ab-2833-4660-ad30-258d6753a4b2","groups":["system:serviceaccounts","system:serviceaccounts:kube-system","system:authenticated"],"extra":{"authentication.kubernetes.io/pod-name":["csiaddon-csi-controller-57bbc79b79-6zkrp"],"authentication.kubernetes.io/pod-uid":["0222bfdd-d5e9-416b-b0c5-e7530712aa36"]}},"sourceIPs":["192.168.227.211"],"userAgent":"csiaddon-csi-controller/v0.0.0 (linux/amd64) kubernetes/$Format/csiaddon-csi-provisioner","objectRef":{"resource":"persistentvolumes","name":"pvc-7109fd69-f0c9-41c5-812d-6b2f391b43e6","apiVersion":"v1"},"responseStatus":{"metadata":{},"code":200},"requestObject":{"metadata":{"$deleteFromPrimitiveList/finalizers":["external-provisioner.volume.kubernetes.io/finalizer"],"$setElementOrder/finalizers":["kubernetes.io/pv-protection"]}},"responseObject":{"kind":"PersistentVolume","apiVersion":"v1","metadata":{"name":"pvc-7109fd69-f0c9-41c5-812d-6b2f391b43e6","uid":"5d4cbfe5-7376-4823-b2d2-4cbcabdcf95a","resourceVersion":"1538006","creationTimestamp":"2024-11-13T12:26:16Z","deletionTimestamp":"2024-11-13T12:32:18Z","deletionGracePeriodSeconds":0,"labels":{"failure-domain.beta.kubernetes.io/region":"fake-az","failure-domain.beta.kubernetes.io/zone":"fake-region"},"annotations":{"pv.kubernetes.io/provisioned-by":"csiaddon-csi-provisioner"},"finalizers":["kubernetes.io/pv-protection"],"managedFields":[{"manager":"csiaddon-csi-controller","operation":"Update","apiVersion":"v1","time":"2024-11-13T12:26:16Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:pv.kubernetes.io/provisioned-by":{}},"f:finalizers":{},"f:labels":{".":{},"f:failure-domain.beta.kubernetes.io/region":{},"f:failure-domain.beta.kubernetes.io/zone":{}}},"f:spec":{"f:accessModes":{},"f:capacity":{".":{},"f:storage":{}},"f:claimRef":{".":{},"f:apiVersion":{},"f:kind":{},"f:name":{},"f:namespace":{},"f:resourceVersion":{},"f:uid":{}},"f:csi":{".":{},"f:driver":{},"f:fsType":{},"f:volumeAttributes":{".":{},"f:csiaddon.io/disk-mode":{},"f:csiaddon.io/disk-volume-type":{},"f:csiaddon.io/enterprise-project-id":{},"f:storage.kubernetes.io/csiProvisionerIdentity":{}},"f:volumeHandle":{}},"f:nodeAffinity":{".":{},"f:required":{}},"f:persistentVolumeReclaimPolicy":{},"f:storageClassName":{},"f:volumeMode":{}}}},{"manager":"kube-controller-manager","operation":"Update","apiVersion":"v1","time":"2024-11-13T12:32:18Z","fieldsType":"FieldsV1","fieldsV1":{"f:status":{"f:phase":{}}},"subresource":"status"}]},"spec":{"capacity":{"storage":"10Gi"},"csi":{"driver":"disk.csi.csiaddon.io","volumeHandle":"1ec53b26-a8d6-4ab9-8e29-97d3f8172952","fsType":"ext4","volumeAttributes":{"csiaddon.io/disk-mode":"SCSI","csiaddon.io/disk-volume-type":"SAS","csiaddon.io/enterprise-project-id":"0","storage.kubernetes.io/csiProvisionerIdentity":"csiaddon-csi-provisioner"}},"accessModes":["ReadWriteOnce"],"claimRef":{"kind":"PersistentVolumeClaim","namespace":"default","name":"disk-18","uid":"7109fd69-f0c9-41c5-812d-6b2f391b43e6","apiVersion":"v1","resourceVersion":"1536629"},"persistentVolumeReclaimPolicy":"Delete","storageClassName":"csi-disk","volumeMode":"Filesystem","nodeAffinity":{"required":{"nodeSelectorTerms":[{"matchExpressions":[{"key":"failure-domain.beta.kubernetes.io/zone","operator":"In","values":["fake-region"]}]}]}}},"status":{"phase":"Released"}},"requestReceivedTimestamp":"2024-11-13T12:32:18.603383Z","stageTimestamp":"2024-11-13T12:32:18.609903Z","annotations":{"authorization.k8s.io/decision":"allow","authorization.k8s.io/reason":"RBAC: allowed by ClusterRoleBinding "system:csiaddon-csi-controller" of ClusterRole "system:csiaddon-csi-controller" to ServiceAccount "csiaddon-csi-controller/kube-system""}}
{"kind":"Event","apiVersion":"audit.k8s.io/v1","level":"RequestResponse","auditID":"03f766a9-31b7-487b-ae98-2895f38e0611","stage":"ResponseComplete","requestURI":"/api/v1/persistentvolumes/pvc-7109fd69-f0c9-41c5-812d-6b2f391b43e6","verb":"update","user":{"username":"system:serviceaccount:kube-system:pv-protection-controller","uid":"5dde667f-551d-4530-859f-c0086439e06a","groups":["system:serviceaccounts","system:serviceaccounts:kube-system","system:authenticated"]},"sourceIPs":["192.168.99.16"],"userAgent":"kube-controller-manager/v1.28.15 (linux/amd64) kubernetes/79252b8/system:serviceaccount:kube-system:pv-protection-controller","objectRef":{"resource":"persistentvolumes","name":"pvc-7109fd69-f0c9-41c5-812d-6b2f391b43e6","uid":"5d4cbfe5-7376-4823-b2d2-4cbcabdcf95a","apiVersion":"v1","resourceVersion":"1538006"},"responseStatus":{"metadata":{},"code":200},"requestObject":{"kind":"PersistentVolume","apiVersion":"v1","metadata":{"name":"pvc-7109fd69-f0c9-41c5-812d-6b2f391b43e6","uid":"5d4cbfe5-7376-4823-b2d2-4cbcabdcf95a","resourceVersion":"1538006","creationTimestamp":"2024-11-13T12:26:16Z","deletionTimestamp":"2024-11-13T12:32:18Z","deletionGracePeriodSeconds":0,"labels":{"failure-domain.beta.kubernetes.io/region":"fake-az","failure-domain.beta.kubernetes.io/zone":"fake-region"},"annotations":{"pv.kubernetes.io/provisioned-by":"csiaddon-csi-provisioner"},"managedFields":[{"manager":"csiaddon-csi-controller","operation":"Update","apiVersion":"v1","time":"2024-11-13T12:26:16Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:pv.kubernetes.io/provisioned-by":{}},"f:finalizers":{},"f:labels":{".":{},"f:failure-domain.beta.kubernetes.io/region":{},"f:failure-domain.beta.kubernetes.io/zone":{}}},"f:spec":{"f:accessModes":{},"f:capacity":{".":{},"f:storage":{}},"f:claimRef":{".":{},"f:apiVersion":{},"f:kind":{},"f:name":{},"f:namespace":{},"f:resourceVersion":{},"f:uid":{}},"f:csi":{".":{},"f:driver":{},"f:fsType":{},"f:volumeAttributes":{".":{},"f:csiaddon.io/disk-mode":{},"f:csiaddon.io/disk-volume-type":{},"f:csiaddon.io/enterprise-project-id":{},"f:storage.kubernetes.io/csiProvisionerIdentity":{}},"f:volumeHandle":{}},"f:nodeAffinity":{".":{},"f:required":{}},"f:persistentVolumeReclaimPolicy":{},"f:storageClassName":{},"f:volumeMode":{}}}},{"manager":"kube-controller-manager","operation":"Update","apiVersion":"v1","time":"2024-11-13T12:32:18Z","fieldsType":"FieldsV1","fieldsV1":{"f:status":{"f:phase":{}}},"subresource":"status"}]},"spec":{"capacity":{"storage":"10Gi"},"csi":{"driver":"disk.csi.csiaddon.io","volumeHandle":"1ec53b26-a8d6-4ab9-8e29-97d3f8172952","fsType":"ext4","volumeAttributes":{"csiaddon.io/disk-mode":"SCSI","csiaddon.io/disk-volume-type":"SAS","csiaddon.io/enterprise-project-id":"0","storage.kubernetes.io/csiProvisionerIdentity":"csiaddon-csi-provisioner"}},"accessModes":["ReadWriteOnce"],"claimRef":{"kind":"PersistentVolumeClaim","namespace":"default","name":"disk-18","uid":"7109fd69-f0c9-41c5-812d-6b2f391b43e6","apiVersion":"v1","resourceVersion":"1536629"},"persistentVolumeReclaimPolicy":"Delete","storageClassName":"csi-disk","volumeMode":"Filesystem","nodeAffinity":{"required":{"nodeSelectorTerms":[{"matchExpressions":[{"key":"failure-domain.beta.kubernetes.io/zone","operator":"In","values":["fake-region"]}]}]}}},"status":{"phase":"Released"}},"responseObject":{"kind":"PersistentVolume","apiVersion":"v1","metadata":{"name":"pvc-7109fd69-f0c9-41c5-812d-6b2f391b43e6","uid":"5d4cbfe5-7376-4823-b2d2-4cbcabdcf95a","resourceVersion":"1538006","creationTimestamp":"2024-11-13T12:26:16Z","deletionTimestamp":"2024-11-13T12:32:18Z","deletionGracePeriodSeconds":0,"labels":{"failure-domain.beta.kubernetes.io/region":"fake-az","failure-domain.beta.kubernetes.io/zone":"fake-region"},"annotations":{"pv.kubernetes.io/provisioned-by":"csiaddon-csi-provisioner"},"managedFields":[{"manager":"csiaddon-csi-controller","operation":"Update","apiVersion":"v1","time":"2024-11-13T12:26:16Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:pv.kubernetes.io/provisioned-by":{}},"f:labels":{".":{},"f:failure-domain.beta.kubernetes.io/region":{},"f:failure-domain.beta.kubernetes.io/zone":{}}},"f:spec":{"f:accessModes":{},"f:capacity":{".":{},"f:storage":{}},"f:claimRef":{".":{},"f:apiVersion":{},"f:kind":{},"f:name":{},"f:namespace":{},"f:resourceVersion":{},"f:uid":{}},"f:csi":{".":{},"f:driver":{},"f:fsType":{},"f:volumeAttributes":{".":{},"f:csiaddon.io/disk-mode":{},"f:csiaddon.io/disk-volume-type":{},"f:csiaddon.io/enterprise-project-id":{},"f:storage.kubernetes.io/csiProvisionerIdentity":{}},"f:volumeHandle":{}},"f:nodeAffinity":{".":{},"f:required":{}},"f:persistentVolumeReclaimPolicy":{},"f:storageClassName":{},"f:volumeMode":{}}}},{"manager":"kube-controller-manager","operation":"Update","apiVersion":"v1","time":"2024-11-13T12:32:18Z","fieldsType":"FieldsV1","fieldsV1":{"f:status":{"f:phase":{}}},"subresource":"status"}]},"spec":{"capacity":{"storage":"10Gi"},"csi":{"driver":"disk.csi.csiaddon.io","volumeHandle":"1ec53b26-a8d6-4ab9-8e29-97d3f8172952","fsType":"ext4","volumeAttributes":{"csiaddon.io/disk-mode":"SCSI","csiaddon.io/disk-volume-type":"SAS","csiaddon.io/enterprise-project-id":"0","storage.kubernetes.io/csiProvisionerIdentity":"csiaddon-csi-provisioner"}},"accessModes":["ReadWriteOnce"],"claimRef":{"kind":"PersistentVolumeClaim","namespace":"default","name":"disk-18","uid":"7109fd69-f0c9-41c5-812d-6b2f391b43e6","apiVersion":"v1","resourceVersion":"1536629"},"persistentVolumeReclaimPolicy":"Delete","storageClassName":"csi-disk","volumeMode":"Filesystem","nodeAffinity":{"required":{"nodeSelectorTerms":[{"matchExpressions":[{"key":"failure-domain.beta.kubernetes.io/zone","operator":"In","values":["fake-region"]}]}]}}},"status":{"phase":"Released"}},"requestReceivedTimestamp":"2024-11-13T12:32:18.641532Z","stageTimestamp":"2024-11-13T12:32:18.645094Z","annotations":{"authorization.k8s.io/decision":"allow","authorization.k8s.io/reason":"RBAC: allowed by ClusterRoleBinding "system:controller:pv-protection-controller" of ClusterRole "system:controller:pv-protection-controller" to ServiceAccount "pv-protection-controller/kube-system""}} Added some print logs to the provisioner as follows because of the events of pv, after the volume was successfully deleted, the function UpdateFunc was executed twice more first time: ===> this time caused the second time deleting volume because there was still finalizer "external-provisioner.volume.kubernetes.io/finalizer" second time: |
What happened:
When we try to delete volume using new new sig-storage-lib-external-provisioner v10.0.1, we still notice 2 or more volume deletion requests in the logs. As a result of which PV deleting costs more time.
What you expected to happen:
Only 1 volume deletion request during the pv deletion.
Simple analysis:
When volume related to the PV was deleted successfully, sig-storage-lib-external-provisioner begins to Delete PV,then PV object was updated with a deletionTimestamp, so that the PV was added to volumeQueue, then exec deleteVolumeOperation again because the finalizer "external-provisioner.volume.kubernetes.io/finalizer" exists. finally, 2 or more volume deletion requests was sent during the pv deletion.
Below is the code analysis:
(first time deletion) function 'shouldDelete' returns true ---> ctrl.provisioner.Delete deletes volume related to the PV ---> ctrl.client.CoreV1().PersistentVolumes().Delete deletes PV ---> PV was updated with adding deletionTimestamp ---> try to remove finalizer "external-provisioner.volume.kubernetes.io/finalizer"
(second time deletion) During the first time deletion, when PV was updated with adding deletionTimestamp(before removing finalizer), the PV was added to the volumeQueue again. Then the second time deletion began. Becuase the finalizer "external-provisioner.volume.kubernetes.io/finalizer" still existed and the PV status was Released, so the function 'shouldDelete' still returned 'true' and executed ctrl.provisioner.Delete again.
How to reproduce it:
Call NewProvisionController with an option AddFinalizer(true)
Create a storageclass and PVC
Delete PVC
Notice the status of PV and logs of provisioner
Environment:
Driver version:
Kubernetes version (use kubectl version): v1.28
OS (e.g. from /etc/os-release):
Kernel (e.g. uname -a):
Install tools:
Others: sig-storage-lib-external-provisioner v10.0.1
The text was updated successfully, but these errors were encountered: