Skip to content

Commit dce0b55

Browse files
committed
Use StageTargetPath in NodePublishVolume
Adds the missing volume ID, target path and capabilities validations as well.
1 parent 9e22be7 commit dce0b55

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

mock/service/node.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,16 @@ func (s *service) NodePublishVolume(
103103
req *csi.NodePublishVolumeRequest) (
104104
*csi.NodePublishVolumeResponse, error) {
105105

106-
device, ok := req.PublishInfo["device"]
107-
if !ok {
108-
return nil, status.Error(
109-
codes.InvalidArgument,
110-
"publish volume info 'device' key required")
106+
if len(req.GetVolumeId()) == 0 {
107+
return nil, status.Error(codes.InvalidArgument, "Volume ID cannot be empty")
108+
}
109+
110+
if len(req.GetTargetPath()) == 0 {
111+
return nil, status.Error(codes.InvalidArgument, "Target Path cannot be empty")
112+
}
113+
114+
if req.GetVolumeCapability() == nil {
115+
return nil, status.Error(codes.InvalidArgument, "Volume Capability cannot be empty")
111116
}
112117

113118
s.volsRWL.Lock()
@@ -135,7 +140,7 @@ func (s *service) NodePublishVolume(
135140
}
136141

137142
// Publish the volume.
138-
v.Attributes[nodeMntPathKey] = device
143+
v.Attributes[nodeMntPathKey] = req.GetStagingTargetPath()
139144
s.vols[i] = v
140145

141146
return &csi.NodePublishVolumeResponse{}, nil

0 commit comments

Comments
 (0)