kubernetes-csi/csi-driver-nfs

Volume directory doesnot get deleted in nfs server when Retained PV is deleted manually

navilg opened this issue · 1 comments

navilg commented

What happened:

A PVC and PV was created with ReclaimPolicy: Retain. When PVC was deleted, PV was retained as per policy. Later when PV was deleted manually with kubectl delete pv <pv-name>, PV is deleted in K8s, but the volume directory remains in NFS server for that PV.

What you expected to happen:

Later when PV is deleted manually in above scenario, The supporting volume directory in NFS should also be deleted unless ondelete: retain parameter is set.

How to reproduce it:

  1. Create a storage class with below definition:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: nfs-csi
mountOptions:
- nfsvers=4.1
parameters:
  onDelete: delete
  server: mynfsserver.io
  share: /var/nfs/k8s_pvs
provisioner: nfs.csi.k8s.io
reclaimPolicy: Retain
volumeBindingMode: Immediate
  1. Create a PVC using above storage class. It should create the PVC and PV bounded to it.
  2. Delete PVC. It should delete the PVC but should retain the PV.
  3. Login to NFS server and check share path, It should have volume directory for PV inside it.
  4. Delete PV. It should delete PV from Kubernetes.
  5. Login to NFS server again, The volume directory for PV will still be there even if PV is deleted in K8s.

Anything else we need to know?:

Environment:

  • CSI Driver version: v4.4.0
  • Kubernetes version (use kubectl version): 1.27.7
  • OS (e.g. from /etc/os-release): Ubuntu 22..04

if persistentVolumeReclaimPolicy: Retain is set on pv, then directory should not be deleted when pv is deleted, that's by k8s design