Skip to content

enhance clean up of CNSVolumeOperations instances to delete instances with latest TaskInvocationTimestamp older than 15 minutes #3375

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

Conversation

divyenpatel
Copy link
Member

@divyenpatel divyenpatel commented Jun 27, 2025

What this PR does / why we need it:

With the current code, Clean-up of CNSVolumeOperations CR is happening every 24 hours, but if CSI controller does not remain stable for 24 hours, and restarted then this 24 hour cycle starts again.

This PR is changing DefaultCnsVolumeOperationRequestCleanupIntervalInMin to 15 minutes, instead of 24hours.

During the cleanup, CR instances with latest task invocation timestamp with 15 minutes prior are deleted.

Testing done:

Verified Instance with latest Task Invocation Timestamp within 15 minutes is preserved.

# kubectl describe cnsvolumeoperationrequests.cns.vmware.com -n vmware-system-csi
Name:         pvc-f1c5f77e-48cf-401a-939f-c4194f477553
Namespace:    vmware-system-csi
Labels:       <none>
Annotations:  <none>
API Version:  cns.vmware.com/v1alpha1
Kind:         CnsVolumeOperationRequest
Metadata:
  Creation Timestamp:  2025-06-28T05:17:22Z
  Generation:          3
  Resource Version:    5964336
  UID:                 1e0d0d9b-8a4e-4ec4-8538-5dde2b156140
Spec:
  Name:  pvc-f1c5f77e-48cf-401a-939f-c4194f477553
Status:
  First Operation Details:
    Op Id:                      36953eb9
    Task Id:                    task-4572
    Task Invocation Timestamp:  2025-06-28T05:17:22Z
    Task Status:                Success
  Latest Operation Details:
    Op Id:                      36953eb9
    Task Id:                    task-4572
    Task Invocation Timestamp:  2025-06-28T05:17:22Z
    Task Status:                Success
  Quota Details:
    Namespace:           divyen-ns
    Reserved:            0
    Storage Class Name:  zonal-policy
    Storage Policy Id:   7286abc5-880a-41e8-950b-6332f2e84d34
  Volume ID:             f1c5f77e-48cf-401a-939f-c4194f477553
Events:                  <none>

# kubectl get cnsvolumeoperationrequests.cns.vmware.com -A
NAMESPACE           NAME                                       AGE
vmware-system-csi   pvc-f1c5f77e-48cf-401a-939f-c4194f477553   14m

Logs

2025-06-28T05:22:10.926Z	DEBUG	cnsvolumeoperationrequest/cnsvolumeoperationrequest.go:382	CnsVolumeOperationRequest instance "pvc-f1c5f77e-48cf-401a-939f-c4194f477553" is skipped for deletion	{"TraceId": "c7e5f48b-1099-4f49-9c77-80b2aee272d0"}
2025-06-28T05:33:10.833Z	INFO	cnsvolumeoperationrequest/cnsvolumeoperationrequest.go:385	Calling DeleteRequestDetails for: pvc-f1c5f77e-48cf-401a-939f-c4194f477553	{"TraceId": "c7e5f48b-1099-4f49-9c77-80b2aee272d0"}
2025-06-28T05:33:10.833Z	DEBUG	cnsvolumeoperationrequest/cnsvolumeoperationrequest.go:336	Deleting CnsVolumeOperationRequest instance with name vmware-system-csi/pvc-f1c5f77e-48cf-401a-939f-c4194f477553	{"TraceId": "c7e5f48b-1099-4f49-9c77-80b2aee272d0"}
2025-06-28T05:33:10.845Z	INFO	cnsvolumeoperationrequest/cnsvolumeoperationrequest.go:391	CnsVolumeOperationRequest instance "pvc-f1c5f77e-48cf-401a-939f-c4194f477553" is deleted	{"TraceId": "c7e5f48b-1099-4f49-9c77-80b2aee272d0"}
2025-06-28T05:33:10.846Z	INFO	cnsvolumeoperationrequest/cnsvolumeoperationrequest.go:393	Clean up of stale CnsVolumeOperationRequest complete.	{"TraceId": "c7e5f48b-1099-4f49-9c77-80b2aee272d0"}

Special notes for your reviewer:

Release note:

enhance clean up of CNSVolumeOperations instances to delete instances with latest TaskInvocationTimestamp older than 15 minutes

@divyenpatel divyenpatel requested a review from deepakkinni June 27, 2025 22:38
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 27, 2025
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 27, 2025
@divyenpatel divyenpatel changed the title enhance clean up of CNSVolumeOperations instances [WIP] enhance clean up of CNSVolumeOperations instances Jun 28, 2025
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 28, 2025
@divyenpatel divyenpatel force-pushed the CNSVolumeOperations-cleanupStaleInstances-fix branch 2 times, most recently from ee42c4f to cd6b8ac Compare June 28, 2025 05:23
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 28, 2025
@divyenpatel divyenpatel changed the title [WIP] enhance clean up of CNSVolumeOperations instances enhance clean up of CNSVolumeOperations instances to delete instances with latest TaskInvocationTimestamp older than 15 minutes Jun 28, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 28, 2025
@divyenpatel divyenpatel force-pushed the CNSVolumeOperations-cleanupStaleInstances-fix branch from cd6b8ac to 2872a9a Compare June 28, 2025 05:37
…OperationRequest instances

with latest TaskInvocationTimestamp older than 15 minutes
@divyenpatel divyenpatel force-pushed the CNSVolumeOperations-cleanupStaleInstances-fix branch from 2872a9a to e3adcfb Compare June 30, 2025 22:42
@deepakkinni
Copy link
Collaborator

/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 Jul 1, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deepakkinni, 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 [deepakkinni,divyenpatel]

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 merged commit 4cd6fa5 into kubernetes-sigs:master Jul 1, 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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants