Skip to content

Commit 8c90ae0

Browse files
Fix provisioned-iops-on-create passing logic
1 parent 5ceccbf commit 8c90ae0

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

pkg/common/utils_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,12 @@ func TestConvertStringToInt64(t *testing.T) {
597597
expInt64: 10000,
598598
expectError: false,
599599
},
600+
{
601+
desc: "test higher number",
602+
inputStr: "15000",
603+
expInt64: 15000,
604+
expectError: false,
605+
},
600606
{
601607
desc: "round M to number",
602608
inputStr: "1M",

pkg/gce-cloud-provider/compute/gce-compute.go

+14-11
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ func convertV1DiskToBetaDisk(v1Disk *computev1.Disk, provisionedThroughputOnCrea
419419
ReplicaZones: v1Disk.ReplicaZones,
420420
DiskEncryptionKey: dek,
421421
}
422+
if v1Disk.ProvisionedIops > 0 {
423+
betaDisk.ProvisionedIops = v1Disk.ProvisionedIops
424+
}
422425
if provisionedThroughputOnCreate > 0 {
423426
betaDisk.ProvisionedThroughput = provisionedThroughputOnCreate
424427
}
@@ -449,12 +452,11 @@ func (cloud *CloudProvider) insertRegionalDisk(
449452
}
450453

451454
diskToCreate := &computev1.Disk{
452-
Name: volKey.Name,
453-
SizeGb: common.BytesToGbRoundUp(capBytes),
454-
Description: description,
455-
Type: cloud.GetDiskTypeURI(cloud.project, volKey, params.DiskType),
456-
Labels: params.Labels,
457-
ProvisionedIops: params.ProvisionedIOPSOnCreate,
455+
Name: volKey.Name,
456+
SizeGb: common.BytesToGbRoundUp(capBytes),
457+
Description: description,
458+
Type: cloud.GetDiskTypeURI(cloud.project, volKey, params.DiskType),
459+
Labels: params.Labels,
458460
}
459461
if snapshotID != "" {
460462
_, snapshotType, _, err := common.SnapshotIDToProjectKey(snapshotID)
@@ -562,11 +564,12 @@ func (cloud *CloudProvider) insertZonalDisk(
562564
}
563565

564566
diskToCreate := &computev1.Disk{
565-
Name: volKey.Name,
566-
SizeGb: common.BytesToGbRoundUp(capBytes),
567-
Description: description,
568-
Type: cloud.GetDiskTypeURI(project, volKey, params.DiskType),
569-
Labels: params.Labels,
567+
Name: volKey.Name,
568+
SizeGb: common.BytesToGbRoundUp(capBytes),
569+
Description: description,
570+
Type: cloud.GetDiskTypeURI(project, volKey, params.DiskType),
571+
Labels: params.Labels,
572+
ProvisionedIops: params.ProvisionedIOPSOnCreate,
570573
}
571574

572575
if snapshotID != "" {

test/e2e/tests/single_zone_e2e_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ const (
5151
readyState = "READY"
5252
standardDiskType = "pd-standard"
5353
extremeDiskType = "pd-extreme"
54-
provisionedIOPSOnCreate = "100000"
55-
provisionedIOPSOnCreateInt = int64(100000)
54+
provisionedIOPSOnCreate = "1234"
55+
provisionedIOPSOnCreateInt = int64(1234)
5656

5757
defaultEpsilon = 500000000 // 500M
5858
)

0 commit comments

Comments
 (0)