Skip to content

Commit

Permalink
fix(node): check for empty devicePath (#344)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
apricote authored Dec 15, 2022
1 parent 6beac22 commit e10a680
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions driver/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e10a680

Please sign in to comment.