Merge pull request #12209 from tb365/bugfix/tb-bugfix-091401

fix(region): change aws disk iops
This commit is contained in:
Zexi Li
2021-09-14 16:15:14 +08:00
committed by GitHub
2 changed files with 20 additions and 18 deletions
+18 -2
View File
@@ -480,6 +480,22 @@ func (self *SRegion) resetDisk(diskId, snapshotId string) (string, error) {
return StrVal(ret.VolumeId), self.DeleteDisk(diskId)
}
// io1类型的卷需要指定IOPS参数,最大不超过32000。这里根据aws网站的建议值进行设置
// io2类型的卷需要指定IOPS参数,最大不超过64000。
// GenDiskIops Base 100, 卷每增加2G。IOPS增加1。最多到3000 iops
func GenDiskIops(diskType string, sizeGB int) int64 {
if diskType == api.STORAGE_IO1_SSD || diskType == api.STORAGE_IO2_SSD {
iops := int64(100 + sizeGB/2)
if iops < 3000 {
return iops
} else {
return 3000
}
}
return 0
}
func (self *SRegion) CreateDisk(zoneId string, category string, name string, sizeGb int, snapshotId string, desc string) (string, error) {
tagspec := TagSpec{ResourceType: "volume"}
tagspec.SetNameTag(name)
@@ -494,8 +510,8 @@ func (self *SRegion) CreateDisk(zoneId string, category string, name string, siz
params.SetSnapshotId(snapshotId)
}
if category == api.STORAGE_IO1_SSD || category == api.STORAGE_IO2_SSD {
params.SetIops(200)
if iops := GenDiskIops(category, sizeGb); iops > 0 {
params.SetIops(iops)
}
params.SetTagSpecifications([]*ec2.TagSpecification{ec2Tags})
+2 -16
View File
@@ -792,22 +792,8 @@ func (self *SRegion) CreateInstance(name string, image *SImage, instanceType str
}
}
// io1类型的卷需要指定IOPS参数。这里根据aws网站的建议值进行设置
// 卷每增加1G。IOPS增加50。最大不超过32000
if disk.Category == api.STORAGE_IO1_SSD {
iops := int64(disk.Size * 50)
if iops < 32000 {
ebs.SetIops(iops)
} else {
ebs.SetIops(32000)
}
} else if disk.Category == api.STORAGE_IO2_SSD {
iops := int64(disk.Size * 100)
if iops < 64000 {
ebs.SetIops(iops)
} else {
ebs.SetIops(64000)
}
if iops := GenDiskIops(disk.Category, disk.Size); iops > 0 {
ebs.SetIops(iops)
}
blockDevice := &ec2.BlockDeviceMapping{