kubernetes-sigs / vsphere-csi-driver

vSphere storage Container Storage Interface (CSI) plugin
https://docs.vmware.com/en/VMware-vSphere-Container-Storage-Plug-in/index.html
Apache License 2.0
293 stars 177 forks source link

Handle StoragePolicyUsageCR cleanup in StoragePolicyQuotaCR delete event #2837

Closed chethanv28 closed 5 months ago

chethanv28 commented 5 months ago

What this PR does / why we need it: Handle StoragePolicyUsageCR cleanup in StoragePolicyQuotaCR delete event

Testing done:

Before:

kubectl get storagepolicyusage  -n e2e-1
NAME                                              AGE
wcpglobal-storage-profile-pvc-usage               5m1s

# kubectl get storagepolicyquota  -n e2e-1
NAME                                           AGE
wcpglobal-storage-profile-storagepolicyquota   5m4s

Unassigned storage policy from vSphere UI:

Screenshot 2024-03-22 at 1 10 04 PM

Verify quota CR is deleted:

# kubectl get storagepolicyquota  -n e2e-1
No resources found in e2e-1 namespace.

Verify policy usage CR is deleted:

# kubectl get storagepolicyusage  -n e2e-1
No resources found in e2e-1 namespace.

CSI Syncer logs:

2024-03-22T19:59:31.436Z    INFO    syncer/metadatasyncer.go:2963   policyQuotaCRDeleted: StoragePolicyUsageCR instance "e2e-1"/"wcpglobal-storage-profile-pvc-usage" successfully deleted. {"TraceId": "c0f57cf4-1675-4446-a932-56aaa952ac91"}

Verification with 2 PolicyUsage CRs:

root@42086fb1a55bfb410b84d71d41e897ab [ ~ ]# kubectl get storagepolicyusage  -n e2e-1
NAME                                              AGE
wcpglobal-storage-profile-latebinding-pvc-usage   35m
wcpglobal-storage-profile-pvc-usage               35m

root@42086fb1a55bfb410b84d71d41e897ab [ ~ ]# kubectl get storagepolicyquota  -n e2e-1
NAME                                           AGE
wcpglobal-storage-profile-storagepolicyquota   35m

root@42086fb1a55bfb410b84d71d41e897ab [ ~ ]# kubectl get pods -n vmware-system-csi
NAME                                      READY   STATUS             RESTARTS   AGE
vsphere-csi-controller-6c4dbcb844-4js2p   7/7     Running            0          41s
vsphere-csi-controller-6c4dbcb844-qjk7q   7/7     Running            0          29s
vsphere-csi-controller-6c4dbcb844-x7rgq   7/7     Running            0          15s
vsphere-csi-webhook-6bf44d5786-28pkb      1/1     Running            0          82m
vsphere-csi-webhook-6bf44d5786-db4w8      1/1     Running            0          82m
vsphere-csi-webhook-7c8d4f6f74-bsxr2      1/1     Running   0          112s

After removing the policy from the namespace:

root@42086fb1a55bfb410b84d71d41e897ab [ ~ ]# kubectl get storagepolicyquota  -n e2e-1
No resources found in e2e-1 namespace.
root@42086fb1a55bfb410b84d71d41e897ab [ ~ ]# kubectl get storagepolicyusage  -n e2e-1
No resources found in e2e-1 namespace.

Logs:

2024-03-22T23:14:45.031Z    INFO    syncer/metadatasyncer.go:2947   policyQuotaCRDeleted: StoragePolicyUsageCR instance "e2e-1"/"wcpglobal-storage-profile-latebinding-pvc-usage" successfully deleted. {"TraceId": "f6c5a81b-332a-4502-be59-619d58e0ac5b"}
2024-03-22T23:14:45.046Z    INFO    syncer/metadatasyncer.go:2947   policyQuotaCRDeleted: StoragePolicyUsageCR instance "e2e-1"/"wcpglobal-storage-profile-pvc-usage" successfully deleted. {"TraceId": "f6c5a81b-332a-4502-be59-619d58e0ac5b"}

Special notes for your reviewer:

Release note:

Handle StoragePolicyUsageCR cleanup in StoragePolicyQuotaCR delete event
divyenpatel commented 5 months ago

@chethanv28 do we clean up storagequota CR status filed and remove policyQuotaUsage status for the policy Id for which storagepolicyquota CR is deleted?

divyenpatel commented 5 months ago

/ok-to-test

chethanv28 commented 5 months ago

@chethanv28 do we clean up storagequota CR status filed and remove policyQuotaUsage status for the policy Id for which storagepolicyquota CR is deleted?

CSI Syncer does not perform any updates on storagequota CR . I'm not sure if the status field cleanup is handled in StorageQuotaController repo.

@akankshapanse Can you answer this query ?

svcbot-qecnsdp commented 5 months ago

Started WCP block pre-checkin pipeline... Build Number: 6

svcbot-qecnsdp commented 5 months ago
Build ID: 6
WCP build status: SUCCESS 
Stage before exit: finally 
Jenkins E2E Test Results: 

Ran 1 of 816 Specs in 271.244 seconds
SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 815 Skipped
PASS

Ginkgo ran 1 suite in 5m35.032847777s
Test Suite Passed
make: Leaving directory `/home/worker/workspace/csi-wcp-precheckin_kavya/Results/6/vsphere-csi-driver`
svcbot-qecnsdp commented 5 months ago

Started WCP block pre-checkin pipeline... Build Number: 7

svcbot-qecnsdp commented 5 months ago
Build ID: 7
WCP build status: FAILURE 
Stage before exit: null 
Jenkins E2E Test Results: 
FAIL! -- 10 Passed | 44 Failed | 0 Pending | 762 Skipped
--- FAIL: TestE2E (3972.50s)
FAIL

Ginkgo ran 1 suite in 1h7m17.802685179s

Test Suite Failed
make: Leaving directory `/home/worker/workspace/csi-wcp-precheckin_kavya/Results/7/vsphere-csi-driver`
k8s-ci-robot commented 5 months ago

[APPROVALNOTIFIER] This PR is APPROVED

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

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: - ~~[OWNERS](https://github.com/kubernetes-sigs/vsphere-csi-driver/blob/master/OWNERS)~~ [chethanv28,divyenpatel] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
akankshapanse commented 5 months ago

e clean up storagequota CR status filed and remove policyQuota

storagequota CR status filed and remove policyQuotaUsage status for the policy Id for which storagepolicyquota CR is deleted will be done by Storage quota webhook