From e10a680e23744256d3fe8457d6db297ac537fced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Thu, 15 Dec 2022 10:44:06 +0100 Subject: [PATCH] fix(node): check for empty devicePath (#344) When the VolumeAttachment was created with v1.6.0 (or older) it has an empty publish context and we run into a cryptic error during mount. We should always check that the device path is set in the publish context. This will improve the error message for one of the bugs encountered in #278. --- driver/node.go | 3 +++ driver/node_test.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/driver/node.go b/driver/node.go index f3ca8534..8ec2478c 100644 --- a/driver/node.go +++ b/driver/node.go @@ -58,6 +58,9 @@ func (s *NodeService) NodePublishVolume(ctx context.Context, req *proto.NodePubl } devicePath := req.GetPublishContext()["devicePath"] + if devicePath == "" { + return nil, status.Error(codes.InvalidArgument, "missing device path") + } var opts volumes.MountOpts switch { diff --git a/driver/node_test.go b/driver/node_test.go index e292c704..89432dc5 100644 --- a/driver/node_test.go +++ b/driver/node_test.go @@ -135,6 +135,9 @@ func TestNodeServiceNodePublishPublishError(t *testing.T) { }, }, }, + PublishContext: map[string]string{ + "devicePath": "devpath", + }, }) if grpc.Code(err) != codes.Internal { t.Fatalf("unexpected error: %v", err)