Skip to content
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

Clean up empty parents on deletion when using subDir #763

Closed
jsalatiel opened this issue Sep 4, 2024 · 2 comments · Fixed by #770
Closed

Clean up empty parents on deletion when using subDir #763

jsalatiel opened this issue Sep 4, 2024 · 2 comments · Fixed by #770
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@jsalatiel
Copy link

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
@andyzhangx
Copy link
Member

/kind bug

@andyzhangx
Copy link
Member

@jsalatiel I would like to only delete root folder of subDir when OnDelete: DeleteRootSubDir since there is data loss concern: #855, and by default, root folder of subDir won't be deleted.

WIP PR: #876

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants