mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #56600 from edisonxiang/fixvolumesize
Automatic merge from submit-queue (batch tested with PRs 56600, 56814). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix volume size allocation in gcd_pd **What this PR does / why we need it**: GCE PDs are allocated in chunks of GBs not GiB but CreateVolume function incorrectly creates volume in chunks of GiB. 1 GiB = 1024 * 1024 * 1024 Bytes 1 GB = 1000 * 1000 * 1000 Bytes **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #56081 **Special notes for your reviewer**: **Release note**: ```release-note Fixed dynamic provisioning of GCE PDs to round to the next GB instead of GiB ```
This commit is contained in:
commit
7ede2a012e
@ -423,7 +423,7 @@ func (c *gcePersistentDiskProvisioner) Provision() (*v1.PersistentVolume, error)
|
||||
PersistentVolumeReclaimPolicy: c.options.PersistentVolumeReclaimPolicy,
|
||||
AccessModes: c.options.PVC.Spec.AccessModes,
|
||||
Capacity: v1.ResourceList{
|
||||
v1.ResourceName(v1.ResourceStorage): resource.MustParse(fmt.Sprintf("%dGi", sizeGB)),
|
||||
v1.ResourceName(v1.ResourceStorage): resource.MustParse(fmt.Sprintf("%dG", sizeGB)),
|
||||
},
|
||||
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||
GCEPersistentDisk: &v1.GCEPersistentDiskVolumeSource{
|
||||
|
@ -183,7 +183,7 @@ func TestPlugin(t *testing.T) {
|
||||
}
|
||||
cap := persistentSpec.Spec.Capacity[v1.ResourceStorage]
|
||||
size := cap.Value()
|
||||
if size != 100*1024*1024*1024 {
|
||||
if size != 100*volume.GB {
|
||||
t.Errorf("Provision() returned unexpected volume size: %v", size)
|
||||
}
|
||||
|
||||
|
@ -81,9 +81,8 @@ func (gceutil *GCEDiskUtil) CreateVolume(c *gcePersistentDiskProvisioner) (strin
|
||||
|
||||
name := volume.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)]
|
||||
requestBytes := capacity.Value()
|
||||
// GCE works with gigabytes, convert to GiB with rounding up
|
||||
requestGB := volume.RoundUpSize(requestBytes, 1024*1024*1024)
|
||||
// GCE PDs are allocated in chunks of GBs (not GiBs)
|
||||
requestGB := volume.RoundUpToGB(capacity)
|
||||
|
||||
// Apply Parameters (case-insensitive). We leave validation of
|
||||
// the values to the cloud provider.
|
||||
|
@ -257,8 +257,8 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
|
||||
"type": "pd-ssd",
|
||||
"zone": cloudZone,
|
||||
},
|
||||
"1.5Gi",
|
||||
"2Gi",
|
||||
"1.5G",
|
||||
"2G",
|
||||
func(volume *v1.PersistentVolume) error {
|
||||
return checkGCEPD(volume, "pd-ssd")
|
||||
},
|
||||
@ -270,8 +270,8 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
|
||||
map[string]string{
|
||||
"type": "pd-standard",
|
||||
},
|
||||
"1.5Gi",
|
||||
"2Gi",
|
||||
"1.5G",
|
||||
"2G",
|
||||
func(volume *v1.PersistentVolume) error {
|
||||
return checkGCEPD(volume, "pd-standard")
|
||||
},
|
||||
@ -436,8 +436,8 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
|
||||
map[string]string{
|
||||
"type": "pd-standard",
|
||||
},
|
||||
"1Gi",
|
||||
"1Gi",
|
||||
"1G",
|
||||
"1G",
|
||||
func(volume *v1.PersistentVolume) error {
|
||||
return checkGCEPD(volume, "pd-standard")
|
||||
},
|
||||
@ -470,8 +470,8 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
|
||||
map[string]string{
|
||||
"type": "pd-standard",
|
||||
},
|
||||
"1Gi",
|
||||
"1Gi",
|
||||
"1G",
|
||||
"1G",
|
||||
func(volume *v1.PersistentVolume) error {
|
||||
return checkGCEPD(volume, "pd-standard")
|
||||
},
|
||||
@ -521,7 +521,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
|
||||
name: "unmanaged_zone",
|
||||
provisioner: "kubernetes.io/gce-pd",
|
||||
parameters: map[string]string{"zone": unmanagedZone},
|
||||
claimSize: "1Gi",
|
||||
claimSize: "1G",
|
||||
}
|
||||
sc := newStorageClass(test, ns, suffix)
|
||||
sc, err = c.StorageV1().StorageClasses().Create(sc)
|
||||
@ -641,6 +641,14 @@ 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)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user