Skip to content

Commit

Permalink
Merge pull request #198 from verult/block-createvolume
Browse files Browse the repository at this point in the history
Fail CreateVolume() when Block volume capability is requested
  • Loading branch information
k8s-ci-robot authored Dec 11, 2018
2 parents a7459e1 + 1e304ef commit fa02b89
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/gce-pd-csi-driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("CreateVolume Request Capacity is invalid: %v", err))
}

// TODO(#94): Validate volume capabilities
// TODO(#94): Validate AccessModes in VolumeCapabilities
for _, capability := range volumeCapabilities {
if blk := capability.GetBlock(); blk != nil {
// TODO(#64): Block volume support
return nil, status.Error(codes.Unimplemented, fmt.Sprintf("Block volume support is not yet implemented"))
}
}

// Apply Parameters (case-insensitive). We leave validation of
// the values to the cloud provider.
Expand Down
44 changes: 44 additions & 0 deletions pkg/gce-pd-csi-driver/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,50 @@ func TestCreateVolumeArguments(t *testing.T) {
},
},
},
{
name: "fail with block volume capability",
req: &csi.CreateVolumeRequest{
Name: name,
CapacityRange: stdCapRange,
VolumeCapabilities: []*csi.VolumeCapability{
{
AccessType: &csi.VolumeCapability_Block{
Block: &csi.VolumeCapability_BlockVolume{},
},
AccessMode: &csi.VolumeCapability_AccessMode{
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
},
},
},
expErrCode: codes.Unimplemented,
},
{
name: "fail with both mount and block volume capability",
req: &csi.CreateVolumeRequest{
Name: name,
CapacityRange: stdCapRange,
VolumeCapabilities: []*csi.VolumeCapability{
{
AccessType: &csi.VolumeCapability_Mount{
Mount: &csi.VolumeCapability_MountVolume{},
},
AccessMode: &csi.VolumeCapability_AccessMode{
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
},
{
AccessType: &csi.VolumeCapability_Block{
Block: &csi.VolumeCapability_BlockVolume{},
},
AccessMode: &csi.VolumeCapability_AccessMode{
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
},
},
},
expErrCode: codes.Unimplemented, // once block support is implemented, this error should be InvalidArgument
},
}

// Run test cases
Expand Down

0 comments on commit fa02b89

Please sign in to comment.