mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-07-29 19:42:45 +00:00
only save/use iops for io1 volumes
Signed-off-by: Steve Kriss <steve@heptio.com>
This commit is contained in:
@@ -111,7 +111,7 @@ type VolumeBackupInfo struct {
|
||||
|
||||
// Iops is the optional value of provisioned IOPS for the
|
||||
// disk/volume in the cloud provider API.
|
||||
Iops *int `json:"iops"`
|
||||
Iops *int `json:"iops,omitempty"`
|
||||
}
|
||||
|
||||
// +genclient=true
|
||||
|
||||
@@ -21,6 +21,8 @@ import (
|
||||
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
|
||||
"github.com/heptio/ark/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
@@ -31,6 +33,11 @@ type blockStorageAdapter struct {
|
||||
az string
|
||||
}
|
||||
|
||||
// iopsVolumeTypes is a set of AWS EBS volume types for which IOPS should
|
||||
// be captured during snapshot and provided when creating a new volume
|
||||
// from snapshot.
|
||||
var iopsVolumeTypes = sets.NewString("io1")
|
||||
|
||||
func (op *blockStorageAdapter) CreateVolumeFromSnapshot(snapshotID, volumeType string, iops *int) (volumeID string, err error) {
|
||||
req := &ec2.CreateVolumeInput{
|
||||
SnapshotId: &snapshotID,
|
||||
@@ -38,7 +45,7 @@ func (op *blockStorageAdapter) CreateVolumeFromSnapshot(snapshotID, volumeType s
|
||||
VolumeType: &volumeType,
|
||||
}
|
||||
|
||||
if iops != nil {
|
||||
if iopsVolumeTypes.Has(volumeType) && iops != nil {
|
||||
req.SetIops(int64(*iops))
|
||||
}
|
||||
|
||||
@@ -68,18 +75,19 @@ func (op *blockStorageAdapter) GetVolumeInfo(volumeID string) (string, *int, err
|
||||
|
||||
var (
|
||||
volumeType string
|
||||
iops int
|
||||
iops *int
|
||||
)
|
||||
|
||||
if vol.VolumeType != nil {
|
||||
volumeType = *vol.VolumeType
|
||||
}
|
||||
|
||||
if vol.Iops != nil {
|
||||
iops = int(*vol.Iops)
|
||||
if iopsVolumeTypes.Has(volumeType) && vol.Iops != nil {
|
||||
iopsVal := int(*vol.Iops)
|
||||
iops = &iopsVal
|
||||
}
|
||||
|
||||
return volumeType, &iops, nil
|
||||
return volumeType, iops, nil
|
||||
}
|
||||
|
||||
func (op *blockStorageAdapter) IsVolumeReady(volumeID string) (ready bool, err error) {
|
||||
|
||||
Reference in New Issue
Block a user