From 9b9ac9aa8df26230f868eddbaed272cf2800983f Mon Sep 17 00:00:00 2001 From: Peter Micuch Date: Thu, 25 Feb 2021 10:10:50 +0100 Subject: [PATCH] Preserve name of the PV directory name during archiving --- cmd/nfs-subdir-external-provisioner/provisioner.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/nfs-subdir-external-provisioner/provisioner.go b/cmd/nfs-subdir-external-provisioner/provisioner.go index 67bc5977..4f2ec6a9 100644 --- a/cmd/nfs-subdir-external-provisioner/provisioner.go +++ b/cmd/nfs-subdir-external-provisioner/provisioner.go @@ -139,8 +139,8 @@ func (p *nfsProvisioner) Provision(ctx context.Context, options controller.Provi func (p *nfsProvisioner) Delete(ctx context.Context, volume *v1.PersistentVolume) error { path := volume.Spec.PersistentVolumeSource.NFS.Path - relativePath := strings.Replace(path, p.path, "", 1) - oldPath := filepath.Join(mountPath, relativePath) + basePath := filepath.Base(path) + oldPath := filepath.Join(mountPath, basePath) if _, err := os.Stat(oldPath); os.IsNotExist(err) { glog.Warningf("path %s does not exist, deletion skipped", oldPath) @@ -179,7 +179,7 @@ func (p *nfsProvisioner) Delete(ctx context.Context, volume *v1.PersistentVolume } } - archivePath := filepath.Join(mountPath, "archived-"+volume.Name) + archivePath := filepath.Join(mountPath, "archived-"+basePath) glog.V(4).Infof("archiving path %s to %s", oldPath, archivePath) return os.Rename(oldPath, archivePath) }