diff --git a/driver/node.go b/driver/node.go index 0a430f2dc..55f5174a3 100644 --- a/driver/node.go +++ b/driver/node.go @@ -25,6 +25,7 @@ limitations under the License. package driver import ( + "net/http" "context" "path/filepath" @@ -266,6 +267,15 @@ func (d *Driver) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublish }) ll.Info("node unpublish volume called") + // TODO(treimann): Add a test to https://github.com/kubernetes-csi/csi-test/blob/master/pkg/sanity/node.go + _, resp, err := d.storage.GetVolume(ctx, req.VolumeId) + if err != nil { + if resp != nil && resp.StatusCode == http.StatusNotFound { + return nil, status.Errorf(codes.NotFound, "volume %q not found", req.VolumeId) + } + return nil, status.Errorf(codes.Internal, "failed to get volume %q: %s", req.VolumeId, err) + } + mounted, err := d.mounter.IsMounted(req.TargetPath) if err != nil { return nil, err