Skip to content

Commit

Permalink
Merge pull request #558 from ayberk/io2
Browse files Browse the repository at this point in the history
Add EBS IO2 support
  • Loading branch information
k8s-ci-robot authored Sep 12, 2020
2 parents 0297b9c + fd77e76 commit 9b33867
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 12 deletions.
14 changes: 7 additions & 7 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ The following CSI gRPC calls are implemented:
### CreateVolume Parameters
There are several optional parameters that could be passed into `CreateVolumeRequest.parameters` map:

| Parameters | Values | Default | Description |
|-----------------------------|----------------------------|----------|---------------------|
| "csi.storage.k8s.io/fsType" | xfs, ext2, ext3, ext4 | ext4 | File system type that will be formatted during volume creation |
| "type" | io1, gp2, sc1, st1,standard| gp2 | EBS volume type |
| "iopsPerGB" | | | I/O operations per second per GiB. Required when io1 volume type is specified |
| "encrypted" | | | Whether the volume should be encrypted or not. Valid values are "true" or "false" |
| "kmsKeyId" | | | The full ARN of the key to use when encrypting the volume. When not specified, the default KMS key is used |
| Parameters | Values | Default | Description |
|-----------------------------|-----------------------------------|----------|---------------------|
| "csi.storage.k8s.io/fsType" | xfs, ext2, ext3, ext4 | ext4 | File system type that will be formatted during volume creation |
| "type" | io1, io2, gp2, sc1, st1,standard | gp2 | EBS volume type |
| "iopsPerGB" | | | I/O operations per second per GiB. Required when io1 or io2 volume type is specified |
| "encrypted" | | | Whether the volume should be encrypted or not. Valid values are "true" or "false" |
| "kmsKeyId" | | | The full ARN of the key to use when encrypting the volume. When not specified, the default KMS key is used |

**Notes**:
* The parameters are case insensitive.
Expand Down
5 changes: 4 additions & 1 deletion pkg/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import (
const (
// VolumeTypeIO1 represents a provisioned IOPS SSD type of volume.
VolumeTypeIO1 = "io1"
// VolumeTypeIO2 represents a provisioned IOPS SSD type of volume.
VolumeTypeIO2 = "io2"
// VolumeTypeGP2 represents a general purpose SSD type of volume.
VolumeTypeGP2 = "gp2"
// VolumeTypeSC1 represents a cold HDD (sc1) type of volume.
Expand All @@ -51,6 +53,7 @@ const (
var (
ValidVolumeTypes = []string{
VolumeTypeIO1,
VolumeTypeIO2,
VolumeTypeGP2,
VolumeTypeSC1,
VolumeTypeST1,
Expand Down Expand Up @@ -237,7 +240,7 @@ func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions *
switch diskOptions.VolumeType {
case VolumeTypeGP2, VolumeTypeSC1, VolumeTypeST1, VolumeTypeStandard:
createType = diskOptions.VolumeType
case VolumeTypeIO1:
case VolumeTypeIO1, VolumeTypeIO2:
createType = diskOptions.VolumeType
iops = capacityGiB * int64(diskOptions.IOPSPerGB)
case "":
Expand Down
42 changes: 42 additions & 0 deletions pkg/driver/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,48 @@ func TestCreateVolume(t *testing.T) {
}
},
},
{
name: "success with volume type io2",
testFunc: func(t *testing.T) {
req := &csi.CreateVolumeRequest{
Name: "vol-test",
CapacityRange: stdCapRange,
VolumeCapabilities: stdVolCap,
Parameters: map[string]string{
VolumeTypeKey: cloud.VolumeTypeIO2,
IopsPerGBKey: "5",
},
}

ctx := context.Background()

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

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

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

awsDriver := controllerService{
cloud: mockCloud,
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
12 changes: 8 additions & 4 deletions tests/e2e/driver/ebs_csi_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"github.com/kubernetes-csi/external-snapshotter/v2/pkg/apis/volumesnapshot/v1beta1"
ebscsidriver "github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/driver"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
storagev1 "k8s.io/api/storage/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -126,19 +126,23 @@ func MinimumSizeForVolumeType(volumeType string) string {
return "1Gi"
case "io1":
return "4Gi"
case "io2":
return "4Gi"
case "standard":
return "10Gi"
default:
return "1Gi"
}
}

// IOPSPerGBForVolumeType returns 25 for io1 volumeType
// IOPSPerGBForVolumeType returns 25 io1 and io2 volume types
// Otherwise returns an empty string
func IOPSPerGBForVolumeType(volumeType string) string {
if volumeType == "io1" {
switch volumeType {
case "io1", "io2":
// Minimum disk size is 4, minimum IOPS is 100
return "25"
default:
return ""
}
return ""
}

0 comments on commit 9b33867

Please sign in to comment.