Skip to content

Commit

Permalink
Merge pull request #66356 from krunaljain/automated-cherry-pick-of-#6…
Browse files Browse the repository at this point in the history
…6172-#66324-upstream-release-1.11

Automatic merge from submit-queue.

Automated cherry pick of #66172: Reverting commit #56600 as GCE PD is allocated in chunks of #66324: Fixing E2E tests for disk resizing

Cherry pick of #66172 #66324 on release-1.11.

#66172: Reverting commit #56600 as GCE PD is allocated in chunks of
#66324: Fixing E2E tests for disk resizing

```release-note
none
```
  • Loading branch information
Kubernetes Submit Queue authored Jul 30, 2018
2 parents 048fd05 + 4a23b60 commit 29be13f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 45 deletions.
12 changes: 6 additions & 6 deletions pkg/cloudprovider/providers/gce/gce_disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,12 +747,12 @@ func (gce *GCECloud) ResizeDisk(diskToResize string, oldSize resource.Quantity,
}

requestBytes := newSize.Value()
// GCE resizes in chunks of GBs (not GiB)
requestGB := volumeutil.RoundUpSize(requestBytes, 1000*1000*1000)
newSizeQuant := resource.MustParse(fmt.Sprintf("%dG", requestGB))
// GCE resizes in chunks of GiBs
requestGIB := volumeutil.RoundUpSize(requestBytes, volumeutil.GIB)
newSizeQuant := resource.MustParse(fmt.Sprintf("%dGi", requestGIB))

// If disk is already of size equal or greater than requested size, we simply return
if disk.SizeGb >= requestGB {
if disk.SizeGb >= requestGIB {
return newSizeQuant, nil
}

Expand All @@ -761,7 +761,7 @@ func (gce *GCECloud) ResizeDisk(diskToResize string, oldSize resource.Quantity,
switch zoneInfo := disk.ZoneInfo.(type) {
case singleZone:
mc = newDiskMetricContextZonal("resize", disk.Region, zoneInfo.zone)
err := gce.manager.ResizeDiskOnCloudProvider(disk, requestGB, zoneInfo.zone)
err := gce.manager.ResizeDiskOnCloudProvider(disk, requestGIB, zoneInfo.zone)

if err != nil {
return oldSize, mc.Observe(err)
Expand All @@ -774,7 +774,7 @@ func (gce *GCECloud) ResizeDisk(diskToResize string, oldSize resource.Quantity,
}

mc = newDiskMetricContextRegional("resize", disk.Region)
err := gce.manager.RegionalResizeDiskOnCloudProvider(disk, requestGB)
err := gce.manager.RegionalResizeDiskOnCloudProvider(disk, requestGIB)

if err != nil {
return oldSize, mc.Observe(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/volume/gce_pd/gce_pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func (c *gcePersistentDiskProvisioner) Provision(selectedNode *v1.Node, allowedT
PersistentVolumeReclaimPolicy: c.options.PersistentVolumeReclaimPolicy,
AccessModes: c.options.PVC.Spec.AccessModes,
Capacity: v1.ResourceList{
v1.ResourceName(v1.ResourceStorage): resource.MustParse(fmt.Sprintf("%dG", sizeGB)),
v1.ResourceName(v1.ResourceStorage): resource.MustParse(fmt.Sprintf("%dGi", sizeGB)),
},
PersistentVolumeSource: v1.PersistentVolumeSource{
GCEPersistentDisk: &v1.GCEPersistentDiskVolumeSource{
Expand Down
2 changes: 1 addition & 1 deletion pkg/volume/gce_pd/gce_pd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func TestPlugin(t *testing.T) {
}
cap := persistentSpec.Spec.Capacity[v1.ResourceStorage]
size := cap.Value()
if size != 100*util.GB {
if size != 100*util.GIB {
t.Errorf("Provision() returned unexpected volume size: %v", size)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/volume/gce_pd/gce_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func (gceutil *GCEDiskUtil) CreateVolume(c *gcePersistentDiskProvisioner) (strin

name := volumeutil.GenerateVolumeName(c.options.ClusterName, c.options.PVName, 63) // GCE PD name can have up to 63 characters
capacity := c.options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]
// GCE PDs are allocated in chunks of GBs (not GiBs)
requestGB := volumeutil.RoundUpToGB(capacity)
// GCE PDs are allocated in chunks of GiBs
requestGB := volumeutil.RoundUpToGiB(capacity)

// Apply Parameters.
// Values for parameter "replication-type" are canonicalized to lower case.
Expand Down
44 changes: 9 additions & 35 deletions test/e2e/storage/volume_provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
"type": "pd-ssd",
"zone": cloudZone,
},
claimSize: "1.5G",
expectedSize: "2G",
claimSize: "1.5Gi",
expectedSize: "2Gi",
pvCheck: func(volume *v1.PersistentVolume) error {
return checkGCEPD(volume, "pd-ssd")
},
Expand All @@ -278,8 +278,8 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
parameters: map[string]string{
"type": "pd-standard",
},
claimSize: "1.5G",
expectedSize: "2G",
claimSize: "1.5Gi",
expectedSize: "2Gi",
pvCheck: func(volume *v1.PersistentVolume) error {
return checkGCEPD(volume, "pd-standard")
},
Expand Down Expand Up @@ -443,8 +443,8 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
parameters: map[string]string{
"type": "pd-standard",
},
claimSize: "1G",
expectedSize: "1G",
claimSize: "1Gi",
expectedSize: "1Gi",
pvCheck: func(volume *v1.PersistentVolume) error {
return checkGCEPD(volume, "pd-standard")
},
Expand Down Expand Up @@ -477,8 +477,8 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
parameters: map[string]string{
"type": "pd-standard",
},
claimSize: "1G",
expectedSize: "1G",
claimSize: "1Gi",
expectedSize: "1Gi",
pvCheck: func(volume *v1.PersistentVolume) error {
return checkGCEPD(volume, "pd-standard")
},
Expand Down Expand Up @@ -526,7 +526,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
name: "unmanaged_zone",
provisioner: "kubernetes.io/gce-pd",
parameters: map[string]string{"zone": unmanagedZone},
claimSize: "1G",
claimSize: "1Gi",
}
sc := newStorageClass(test, ns, suffix)
sc, err = c.StorageV1().StorageClasses().Create(sc)
Expand Down Expand Up @@ -714,13 +714,6 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
claimSize: "2Gi",
expectedSize: "2Gi",
}
// gce or gke
if getDefaultPluginName() == "kubernetes.io/gce-pd" {
// using GB not GiB as e2e test unit since gce-pd returns GB,
// or expectedSize may be greater than claimSize.
test.claimSize = "2G"
test.expectedSize = "2G"
}

claim := newClaim(test, ns, "default")
testDynamicProvisioning(test, c, claim, nil)
Expand Down Expand Up @@ -803,17 +796,6 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
parameters: map[string]string{"resturl": serverUrl},
attach: false,
}

// GCE/GKE
if getDefaultPluginName() == "kubernetes.io/gce-pd" {
// Keeping an extra condition here based on below facts:
//*) gce-pd rounds up to the next gb.
//*) GlusterFS provisioner rounduptoGiB() and send it to backend,
// which does 'size/number' from provisioner*1024*1024*1024
test.claimSize = "2Gi"
test.expectedSize = "3G"
}

suffix := fmt.Sprintf("glusterdptest")
class := newStorageClass(test, ns, suffix)

Expand All @@ -838,14 +820,6 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
expectedSize: "2Gi",
volumeMode: &block,
}
// gce or gke
if getDefaultPluginName() == "kubernetes.io/gce-pd" {
// using GB not GiB as e2e test unit since gce-pd returns GB,
// or expectedSize may be greater than claimSize.
test.claimSize = "2G"
test.expectedSize = "2G"
}

claim := newClaim(test, ns, "default")
claim.Spec.VolumeMode = &block
testDynamicProvisioning(test, c, claim, nil)
Expand Down

0 comments on commit 29be13f

Please sign in to comment.