switch to int64 for iops val

Signed-off-by: Steve Kriss <steve@heptio.com>
This commit is contained in:
Steve Kriss
2017-08-14 09:42:33 -07:00
parent c41c958777
commit aff57e0571
9 changed files with 20 additions and 21 deletions

View File

@@ -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

View File

@@ -31,7 +31,7 @@ import (
)
func TestVolumeSnapshotAction(t *testing.T) {
iops := 1000
iops := int64(1000)
tests := []struct {
name string

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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)

View File

@@ -29,7 +29,7 @@ import (
)
func TestPVRestorerPrepare(t *testing.T) {
iops := 1000
iops := int64(1000)
tests := []struct {
name string

View File

@@ -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 {