Fail fast if io2 iops to size ratio is too high

In AWS the ratio between volume IOPS and volume size must be at most 50,
otherwise volume will fail creating. See
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html,
specifically "_The maximum ratio of provisioned IOPS to requested volume size
(in GiB) is 50:1. For example, a 100 GiB volume can be provisioned with up to
5,000 IOPS._"

This commit adds the option of failing fast when creating a new cluster if the
ratio is higher than 50. Previously kops would send the API request to AWS, fail
and repeat until the timeout was reached.
This commit is contained in:
Vlad Ionescu 2018-11-06 13:08:40 +02:00
parent b2b07cf045
commit 098266e875
No known key found for this signature in database
GPG Key ID: 2D9C4486A1602F1C
1 changed files with 12 additions and 2 deletions

View File

@ -92,7 +92,10 @@ func (b *MasterVolumeBuilder) Build(c *fi.ModelBuilderContext) error {
switch kops.CloudProviderID(b.Cluster.Spec.CloudProvider) { switch kops.CloudProviderID(b.Cluster.Spec.CloudProvider) {
case kops.CloudProviderAWS: case kops.CloudProviderAWS:
b.addAWSVolume(c, name, volumeSize, zone, etcd, m, allMembers) err = b.addAWSVolume(c, name, volumeSize, zone, etcd, m, allMembers)
if err != nil {
return err
}
case kops.CloudProviderDO: case kops.CloudProviderDO:
b.addDOVolume(c, name, volumeSize, zone, etcd, m, allMembers) b.addDOVolume(c, name, volumeSize, zone, etcd, m, allMembers)
case kops.CloudProviderGCE: case kops.CloudProviderGCE:
@ -116,7 +119,7 @@ func (b *MasterVolumeBuilder) Build(c *fi.ModelBuilderContext) error {
return nil return nil
} }
func (b *MasterVolumeBuilder) addAWSVolume(c *fi.ModelBuilderContext, name string, volumeSize int32, zone string, etcd *kops.EtcdClusterSpec, m *kops.EtcdMemberSpec, allMembers []string) { func (b *MasterVolumeBuilder) addAWSVolume(c *fi.ModelBuilderContext, name string, volumeSize int32, zone string, etcd *kops.EtcdClusterSpec, m *kops.EtcdMemberSpec, allMembers []string) error {
volumeType := fi.StringValue(m.VolumeType) volumeType := fi.StringValue(m.VolumeType)
volumeIops := fi.Int32Value(m.VolumeIops) volumeIops := fi.Int32Value(m.VolumeIops)
switch volumeType { switch volumeType {
@ -160,9 +163,16 @@ func (b *MasterVolumeBuilder) addAWSVolume(c *fi.ModelBuilderContext, name strin
} }
if volumeType == "io1" { if volumeType == "io1" {
t.VolumeIops = i64(int64(volumeIops)) t.VolumeIops = i64(int64(volumeIops))
// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html
if float64(*t.VolumeIops)/float64(*t.SizeGB) > 50.0 {
return fmt.Errorf("volumeIops to volumeSize ratio must be lower than 50. For %s ratio is %f", *t.Name, float64(*t.VolumeIops)/float64(*t.SizeGB))
}
} }
c.AddTask(t) c.AddTask(t)
return nil
} }
func (b *MasterVolumeBuilder) addDOVolume(c *fi.ModelBuilderContext, name string, volumeSize int32, zone string, etcd *kops.EtcdClusterSpec, m *kops.EtcdMemberSpec, allMembers []string) { func (b *MasterVolumeBuilder) addDOVolume(c *fi.ModelBuilderContext, name string, volumeSize int32, zone string, etcd *kops.EtcdClusterSpec, m *kops.EtcdMemberSpec, allMembers []string) {