Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit 55fda9d

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 70fa3e8 commit 55fda9d

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)