Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove condition on iopspergb key being mandatory for io1 volumes #1590

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,6 @@ func (d *controllerService) CreateVolume(ctx context.Context, req *csi.CreateVol
}
}

if volumeType == cloud.VolumeTypeIO1 {
if iopsPerGB == 0 {
return nil, status.Errorf(codes.InvalidArgument, "The parameter IOPSPerGB must be specified for io1 volumes")
}
}

if blockExpress && volumeType != cloud.VolumeTypeIO2 {
return nil, status.Errorf(codes.InvalidArgument, "Block Express is only supported on io2 volumes")
}
Expand Down
127 changes: 86 additions & 41 deletions pkg/driver/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ func TestCreateVolume(t *testing.T) {
},
},
{
name: "success with volume type io1",
name: "success with volume type io1 using iopsPerGB",
testFunc: func(t *testing.T) {
req := &csi.CreateVolumeRequest{
Name: "vol-test",
Expand Down Expand Up @@ -839,7 +839,49 @@ func TestCreateVolume(t *testing.T) {
},
},
{
name: "success with volume type io2",
name: "success with volume type io1 using iops",
testFunc: func(t *testing.T) {
req := &csi.CreateVolumeRequest{
Name: "vol-test",
CapacityRange: stdCapRange,
VolumeCapabilities: stdVolCap,
Parameters: map[string]string{
VolumeTypeKey: cloud.VolumeTypeIO1,
IopsKey: "5",
},
}

ctx := context.Background()

mockDisk := &cloud.Disk{
VolumeID: req.Name,
AvailabilityZone: expZone,
CapacityGiB: util.BytesToGiB(stdVolSize),
}

mockCtl := gomock.NewController(t)
defer mockCtl.Finish()

mockCloud := cloud.NewMockCloud(mockCtl)
mockCloud.EXPECT().CreateDisk(gomock.Eq(ctx), gomock.Eq(req.Name), gomock.Any()).Return(mockDisk, nil)

awsDriver := controllerService{
cloud: mockCloud,
inFlight: internal.NewInFlight(),
driverOptions: &DriverOptions{},
}

if _, err := awsDriver.CreateVolume(ctx, req); err != nil {
srvErr, ok := status.FromError(err)
if !ok {
t.Fatalf("Could not get error status code from error: %v", srvErr)
}
t.Fatalf("Unexpected error: %v", srvErr.Code())
}
},
},
{
name: "success with volume type io2 using iopsPerGB",
testFunc: func(t *testing.T) {
req := &csi.CreateVolumeRequest{
Name: "vol-test",
Expand Down Expand Up @@ -880,6 +922,48 @@ func TestCreateVolume(t *testing.T) {
}
},
},
{
name: "success with volume type io2 using iops",
testFunc: func(t *testing.T) {
req := &csi.CreateVolumeRequest{
Name: "vol-test",
CapacityRange: stdCapRange,
VolumeCapabilities: stdVolCap,
Parameters: map[string]string{
VolumeTypeKey: cloud.VolumeTypeIO2,
IopsKey: "5",
},
}

ctx := context.Background()

mockDisk := &cloud.Disk{
VolumeID: req.Name,
AvailabilityZone: expZone,
CapacityGiB: util.BytesToGiB(stdVolSize),
}

mockCtl := gomock.NewController(t)
defer mockCtl.Finish()

mockCloud := cloud.NewMockCloud(mockCtl)
mockCloud.EXPECT().CreateDisk(gomock.Eq(ctx), gomock.Eq(req.Name), gomock.Any()).Return(mockDisk, nil)

awsDriver := controllerService{
cloud: mockCloud,
inFlight: internal.NewInFlight(),
driverOptions: &DriverOptions{},
}

if _, err := awsDriver.CreateVolume(ctx, req); err != nil {
srvErr, ok := status.FromError(err)
if !ok {
t.Fatalf("Could not get error status code from error: %v", srvErr)
}
t.Fatalf("Unexpected error: %v", srvErr.Code())
}
},
},
{
name: "success with volume type sc1",
testFunc: func(t *testing.T) {
Expand Down Expand Up @@ -1521,45 +1605,6 @@ func TestCreateVolume(t *testing.T) {
checkExpectedErrorCode(t, err, codes.Aborted)
},
},
{
name: "fail with missing iopsPerGB parameter",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test to check for success when using io1/io2 volume with no iopsPerGb parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added 2 tests (one for io1, one for io2) to check for success when iops parameter is used instead of iopspergb.

testFunc: func(t *testing.T) {
req := &csi.CreateVolumeRequest{
Name: "vol-test",
CapacityRange: stdCapRange,
VolumeCapabilities: stdVolCap,
Parameters: map[string]string{
VolumeTypeKey: cloud.VolumeTypeIO1,
},
}

ctx := context.Background()

mockCtl := gomock.NewController(t)
defer mockCtl.Finish()

mockCloud := cloud.NewMockCloud(mockCtl)

awsDriver := controllerService{
cloud: mockCloud,
inFlight: internal.NewInFlight(),
driverOptions: &DriverOptions{},
}

_, err := awsDriver.CreateVolume(ctx, req)
if err == nil {
t.Fatalf("Expected CreateVolume to fail but got no error")
}

srvErr, ok := status.FromError(err)
if !ok {
t.Fatalf("Could not get error status code from error: %v", srvErr)
}
if srvErr.Code() != codes.InvalidArgument {
t.Fatalf("Expect InvalidArgument but got: %s", srvErr.Code())
}
},
},
{
name: "Fail with IdempotentParameterMismatch error",
testFunc: func(t *testing.T) {
Expand Down