Skip to content

Commit

Permalink
Merge pull request #59 from petermicuch/restore_delete_folder_name
Browse files Browse the repository at this point in the history
Preserve name of the PV directory name during archiving
  • Loading branch information
k8s-ci-robot authored Mar 3, 2021
2 parents 6b7372c + 9b9ac9a commit a99f3da
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/nfs-subdir-external-provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit a99f3da

Please sign in to comment.