fix: remove stale archived volume copy before Rename
This commit is contained in:
parent
b6b606e48e
commit
1f40750905
@ -252,8 +252,11 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// archive subdirectory under base-dir
|
// archive subdirectory under base-dir, remove stale archived copy if exists.
|
||||||
klog.V(2).Infof("archiving subdirectory %s --> %s", internalVolumePath, archivedInternalVolumePath)
|
klog.V(2).Infof("archiving subdirectory %s --> %s", internalVolumePath, archivedInternalVolumePath)
|
||||||
|
if err = os.RemoveAll(archivedInternalVolumePath); err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to delete archived subdirectory %s: %v", archivedInternalVolumePath, err.Error())
|
||||||
|
}
|
||||||
if err = os.Rename(internalVolumePath, archivedInternalVolumePath); err != nil {
|
if err = os.Rename(internalVolumePath, archivedInternalVolumePath); err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err.Error())
|
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user