Skip deletion if the corresponding directory is not found
This commit is contained in:
		
							parent
							
								
									ec6a216177
								
							
						
					
					
						commit
						9debe1e4d3
					
				|  | @ -96,6 +96,10 @@ func (p *nfsProvisioner) Delete(volume *v1.PersistentVolume) error { | ||||||
| 	path := volume.Spec.PersistentVolumeSource.NFS.Path | 	path := volume.Spec.PersistentVolumeSource.NFS.Path | ||||||
| 	pvName := filepath.Base(path) | 	pvName := filepath.Base(path) | ||||||
| 	oldPath := filepath.Join(mountPath, pvName) | 	oldPath := filepath.Join(mountPath, pvName) | ||||||
|  | 	if _, err := os.Stat(oldPath); os.IsNotExist(err) { | ||||||
|  | 		glog.Warningf("path %s does not exist, deletion skipped", oldPath) | ||||||
|  | 		return nil | ||||||
|  | 	} | ||||||
| 	archivePath := filepath.Join(mountPath, "archived-"+pvName) | 	archivePath := filepath.Join(mountPath, "archived-"+pvName) | ||||||
| 	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) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue