fix: NodeUnpublishVolume should be idempotent
In case the NodeUnpublishVolume procedure was aborted after unmounting the volume, a repeated call will return an error like "Volume not mounted". Instead of returning the error, log a message and return success to indicate that the volume is not mounted anymore.
This commit is contained in:
parent
9aeed81815
commit
a59837abe1
@ -139,7 +139,8 @@ func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
if notMnt {
|
||||
return nil, status.Error(codes.NotFound, "Volume not mounted")
|
||||
klog.V(2).Infof("NodeUnpublishVolume: Targetpath %s of volumeID(%s) is not mounted", targetPath, volumeID)
|
||||
return &csi.NodeUnpublishVolumeResponse{}, nil
|
||||
}
|
||||
|
||||
klog.V(2).Infof("NodeUnpublishVolume: CleanupMountPoint %s on volumeID(%s)", targetPath, volumeID)
|
||||
|
||||
@ -189,9 +189,8 @@ func TestNodeUnpublishVolume(t *testing.T) {
|
||||
expectedErr: status.Error(codes.Internal, "fake IsLikelyNotMountPoint: fake error"),
|
||||
},
|
||||
{
|
||||
desc: "[Error] Volume not mounted",
|
||||
req: csi.NodeUnpublishVolumeRequest{TargetPath: targetFile, VolumeId: "vol_1"},
|
||||
expectedErr: status.Error(codes.NotFound, "Volume not mounted"),
|
||||
desc: "[Success] Volume not mounted",
|
||||
req: csi.NodeUnpublishVolumeRequest{TargetPath: targetFile, VolumeId: "vol_1"},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user