Skip to content

Commit

Permalink
hostpath: Implement ValidateVolumeCapabilities
Browse files Browse the repository at this point in the history
This implements a basic version of ValidateVolumeCapabilities for
hostpath driver and removes this from the skip tests list in the e2e
tests.
  • Loading branch information
darkowlzz committed Feb 18, 2019
1 parent fd2e591 commit 90617d0
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 90617d0

Please sign in to comment.