Skip to content

Conversation

@kolluria
Copy link
Contributor

@kolluria kolluria commented May 27, 2025

What this PR does / why we need it:

Enhances CNS Unregister Volume functionality by removing the dependency on the less reliable cns volume metadata and using the kubernetes cluster as the source of truth.

Testing done:

Environment

  • VMware vCenter Server
  • Release: 9.1.0.0
  • Version: 9.1.0.0
  • Build: 85717360
  • Type: vCenter Server with an embedded Platform Services Controller
  • Supervisor - v1.30.10+vmware.1-fips-vsc9.0.0.0-24719998

When volume is unused
{"level":"info","time":"2025-05-27T08:44:41.729993926Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:204","msg":"Reconciling CnsUnregisterVolume instance \"unregister-unused-vol\" from namespace \"default\". timeout \"1s\" seconds"}
{"level":"info","time":"2025-05-27T08:44:41.730211139Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:217","msg":"found PV: \"pvc-dc369d5e-1847-4852-837d-66dcd0c8e9b0\" for the volumd Id: \"f7766c13-e8a0-4f06-8a0f-04d571c82455\""}
{"level":"info","time":"2025-05-27T08:44:41.730384202Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:224","msg":"found PVC: \"unused-pvc\" in the namespace:\"unused-vol\" for the volumd Id: \"f7766c13-e8a0-4f06-8a0f-04d571c82455\""}
{"level":"info","time":"2025-05-27T08:44:41.780792112Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:269","msg":"Updated ReclaimPolicy on PV \"pvc-dc369d5e-1847-4852-837d-66dcd0c8e9b0\" to \"Retain\""}
{"level":"info","time":"2025-05-27T08:44:41.834154967Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:287","msg":"Deleted PVC \"unused-pvc\" in namespace \"unused-vol\""}
{"level":"info","time":"2025-05-27T08:44:41.847664247Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:304","msg":"Deleted PV \"pvc-dc369d5e-1847-4852-837d-66dcd0c8e9b0\""}
{"level":"info","time":"2025-05-27T08:44:42.332753073Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:320","msg":"Deleted CNS volume \"f7766c13-e8a0-4f06-8a0f-04d571c82455\" with deleteDisk set to false"}
{"level":"info","time":"2025-05-27T08:44:42.344265955Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:335","msg":"Successfully unregistered the volume on namespace: default"}

Result: volume got unregistered successfully

When volume is in use by a pod

{"level":"info","time":"2025-05-27T08:53:38.733115608Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:204","msg":"Reconciling CnsUnregisterVolume instance \"unregister-vol-used-by-pod\" from namespace \"default\". timeout \"32s\" seconds"}
{"level":"info","time":"2025-05-27T08:53:38.733205067Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:217","msg":"found PV: \"pvc-683be09c-11c7-4ca2-acae-a5a322a6f2c7\" for the volumd Id: \"9c17e37b-0598-4cb3-a087-58af7a5e7ea5\""}
{"level":"info","time":"2025-05-27T08:53:38.733222435Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:224","msg":"found PVC: \"vol-used-by-pod\" in the namespace:\"pod\" for the volumd Id: \"9c17e37b-0598-4cb3-a087-58af7a5e7ea5\""}
{"level":"error","time":"2025-05-27T08:53:38.74408916Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:244","msg":"cannot unregister the volume 9c17e37b-0598-4cb3-a087-58af7a5e7ea5 as it's in use by pod pod in namespace pod","stacktrace":"sigs.k8s.io/vsphere-csi-driver/v3/pkg/syncer/cnsoperator/controller/cnsunregistervolume.(*ReconcileCnsUnregisterVolume).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/pkg/syncer/cnsoperator/controller/cnsunregistervolume/cnsunregistervolume_controller.go:244\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:116\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:303\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:263\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:224"}
{"level":"info","time":"2025-05-27T08:54:10.754676608Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:204","msg":"Reconciling CnsUnregisterVolume instance \"unregister-vol-used-by-pod\" from namespace \"default\". timeout \"1m4s\" seconds"}
{"level":"info","time":"2025-05-27T08:54:10.754810877Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:217","msg":"found PV: \"pvc-683be09c-11c7-4ca2-acae-a5a322a6f2c7\" for the volumd Id: \"9c17e37b-0598-4cb3-a087-58af7a5e7ea5\""}
{"level":"info","time":"2025-05-27T08:54:10.754845035Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:224","msg":"found PVC: \"vol-used-by-pod\" in the namespace:\"pod\" for the volumd Id: \"9c17e37b-0598-4cb3-a087-58af7a5e7ea5\""}
{"level":"error","time":"2025-05-27T08:54:10.764394367Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:244","msg":"cannot unregister the volume 9c17e37b-0598-4cb3-a087-58af7a5e7ea5 as it's in use by pod pod in namespace pod","stacktrace":"sigs.k8s.io/vsphere-csi-driver/v3/pkg/syncer/cnsoperator/controller/cnsunregistervolume.(*ReconcileCnsUnregisterVolume).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/pkg/syncer/cnsoperator/controller/cnsunregistervolume/cnsunregistervolume_controller.go:244\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:116\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:303\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:263\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:224"}

Result: unregistration failed successfully

When volume is in use by a VM

{"level":"info","time":"2025-05-27T08:23:11.240141831Z","caller":"manager/init.go:190","msg":"Creating \"cnsunregistervolumes\" CRD","TraceId":"56bc153d-40dc-4898-b8e4-98e8d5514d7d"}
{"level":"info","time":"2025-05-27T08:23:11.270648747Z","caller":"kubernetes/kubernetes.go:515","msg":"\"cnsunregistervolumes.cns.vmware.com\" CRD created successfully","TraceId":"56bc153d-40dc-4898-b8e4-98e8d5514d7d"}
{"level":"info","time":"2025-05-27T08:23:16.290268958Z","caller":"manager/init.go:197","msg":"\"cnsunregistervolumes\" CRD is created successfully","TraceId":"239dc0d3-bea9-4266-937f-05c89206c23b"}
{"level":"info","time":"2025-05-27T08:23:16.416484069Z","caller":"controller/controller.go:175","msg":"Starting EventSource","TraceId":"56bc153d-40dc-4898-b8e4-98e8d5514d7d","controller":"cnsunregistervolume-controller","source":"kind source: *v1alpha1.CnsUnregisterVolume"}
{"level":"info","time":"2025-05-27T08:23:16.416705284Z","caller":"controller/controller.go:183","msg":"Starting Controller","TraceId":"56bc153d-40dc-4898-b8e4-98e8d5514d7d","controller":"cnsunregistervolume-controller"}
{"level":"info","time":"2025-05-27T08:23:16.526642827Z","caller":"controller/controller.go:217","msg":"Starting workers","TraceId":"56bc153d-40dc-4898-b8e4-98e8d5514d7d","controller":"cnsunregistervolume-controller","worker count":40}
{"level":"info","time":"2025-05-27T08:25:07.011441681Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:204","msg":"Reconciling CnsUnregisterVolume instance \"unregister-vol-used-by-vm-svc-vm\" from namespace \"default\". timeout \"1s\" seconds"}
{"level":"info","time":"2025-05-27T08:25:07.01222132Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:217","msg":"found PV: \"pvc-98224a00-c39e-4a37-8ccb-26858d5952ac\" for the volumd Id: \"bbeff293-afa3-46cc-ae48-a6a01701d317\""}
{"level":"info","time":"2025-05-27T08:25:07.012504569Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:224","msg":"found PVC: \"vol-used-by-vm-svc-vm\" in the namespace:\"vm-svc-vm\" for the volumd Id: \"bbeff293-afa3-46cc-ae48-a6a01701d317\""}
{"level":"error","time":"2025-05-27T08:25:07.052735355Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:244","msg":"cannot unregister the volume bbeff293-afa3-46cc-ae48-a6a01701d317 as it's in use by VirtualMachine vm in namespace vm-svc-vm","stacktrace":"sigs.k8s.io/vsphere-csi-driver/v3/pkg/syncer/cnsoperator/controller/cnsunregistervolume.(*ReconcileCnsUnregisterVolume).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/pkg/syncer/cnsoperator/controller/cnsunregistervolume/cnsunregistervolume_controller.go:244\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:116\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:303\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:263\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:224"}
{"level":"info","time":"2025-05-27T08:25:07.068109961Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:204","msg":"Reconciling CnsUnregisterVolume instance \"unregister-vol-used-by-vm-svc-vm\" from namespace \"default\". timeout \"2s\" seconds"}
{"level":"info","time":"2025-05-27T08:25:07.068162352Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:217","msg":"found PV: \"pvc-98224a00-c39e-4a37-8ccb-26858d5952ac\" for the volumd Id: \"bbeff293-afa3-46cc-ae48-a6a01701d317\""}
{"level":"info","time":"2025-05-27T08:25:07.068177436Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:224","msg":"found PVC: \"vol-used-by-vm-svc-vm\" in the namespace:\"vm-svc-vm\" for the volumd Id: \"bbeff293-afa3-46cc-ae48-a6a01701d317\""}
{"level":"error","time":"2025-05-27T08:25:07.103688872Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:244","msg":"cannot unregister the volume bbeff293-afa3-46cc-ae48-a6a01701d317 as it's in use by VirtualMachine vm in namespace vm-svc-vm","stacktrace":"sigs.k8s.io/vsphere-csi-driver/v3/pkg/syncer/cnsoperator/controller/cnsunregistervolume.(*ReconcileCnsUnregisterVolume).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/pkg/syncer/cnsoperator/controller/cnsunregistervolume/cnsunregistervolume_controller.go:244\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:116\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:303\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:263\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:224"}
{"level":"info","time":"2025-05-27T08:25:08.068014605Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:204","msg":"Reconciling CnsUnregisterVolume instance \"unregister-vol-used-by-vm-svc-vm\" from namespace \"default\". timeout \"4s\" seconds"}
{"level":"info","time":"2025-05-27T08:25:08.068090953Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:217","msg":"found PV: \"pvc-98224a00-c39e-4a37-8ccb-26858d5952ac\" for the volumd Id: \"bbeff293-afa3-46cc-ae48-a6a01701d317\""}
{"level":"info","time":"2025-05-27T08:25:08.06810906Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:224","msg":"found PVC: \"vol-used-by-vm-svc-vm\" in the namespace:\"vm-svc-vm\" for the volumd Id: \"bbeff293-afa3-46cc-ae48-a6a01701d317\""}
{"level":"error","time":"2025-05-27T08:25:08.095787498Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:244","msg":"cannot unregister the volume bbeff293-afa3-46cc-ae48-a6a01701d317 as it's in use by VirtualMachine vm in namespace vm-svc-vm","stacktrace":"sigs.k8s.io/vsphere-csi-driver/v3/pkg/syncer/cnsoperator/controller/cnsunregistervolume.(*ReconcileCnsUnregisterVolume).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/pkg/syncer/cnsoperator/controller/cnsunregistervolume/cnsunregistervolume_controller.go:244\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:116\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:303\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:263\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:224"}
{"level":"info","time":"2025-05-27T08:25:12.107919091Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:204","msg":"Reconciling CnsUnregisterVolume instance \"unregister-vol-used-by-vm-svc-vm\" from namespace \"default\". timeout \"8s\" seconds"}
{"level":"info","time":"2025-05-27T08:25:12.10798796Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:217","msg":"found PV: \"pvc-98224a00-c39e-4a37-8ccb-26858d5952ac\" for the volumd Id: \"bbeff293-afa3-46cc-ae48-a6a01701d317\""}
{"level":"info","time":"2025-05-27T08:25:12.108001074Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:224","msg":"found PVC: \"vol-used-by-vm-svc-vm\" in the namespace:\"vm-svc-vm\" for the volumd Id: \"bbeff293-afa3-46cc-ae48-a6a01701d317\""}
{"level":"error","time":"2025-05-27T08:25:12.138648937Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:244","msg":"cannot unregister the volume bbeff293-afa3-46cc-ae48-a6a01701d317 as it's in use by VirtualMachine vm in namespace vm-svc-vm","stacktrace":"sigs.k8s.io/vsphere-csi-driver/v3/pkg/syncer/cnsoperator/controller/cnsunregistervolume.(*ReconcileCnsUnregisterVolume).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/pkg/syncer/cnsoperator/controller/cnsunregistervolume/cnsunregistervolume_controller.go:244\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:116\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:303\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:263\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:224"}
{"level":"info","time":"2025-05-27T08:25:20.156342608Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:204","msg":"Reconciling CnsUnregisterVolume instance \"unregister-vol-used-by-vm-svc-vm\" from namespace \"default\". timeout \"16s\" seconds"}
{"level":"info","time":"2025-05-27T08:25:20.156531749Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:217","msg":"found PV: \"pvc-98224a00-c39e-4a37-8ccb-26858d5952ac\" for the volumd Id: \"bbeff293-afa3-46cc-ae48-a6a01701d317\""}
{"level":"info","time":"2025-05-27T08:25:20.156544495Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:224","msg":"found PVC: \"vol-used-by-vm-svc-vm\" in the namespace:\"vm-svc-vm\" for the volumd Id: \"bbeff293-afa3-46cc-ae48-a6a01701d317\""}
{"level":"error","time":"2025-05-27T08:25:20.199193522Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:244","msg":"cannot unregister the volume bbeff293-afa3-46cc-ae48-a6a01701d317 as it's in use by VirtualMachine vm in namespace vm-svc-vm","stacktrace":"sigs.k8s.io/vsphere-csi-driver/v3/pkg/syncer/cnsoperator/controller/cnsunregistervolume.(*ReconcileCnsUnregisterVolume).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/pkg/syncer/cnsoperator/controller/cnsunregistervolume/cnsunregistervolume_controller.go:244\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:116\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:303\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:263\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:224"}
{"level":"info","time":"2025-05-27T08:25:36.212811381Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:204","msg":"Reconciling CnsUnregisterVolume instance \"unregister-vol-used-by-vm-svc-vm\" from namespace \"default\". timeout \"32s\" seconds"}
{"level":"info","time":"2025-05-27T08:25:36.212885555Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:217","msg":"found PV: \"pvc-98224a00-c39e-4a37-8ccb-26858d5952ac\" for the volumd Id: \"bbeff293-afa3-46cc-ae48-a6a01701d317\""}
{"level":"info","time":"2025-05-27T08:25:36.212899273Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:224","msg":"found PVC: \"vol-used-by-vm-svc-vm\" in the namespace:\"vm-svc-vm\" for the volumd Id: \"bbeff293-afa3-46cc-ae48-a6a01701d317\""}
{"level":"error","time":"2025-05-27T08:25:36.249968556Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:244","msg":"cannot unregister the volume bbeff293-afa3-46cc-ae48-a6a01701d317 as it's in use by VirtualMachine vm in namespace vm-svc-vm","stacktrace":"sigs.k8s.io/vsphere-csi-driver/v3/pkg/syncer/cnsoperator/controller/cnsunregistervolume.(*ReconcileCnsUnregisterVolume).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/pkg/syncer/cnsoperator/controller/cnsunregistervolume/cnsunregistervolume_controller.go:244\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:116\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:303\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:263\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:224"}

Result: unregistration failed successfully

When a volume is created from TKC but not used by a pod

{"level":"info","time":"2025-05-27T09:30:50.479224951Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:204","msg":"Reconciling CnsUnregisterVolume instance \"vol-used-by-tkc\" from namespace \"default\". timeout \"1s\" seconds"}
{"level":"info","time":"2025-05-27T09:30:50.482062429Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:217","msg":"found PV: \"pvc-3db4ac70-bf5e-4a19-9a60-78f580accf09\" for the volumd Id: \"db05cb2f-b53a-4317-b79b-8621cd4d9cea\""}
{"level":"info","time":"2025-05-27T09:30:50.482079062Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:224","msg":"found PVC: \"d68819ea-df5a-4f62-a1dd-6c49b0dcb14f-e5b83788-6d37-4742-a5da-92e9dbd7faf6\" in the namespace:\"guest-cluster\" for the volumd Id: \"db05cb2f-b53a-4317-b79b-8621cd4d9cea\""}
{"level":"info","time":"2025-05-27T09:30:50.598124071Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:269","msg":"Updated ReclaimPolicy on PV \"pvc-3db4ac70-bf5e-4a19-9a60-78f580accf09\" to \"Retain\""}
{"level":"info","time":"2025-05-27T09:30:50.664432341Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:287","msg":"Deleted PVC \"d68819ea-df5a-4f62-a1dd-6c49b0dcb14f-e5b83788-6d37-4742-a5da-92e9dbd7faf6\" in namespace \"guest-cluster\""}
{"level":"info","time":"2025-05-27T09:30:50.696156895Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:304","msg":"Deleted PV \"pvc-3db4ac70-bf5e-4a19-9a60-78f580accf09\""}
{"level":"info","time":"2025-05-27T09:30:51.232430534Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:320","msg":"Deleted CNS volume \"db05cb2f-b53a-4317-b79b-8621cd4d9cea\" with deleteDisk set to false"}
{"level":"info","time":"2025-05-27T09:30:51.249122137Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:335","msg":"Successfully unregistered the volume on namespace: default"}

Result: volume got unregistered successfully

When volume is created from TKC and is in use by a TKC pod

{"level":"info","time":"2025-05-29T08:33:41.895093225Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:205","msg":"Reconciling CnsUnregisterVolume instance \"vol-used-by-tkc-pod\" from namespace \"default\". timeout \"32s\" seconds"}
{"level":"info","time":"2025-05-29T08:33:41.895170935Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:218","msg":"found PV: \"pvc-4a020fc3-3e33-45b9-a4c4-dc5098b78d2b\" for the volumd Id: \"f56c1651-9f6a-48c7-a93b-edac381e49a1\""}
{"level":"info","time":"2025-05-29T08:33:41.895184404Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:225","msg":"found PVC: \"d68819ea-df5a-4f62-a1dd-6c49b0dcb14f-d22b1ae1-3b90-4c36-8d7a-0e1b958c6bae\" in the namespace:\"guest-cluster\" for the volumd Id: \"f56c1651-9f6a-48c7-a93b-edac381e49a1\""}
{"level":"error","time":"2025-05-29T08:33:41.929406698Z","caller":"cnsunregistervolume/cnsunregistervolume_controller.go:245","msg":"cannot unregister the volume f56c1651-9f6a-48c7-a93b-edac381e49a1 as it's in use by VirtualMachine tkg-np-2-hx25j-5kcks-lrrml in namespace guest-cluster","stacktrace":"sigs.k8s.io/vsphere-csi-driver/v3/pkg/syncer/cnsoperator/controller/cnsunregistervolume.(*ReconcileCnsUnregisterVolume).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/pkg/syncer/cnsoperator/controller/cnsunregistervolume/cnsunregistervolume_controller.go:245\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:116\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:303\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:263\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/Users/vsatyanaraya/src/github.com/vsphere-csi-driver/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:224"}

Result: unregistration failed successfully

**Special notes for your reviewer**:

Release note:

Enhance CNS Unregister Volume API to refer to K8s metadata instead of CNS metadata

@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 May 27, 2025
@k8s-ci-robot k8s-ci-robot requested a review from chethanv28 May 27, 2025 10:49
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 27, 2025
@k8s-ci-robot k8s-ci-robot requested a review from deepakkinni May 27, 2025 10:49
@k8s-ci-robot
Copy link
Contributor

Hi @kolluria. 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-sigs/prow 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 27, 2025
@kolluria kolluria marked this pull request as ready for review May 29, 2025 09:56
@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 May 29, 2025
@kolluria kolluria changed the title fix cnsunregister API to not use CNS metadata Enhance CNS Unregister Volume API to refer to K8s metadata instead of CNS metadata May 29, 2025
@kolluria kolluria force-pushed the fix-cns-unregister-volume branch from f3f5cb7 to 4edb6df Compare May 29, 2025 10:20
@gnufied
Copy link
Contributor

gnufied commented May 29, 2025

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

[APPROVALNOTIFIER] This PR is APPROVED

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

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 May 29, 2025
@k8s-ci-robot k8s-ci-robot merged commit 3e91b50 into kubernetes-sigs:master May 29, 2025
12 checks passed
@kolluria kolluria deleted the fix-cns-unregister-volume branch May 30, 2025 06:50
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/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.

4 participants