mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Merge pull request #31115 from jsafrane/add-constants
Automatic merge from submit-queue Add constants and documentation around AWS magic numbers Also, bumped max IOPS/GB to 50, it changed from 30 since last time I checked. Source: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html @kubernetes/sig-storage
This commit is contained in:
commit
49ff2e8831
@ -257,6 +257,13 @@ const (
|
|||||||
VolumeTypeST1 = "st1"
|
VolumeTypeST1 = "st1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AWS provisioning limits.
|
||||||
|
// Source: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html
|
||||||
|
const (
|
||||||
|
MinTotalIOPS = 100
|
||||||
|
MaxTotalIOPS = 20000
|
||||||
|
)
|
||||||
|
|
||||||
// VolumeOptions specifies capacity and tags for a volume.
|
// VolumeOptions specifies capacity and tags for a volume.
|
||||||
type VolumeOptions struct {
|
type VolumeOptions struct {
|
||||||
CapacityGB int
|
CapacityGB int
|
||||||
@ -265,8 +272,7 @@ type VolumeOptions struct {
|
|||||||
VolumeType string
|
VolumeType string
|
||||||
AvailabilityZone string
|
AvailabilityZone string
|
||||||
// IOPSPerGB x CapacityGB will give total IOPS of the volume to create.
|
// IOPSPerGB x CapacityGB will give total IOPS of the volume to create.
|
||||||
// IOPSPerGB must be bigger than zero and smaller or equal to 30.
|
// Calculated total IOPS will be capped at MaxTotalIOPS.
|
||||||
// Calculated total IOPS will be capped at 20000 IOPS.
|
|
||||||
IOPSPerGB int
|
IOPSPerGB int
|
||||||
Encrypted bool
|
Encrypted bool
|
||||||
// fully qualified resource name to the key to use for encryption.
|
// fully qualified resource name to the key to use for encryption.
|
||||||
@ -1545,17 +1551,19 @@ func (c *Cloud) CreateDisk(volumeOptions *VolumeOptions) (string, error) {
|
|||||||
createType = volumeOptions.VolumeType
|
createType = volumeOptions.VolumeType
|
||||||
|
|
||||||
case VolumeTypeIO1:
|
case VolumeTypeIO1:
|
||||||
// See http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateVolume.html for IOPS constraints
|
// See http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateVolume.html
|
||||||
if volumeOptions.IOPSPerGB <= 0 || volumeOptions.IOPSPerGB > 30 {
|
// for IOPS constraints. AWS will throw an error if IOPS per GB gets out
|
||||||
return "", fmt.Errorf("invalid iopsPerGB value %d, must be 0 < IOPSPerGB <= 30", volumeOptions.IOPSPerGB)
|
// of supported bounds, no need to check it here.
|
||||||
}
|
|
||||||
createType = volumeOptions.VolumeType
|
createType = volumeOptions.VolumeType
|
||||||
iops = int64(volumeOptions.CapacityGB * volumeOptions.IOPSPerGB)
|
iops = int64(volumeOptions.CapacityGB * volumeOptions.IOPSPerGB)
|
||||||
if iops < 100 {
|
|
||||||
iops = 100
|
// Cap at min/max total IOPS, AWS would throw an error if it gets too
|
||||||
|
// low/high.
|
||||||
|
if iops < MinTotalIOPS {
|
||||||
|
iops = MinTotalIOPS
|
||||||
}
|
}
|
||||||
if iops > 20000 {
|
if iops > MaxTotalIOPS {
|
||||||
iops = 20000
|
iops = MaxTotalIOPS
|
||||||
}
|
}
|
||||||
|
|
||||||
case "":
|
case "":
|
||||||
|
Loading…
Reference in New Issue
Block a user