openebs-archive / dynamic-nfs-provisioner

Operator for dynamically provisioning an NFS server on any Kubernetes Persistent Volume. Also creates an NFS volume on the dynamically provisioned server for enabling Kubernetes RWX volumes.
Apache License 2.0
169 stars 58 forks source link

garbage collector not work as expected. #143

Open celiawa opened 2 years ago

celiawa commented 2 years ago

Describe the bug: A clear and concise description of what the bug is.

When the frontend PV and PVC are deleted, openebs nfs provisioner will do gc to remove the stale backend NFS resources every 5 mins. Refer to PR: https://github.com/openebs/dynamic-nfs-provisioner/pull/80 After adding debug log, found that when doing gc, the p.hook is undefined, so it did not enter the below brace to remove the finalizer, and the service, deployment and PVC are not deleted. https://github.com/openebs/dynamic-nfs-provisioner/blob/dbe24dc5607f1c187ff80af3236034061ee99e00/provisioner/helper_kernel_nfs_server.go#L526

image

From openebs-nfs-provisioner log, we can see the gc was triggered, and describe the service, deployment and backend PVC, there were deletingTimestamp in the manifest. I0829 12:11:23.270146 1 garbage_collector.go:119] Deleting stale resources for PV=pvc-71f5a361-47fa-442d-baf1-00865d7567d6 I0829 12:11:23.272453 1 helper_kernel_nfs_server.go:522] Volume pvc-71f5a361-47fa-442d-baf1-00865d7567d6 has been initialized with Service {kube-system/nfs-pvc-71f5a361-47fa-442d-baf1-00865d7567d6}. Initiating delete... I0829 12:11:23.301297 1 helper_kernel_nfs_server.go:403] Volume pvc-71f5a361-47fa-442d-baf1-00865d7567d6 has been initialized with Deployment:nfs-pvc-71f5a361-47fa-442d-baf1-00865d7567d6. Initiating delete... I0829 12:11:23.313493 1 helper_kernel_nfs_server.go:211] Volume pvc-71f5a361-47fa-442d-baf1-00865d7567d6 has been initialized with PVC {kube-system/nfs-pvc-71f5a361-47fa-442d-baf1-00865d7567d6} Initiating delete...

From this code in garbage_collector.go, no hook initialized https://github.com/openebs/dynamic-nfs-provisioner/blob/1f414468b8c53b974c5dddbe02357a6ceb97d3b9/provisioner/garbage_collector.go#L120 image

I added a fix like the below and built a new image. Verified that the service, deployment, and PVC can be deleted in GC. image

Environment details:

celiawa commented 2 years ago

Hi @mynktl , could you help look at this issue? Thanks!