Skip to content

Commit

Permalink
Merge pull request #5 from darkowlzz/hostpath-validatevolumecaps
Browse files Browse the repository at this point in the history
hostpath: Implement ValidateVolumeCapabilities
  • Loading branch information
k8s-ci-robot authored Feb 21, 2019
2 parents fd2e591 + 90617d0 commit c44a77d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
3 changes: 0 additions & 3 deletions hack/e2e-hostpath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ CSI_MOUNTPOINT="/mnt"
APP=hostpathplugin

SKIP="WithCapacity"
if [ x${TRAVIS} = x"true" ] ; then
SKIP="ValidateVolumeCapabilities"
fi

# Get csi-sanity
./hack/get-sanity.sh
Expand Down
30 changes: 29 additions & 1 deletion pkg/hostpath/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,35 @@ func (cs *controllerServer) ControllerGetCapabilities(ctx context.Context, req *
}

func (cs *controllerServer) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) {
return nil, status.Error(codes.Unimplemented, "")

// Check arguments
if len(req.GetVolumeId()) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume ID cannot be empty")
}
if len(req.VolumeCapabilities) == 0 {
return nil, status.Error(codes.InvalidArgument, req.VolumeId)
}

if _, err := getVolumeByID(req.GetVolumeId()); err != nil {
return nil, status.Error(codes.NotFound, req.GetVolumeId())
}

for _, cap := range req.GetVolumeCapabilities() {
if cap.GetMount() == nil && cap.GetBlock() == nil {
return nil, status.Error(codes.InvalidArgument, "cannot have both mount and block access type be undefined")
}

// A real driver would check the capabilities of the given volume with
// the set of requested capabilities.
}

return &csi.ValidateVolumeCapabilitiesResponse{
Confirmed: &csi.ValidateVolumeCapabilitiesResponse_Confirmed{
VolumeContext: req.GetVolumeContext(),
VolumeCapabilities: req.GetVolumeCapabilities(),
Parameters: req.GetParameters(),
},
}, nil
}

func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error) {
Expand Down

0 comments on commit c44a77d

Please sign in to comment.