Clean up empty parents on deletion when using subDir
Closed this issue · 1 comments
What happened:
The subDir parameter provides great flexibility allowing the user to set the subDir to something one considers helpful.
The problem is that when subDir is set to some nested directory tree like for example:
subDir=${pvc.metadata.namespace}/${pvc.metadata.name}/
when all the volumes from namespace are deleted, you will still see in the storage the empty $namespace directory.
The problem is even bigger if the depth of the subdir is bigger, for example:
subDir=${pvc.metadata.namespace}/${pvc.metadata.name}/${pv.metadata.name}
If I delete all the volumes of that namespace I will have at least 2 empty directories inside the $namespace directory on the nfs share.
What you expected to happen:
When deleting a volume, the driver should check if its parent is empty ( and it is inside a level of subDir ) and if so delete it too.
How to reproduce it:
Use subDir=${pvc.metadata.namespace}/${pvc.metadata.name}/${pv.metadata.name}
Use this values.yaml
replicaCount: 1
persistence:
enabled: true
accessModes:
- ReadWriteMany
size: 1Gi
mariadb:
primary:
persistence:
size: 2Gi
and install wordpress to test it.
helm install wp oci://registry-1.docker.io/bitnamicharts/wordpress --namespace wp --create-namespace -f values.yml
Delete the wp namespace and check the remove NFS server, there will be several emptydirs under the wp folder.
Anything else we need to know?:
Environment:
- CSI Driver version: nfsplugin:v4.8.0
- Kubernetes version (use
kubectl version
): v1.30.3 - OS (e.g. from /etc/os-release): Flatcar Container Linux by Kinvolk 3815.2.2
- Kernel (e.g.
uname -a
):6.1.85-flatcar
/kind bug