Unverified Commit a99f3daf by Kubernetes Prow Robot Committed by GitHub

Merge pull request #59 from petermicuch/restore_delete_folder_name

Preserve name of the PV directory name during archiving
parents 6b7372c8 9b9ac9aa
...@@ -139,8 +139,8 @@ func (p *nfsProvisioner) Provision(ctx context.Context, options controller.Provi ...@@ -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 { func (p *nfsProvisioner) Delete(ctx context.Context, volume *v1.PersistentVolume) error {
path := volume.Spec.PersistentVolumeSource.NFS.Path path := volume.Spec.PersistentVolumeSource.NFS.Path
relativePath := strings.Replace(path, p.path, "", 1) basePath := filepath.Base(path)
oldPath := filepath.Join(mountPath, relativePath) oldPath := filepath.Join(mountPath, basePath)
if _, err := os.Stat(oldPath); os.IsNotExist(err) { if _, err := os.Stat(oldPath); os.IsNotExist(err) {
glog.Warningf("path %s does not exist, deletion skipped", oldPath) glog.Warningf("path %s does not exist, deletion skipped", oldPath)
...@@ -179,7 +179,7 @@ func (p *nfsProvisioner) Delete(ctx context.Context, volume *v1.PersistentVolume ...@@ -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) glog.V(4).Infof("archiving path %s to %s", oldPath, archivePath)
return os.Rename(oldPath, archivePath) return os.Rename(oldPath, archivePath)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment