Skip to content

Commit

Permalink
fix(controller): fail on validate volume caps when volume doesn't exists
Browse files Browse the repository at this point in the history
  • Loading branch information
paullaffitte committed Sep 23, 2020
1 parent c6085e1 commit ba8bed0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,19 @@ func (driver *Driver) ControllerGetCapabilities(ctx context.Context, req *csi.Co
// ValidateVolumeCapabilities checks whether the volume capabilities requested
// are supported.
func (driver *Driver) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) {
if len(req.GetVolumeId()) == 0 {
volumeID := req.GetVolumeId()
if len(volumeID) == 0 {
return nil, status.Error(codes.InvalidArgument, "cannot validate volume with empty ID")
}
if len(req.GetVolumeCapabilities()) == 0 {
return nil, status.Error(codes.InvalidArgument, "cannot validate volume without capabilities")
}
_, _, err := driver.dothillClient.ShowVolumes(volumeID)
if err != nil {
return nil, status.Error(codes.NotFound, "cannot validate volume not found")
}

err := driver.beginRoutine(&common.DriverCtx{
err = driver.beginRoutine(&common.DriverCtx{
Req: req,
})
defer driver.endRoutine()
Expand Down

0 comments on commit ba8bed0

Please sign in to comment.