Skip to content

Commit 393c669

Browse files
committed
pmem-csi-driver: idempotent removal of target dir in NodeUnpublishVolume
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.
1 parent 53c5e26 commit 393c669

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/pmem-csi-driver/nodeserver.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,11 @@ func (ns *nodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
418418
}
419419
}
420420

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

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

0 commit comments

Comments
 (0)