Skip to content

Commit

Permalink
pmem-csi-driver: idempotent removal of target dir in NodeUnpublishVolume
Browse files Browse the repository at this point in the history
If the target directory already was removed earlier, os.Remove returns
ErrNotExist, which must be ignored.

Found accidentally on Clear Linux during the "can mount again after
restart" test: there (and not on Fedora!) the target directory created
by the driver didn't survive the sudden power loss, and then
NodeUnpublishVolume failed.
  • Loading branch information
pohly committed May 20, 2020
1 parent 47de465 commit 23a59c5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/pmem-csi-driver/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,11 @@ func (ns *nodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
}
}

if err := os.Remove(targetPath); err != nil {
err = os.Remove(targetPath)
if err != nil && !errors.Is(err, os.ErrNotExist) {
return nil, status.Error(codes.Internal, "unexpected error while removing target path: "+err.Error())
}
klog.V(5).Infof("NodeUnpublishVolume: volume id:%s targetpath:%s has been removed with error: %v", req.VolumeId, targetPath, err)

if p.GetPersistency() == parameters.PersistencyEphemeral {
if _, err := ns.cs.DeleteVolume(ctx, &csi.DeleteVolumeRequest{VolumeId: vol.ID}); err != nil {
Expand Down

0 comments on commit 23a59c5

Please sign in to comment.