From aff57e05713974cab8088761f7c33902b60e7da8 Mon Sep 17 00:00:00 2001 From: Steve Kriss Date: Mon, 14 Aug 2017 09:42:33 -0700 Subject: [PATCH] switch to int64 for iops val Signed-off-by: Steve Kriss --- pkg/apis/ark/v1/backup.go | 2 +- pkg/backup/volume_snapshot_action_test.go | 2 +- pkg/cloudprovider/aws/block_storage_adapter.go | 11 +++++------ pkg/cloudprovider/azure/block_storage_adapter.go | 4 ++-- pkg/cloudprovider/gcp/block_storage_adapter.go | 4 ++-- pkg/cloudprovider/snapshot_service.go | 8 ++++---- pkg/cloudprovider/storage_interfaces.go | 4 ++-- pkg/restore/restorers/pv_restorer_test.go | 2 +- pkg/util/test/fake_snapshot_service.go | 4 ++-- 9 files changed, 20 insertions(+), 21 deletions(-) diff --git a/pkg/apis/ark/v1/backup.go b/pkg/apis/ark/v1/backup.go index 0d954b6d2..adfe40b41 100644 --- a/pkg/apis/ark/v1/backup.go +++ b/pkg/apis/ark/v1/backup.go @@ -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,omitempty"` + Iops *int64 `json:"iops,omitempty"` } // +genclient=true diff --git a/pkg/backup/volume_snapshot_action_test.go b/pkg/backup/volume_snapshot_action_test.go index 458e2a791..ad1f788cd 100644 --- a/pkg/backup/volume_snapshot_action_test.go +++ b/pkg/backup/volume_snapshot_action_test.go @@ -31,7 +31,7 @@ import ( ) func TestVolumeSnapshotAction(t *testing.T) { - iops := 1000 + iops := int64(1000) tests := []struct { name string diff --git a/pkg/cloudprovider/aws/block_storage_adapter.go b/pkg/cloudprovider/aws/block_storage_adapter.go index 8e3bd26e0..f32173225 100644 --- a/pkg/cloudprovider/aws/block_storage_adapter.go +++ b/pkg/cloudprovider/aws/block_storage_adapter.go @@ -38,7 +38,7 @@ type blockStorageAdapter struct { // from snapshot. var iopsVolumeTypes = sets.NewString("io1") -func (op *blockStorageAdapter) CreateVolumeFromSnapshot(snapshotID, volumeType string, iops *int) (volumeID string, err error) { +func (op *blockStorageAdapter) CreateVolumeFromSnapshot(snapshotID, volumeType string, iops *int64) (volumeID string, err error) { req := &ec2.CreateVolumeInput{ SnapshotId: &snapshotID, AvailabilityZone: &op.az, @@ -46,7 +46,7 @@ func (op *blockStorageAdapter) CreateVolumeFromSnapshot(snapshotID, volumeType s } if iopsVolumeTypes.Has(volumeType) && iops != nil { - req.SetIops(int64(*iops)) + req.Iops = iops } res, err := op.ec2.CreateVolume(req) @@ -57,7 +57,7 @@ func (op *blockStorageAdapter) CreateVolumeFromSnapshot(snapshotID, volumeType s return *res.VolumeId, nil } -func (op *blockStorageAdapter) GetVolumeInfo(volumeID string) (string, *int, error) { +func (op *blockStorageAdapter) GetVolumeInfo(volumeID string) (string, *int64, error) { req := &ec2.DescribeVolumesInput{ VolumeIds: []*string{&volumeID}, } @@ -75,7 +75,7 @@ func (op *blockStorageAdapter) GetVolumeInfo(volumeID string) (string, *int, err var ( volumeType string - iops *int + iops *int64 ) if vol.VolumeType != nil { @@ -83,8 +83,7 @@ func (op *blockStorageAdapter) GetVolumeInfo(volumeID string) (string, *int, err } if iopsVolumeTypes.Has(volumeType) && vol.Iops != nil { - iopsVal := int(*vol.Iops) - iops = &iopsVal + iops = vol.Iops } return volumeType, iops, nil diff --git a/pkg/cloudprovider/azure/block_storage_adapter.go b/pkg/cloudprovider/azure/block_storage_adapter.go index 69c3729b7..088c0f4de 100644 --- a/pkg/cloudprovider/azure/block_storage_adapter.go +++ b/pkg/cloudprovider/azure/block_storage_adapter.go @@ -39,7 +39,7 @@ type blockStorageAdapter struct { var _ cloudprovider.BlockStorageAdapter = &blockStorageAdapter{} -func (op *blockStorageAdapter) CreateVolumeFromSnapshot(snapshotID, volumeType string, iops *int) (string, error) { +func (op *blockStorageAdapter) CreateVolumeFromSnapshot(snapshotID, volumeType string, iops *int64) (string, error) { fullSnapshotName := getFullSnapshotName(op.subscription, op.resourceGroup, snapshotID) diskName := "restore-" + uuid.NewV4().String() @@ -68,7 +68,7 @@ func (op *blockStorageAdapter) CreateVolumeFromSnapshot(snapshotID, volumeType s return diskName, nil } -func (op *blockStorageAdapter) GetVolumeInfo(volumeID string) (string, *int, error) { +func (op *blockStorageAdapter) GetVolumeInfo(volumeID string) (string, *int64, error) { res, err := op.disks.Get(op.resourceGroup, volumeID) if err != nil { return "", nil, err diff --git a/pkg/cloudprovider/gcp/block_storage_adapter.go b/pkg/cloudprovider/gcp/block_storage_adapter.go index 6cb794f61..b4170f2b2 100644 --- a/pkg/cloudprovider/gcp/block_storage_adapter.go +++ b/pkg/cloudprovider/gcp/block_storage_adapter.go @@ -36,7 +36,7 @@ type blockStorageAdapter struct { var _ cloudprovider.BlockStorageAdapter = &blockStorageAdapter{} -func (op *blockStorageAdapter) CreateVolumeFromSnapshot(snapshotID string, volumeType string, iops *int) (volumeID string, err error) { +func (op *blockStorageAdapter) CreateVolumeFromSnapshot(snapshotID string, volumeType string, iops *int64) (volumeID string, err error) { res, err := op.gce.Snapshots.Get(op.project, snapshotID).Do() if err != nil { return "", err @@ -55,7 +55,7 @@ func (op *blockStorageAdapter) CreateVolumeFromSnapshot(snapshotID string, volum return disk.Name, nil } -func (op *blockStorageAdapter) GetVolumeInfo(volumeID string) (string, *int, error) { +func (op *blockStorageAdapter) GetVolumeInfo(volumeID string) (string, *int64, error) { res, err := op.gce.Disks.Get(op.project, op.zone, volumeID).Do() if err != nil { return "", nil, err diff --git a/pkg/cloudprovider/snapshot_service.go b/pkg/cloudprovider/snapshot_service.go index 2eb090a6a..34165ee01 100644 --- a/pkg/cloudprovider/snapshot_service.go +++ b/pkg/cloudprovider/snapshot_service.go @@ -37,14 +37,14 @@ type SnapshotService interface { // CreateVolumeFromSnapshot triggers a restore operation to create a new cloud volume from the specified // snapshot and volume characteristics. Returns the cloud volume ID, or an error if a problem is // encountered triggering the restore via the cloud API. - CreateVolumeFromSnapshot(snapshotID, volumeType string, iops *int) (string, error) + CreateVolumeFromSnapshot(snapshotID, volumeType string, iops *int64) (string, error) // DeleteSnapshot triggers a deletion of the specified Ark snapshot via the cloud API. It returns an // error if a problem is encountered triggering the deletion via the cloud API. DeleteSnapshot(snapshotID string) error // GetVolumeInfo gets the type and IOPS (if applicable) from the cloud API. - GetVolumeInfo(volumeID string) (string, *int, error) + GetVolumeInfo(volumeID string) (string, *int64, error) } const ( @@ -67,7 +67,7 @@ func NewSnapshotService(blockStorage BlockStorageAdapter) SnapshotService { } } -func (sr *snapshotService) CreateVolumeFromSnapshot(snapshotID string, volumeType string, iops *int) (string, error) { +func (sr *snapshotService) CreateVolumeFromSnapshot(snapshotID string, volumeType string, iops *int64) (string, error) { volumeID, err := sr.blockStorage.CreateVolumeFromSnapshot(snapshotID, volumeType, iops) if err != nil { return "", err @@ -116,6 +116,6 @@ func (sr *snapshotService) DeleteSnapshot(snapshotID string) error { return sr.blockStorage.DeleteSnapshot(snapshotID) } -func (sr *snapshotService) GetVolumeInfo(volumeID string) (string, *int, error) { +func (sr *snapshotService) GetVolumeInfo(volumeID string) (string, *int64, error) { return sr.blockStorage.GetVolumeInfo(volumeID) } diff --git a/pkg/cloudprovider/storage_interfaces.go b/pkg/cloudprovider/storage_interfaces.go index e91defc5d..1f02082ad 100644 --- a/pkg/cloudprovider/storage_interfaces.go +++ b/pkg/cloudprovider/storage_interfaces.go @@ -44,11 +44,11 @@ type ObjectStorageAdapter interface { type BlockStorageAdapter interface { // CreateVolumeFromSnapshot creates a new block volume, initialized from the provided snapshot, // and with the specified type and IOPS (if using provisioned IOPS). - CreateVolumeFromSnapshot(snapshotID, volumeType string, iops *int) (volumeID string, err error) + CreateVolumeFromSnapshot(snapshotID, volumeType string, iops *int64) (volumeID string, err error) // GetVolumeInfo returns the type and IOPS (if using provisioned IOPS) for a specified block // volume. - GetVolumeInfo(volumeID string) (string, *int, error) + GetVolumeInfo(volumeID string) (string, *int64, error) // IsVolumeReady returns whether the specified volume is ready to be used. IsVolumeReady(volumeID string) (ready bool, err error) diff --git a/pkg/restore/restorers/pv_restorer_test.go b/pkg/restore/restorers/pv_restorer_test.go index 0979b5d6a..12ce423cd 100644 --- a/pkg/restore/restorers/pv_restorer_test.go +++ b/pkg/restore/restorers/pv_restorer_test.go @@ -29,7 +29,7 @@ import ( ) func TestPVRestorerPrepare(t *testing.T) { - iops := 1000 + iops := int64(1000) tests := []struct { name string diff --git a/pkg/util/test/fake_snapshot_service.go b/pkg/util/test/fake_snapshot_service.go index f39631082..f940ec6f8 100644 --- a/pkg/util/test/fake_snapshot_service.go +++ b/pkg/util/test/fake_snapshot_service.go @@ -52,7 +52,7 @@ func (s *FakeSnapshotService) CreateSnapshot(volumeID string) (string, error) { return s.SnapshottableVolumes[volumeID].SnapshotID, nil } -func (s *FakeSnapshotService) CreateVolumeFromSnapshot(snapshotID, volumeType string, iops *int) (string, error) { +func (s *FakeSnapshotService) CreateVolumeFromSnapshot(snapshotID, volumeType string, iops *int64) (string, error) { key := api.VolumeBackupInfo{ SnapshotID: snapshotID, Type: volumeType, @@ -72,7 +72,7 @@ func (s *FakeSnapshotService) DeleteSnapshot(snapshotID string) error { return nil } -func (s *FakeSnapshotService) GetVolumeInfo(volumeID string) (string, *int, error) { +func (s *FakeSnapshotService) GetVolumeInfo(volumeID string) (string, *int64, error) { if volumeInfo, exists := s.SnapshottableVolumes[volumeID]; !exists { return "", nil, errors.New("VolumeID not found") } else {