Skip to content

Commit 0590ad0

Browse files
committed
Use StageTargetPath in NodePublishVolume
Adds the missing volume ID, target path and capabilities validations as well.
1 parent 7349b5a commit 0590ad0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

mock/service/node.go

+17-1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ func (s *service) NodePublishVolume(
110110
"publish volume info 'device' key required")
111111
}
112112

113+
if len(req.GetVolumeId()) == 0 {
114+
return nil, status.Error(codes.InvalidArgument, "Volume ID cannot be empty")
115+
}
116+
117+
if len(req.GetTargetPath()) == 0 {
118+
return nil, status.Error(codes.InvalidArgument, "Target Path cannot be empty")
119+
}
120+
121+
if req.GetVolumeCapability() == nil {
122+
return nil, status.Error(codes.InvalidArgument, "Volume Capability cannot be empty")
123+
}
124+
113125
s.volsRWL.Lock()
114126
defer s.volsRWL.Unlock()
115127

@@ -135,7 +147,11 @@ func (s *service) NodePublishVolume(
135147
}
136148

137149
// Publish the volume.
138-
v.Attributes[nodeMntPathKey] = device
150+
if req.GetStagingTargetPath() != "" {
151+
v.Attributes[nodeMntPathKey] = req.GetStagingTargetPath()
152+
} else {
153+
v.Attributes[nodeMntPathKey] = device
154+
}
139155
s.vols[i] = v
140156

141157
return &csi.NodePublishVolumeResponse{}, nil

0 commit comments

Comments
 (0)