Skip to content

Commit 45f0cb0

Browse files
Fix provisioned-iops-on-create passing logic
1 parent 5ceccbf commit 45f0cb0

File tree

3 files changed

+50
-22
lines changed

3 files changed

+50
-22
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

+30-11
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,24 @@ import (
4444
const (
4545
testNamePrefix = "gcepd-csi-e2e-"
4646

47-
defaultSizeGb int64 = 5
48-
defaultRepdSizeGb int64 = 200
49-
defaultMwSizeGb int64 = 200
50-
defaultVolumeLimit int64 = 127
51-
readyState = "READY"
52-
standardDiskType = "pd-standard"
53-
extremeDiskType = "pd-extreme"
54-
provisionedIOPSOnCreate = "100000"
55-
provisionedIOPSOnCreateInt = int64(100000)
47+
defaultSizeGb int64 = 5
48+
defaultExtremeSizeGb int64 = 500
49+
defaultRepdSizeGb int64 = 200
50+
defaultMwSizeGb int64 = 200
51+
defaultVolumeLimit int64 = 127
52+
readyState = "READY"
53+
standardDiskType = "pd-standard"
54+
extremeDiskType = "pd-extreme"
55+
provisionedIOPSOnCreate = "100000"
56+
provisionedIOPSConfigOnCreate = "112345"
57+
provisionedIOPSOnCreateInt = int64(100000)
58+
provisionedIOPSConfigOnCreateInt = int64(112345)
5659

5760
defaultEpsilon = 500000000 // 500M
5861
)
5962

63+
var test_counter = 1
64+
6065
var _ = Describe("GCE PD CSI Driver", func() {
6166

6267
It("Should get reasonable volume limits from nodes with NodeGetInfo", func() {
@@ -386,14 +391,28 @@ var _ = Describe("GCE PD CSI Driver", func() {
386391
// Create Disk
387392
disk := typeToDisk[diskType]
388393
volName := testNamePrefix + string(uuid.NewUUID())
389-
volID, err := client.CreateVolume(volName, disk.params, defaultSizeGb, nil, nil)
394+
if test_counter == 1 && disk.params.DiskType == extremeDiskType {
395+
disk.params.ProvisionedIOPSOnCreate = provisionedIOPSConfigOnCreate
396+
volID, err := client.CreateVolume(volName, disk.params, defaultExtremeSizeGb, nil, nil)
397+
} else {
398+
volID, err := client.CreateVolume(volName, disk.params, defaultSizeGb, nil, nil)
399+
}
400+
390401
Expect(err).To(BeNil(), "CreateVolume failed with error: %v", err)
391402

392403
// Validate Disk Created
393404
cloudDisk, err := computeService.Disks.Get(p, z, volName).Do()
394405
Expect(err).To(BeNil(), "Could not get disk from cloud directly")
395406
Expect(cloudDisk.Status).To(Equal(readyState))
396-
Expect(cloudDisk.SizeGb).To(Equal(defaultSizeGb))
407+
408+
if test_counter == 1 && disk.params.DiskType == extremeDiskType {
409+
Expect(cloudDisk.SizeGb).To(Equal(defaultDiskSizeGb))
410+
Expect(cloudDisk.ProvisionedIops).To(Equal(provisionedIOPSOnCreateInt))
411+
test_counter++
412+
} else {
413+
Expect(cloudDisk.SizeGb).To(Equal(defaultSizeGb))
414+
}
415+
397416
Expect(cloudDisk.Name).To(Equal(volName))
398417
disk.validate(cloudDisk)
399418

0 commit comments

Comments
 (0)