Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix volume size allocation in gcd_pd #56600

Merged
merged 2 commits into from
Dec 19, 2017

Conversation

edisonxiang
Copy link
Contributor

@edisonxiang edisonxiang commented Nov 30, 2017

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:

Fixed dynamic provisioning of GCE PDs to round to the next GB instead of GiB

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 30, 2017
@msau42
Copy link
Member

msau42 commented Nov 30, 2017

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 30, 2017
@edisonxiang
Copy link
Contributor Author

/cc @msau42 @gnufied

@@ -194,7 +196,7 @@ func (gceutil *GCEDiskUtil) CreateVolume(c *gcePersistentDiskProvisioner) (strin
glog.Errorf("error getting labels for volume %q: %v", name, err)
}

return name, int(requestGB), labels, fstype, nil
return name, int(requestGiB), labels, fstype, nil
Copy link
Member

@gnufied gnufied Nov 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make sure that value returned by this function is read correctly by Provision function here - https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/gce_pd/gce_pd.go#L426 . Currently as it exists it will try to save a GB value back into GiB and that will be wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I missed that you are creating both GB and GiB values out of requested size and returning GiB value back to caller. That works too I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gnufied Thanks your review.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidz627 Done, thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, why do we need to return GiB if we're allocating in GB? Won't the size recorded in the PV be wrong then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @msau42, Thanks your review. Does your suggestion is to remove this line and return requestGB directly, and replace "%dGi" with "%dG" in this line?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think either thing works. Return the GB value and then get resource.Quantity out of it by doing %dG. That is what I originally suggested above. Returning GiB and leaving %dGi works too, but I do think that may be returning GB and then parsing value back using %dG was better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think returning GiB is accurate. requestGiB != requestGB in bytes. The PV is going to have capacity larger than what was actually allocated.

So if there is no reason to return values in Gi, then I would recommend just returning GB.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msau42 @gnufied Done. Now it is return GB Directly. Thanks.

@edisonxiang
Copy link
Contributor Author

Hey @davidz627 @msau42 @gnufied PTAL, Thank you~

@davidz627
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 1, 2017
@gnufied
Copy link
Member

gnufied commented Dec 1, 2017

/approve

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 1, 2017
@msau42
Copy link
Member

msau42 commented Dec 4, 2017

/lgtm cancel

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 4, 2017
@@ -38,6 +38,13 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
)

const (
// GiB is used by PV/PVC. 1 GiB = 1024 * 1024 * 1024 Bytes
VolumeSizeGiB = 1024 * 1024 * 1024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we using this variable anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. A lot of places. Such as this line. If this bug fix is accepted, I am willing to submit another pr to fix this issue with @gnufied.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 5, 2017
Copy link
Member

@msau42 msau42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Thanks for running the e2e tests too!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 5, 2017
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to @fejta).

Review the full test history for this PR.

1 similar comment
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to @fejta).

Review the full test history for this PR.

@msau42
Copy link
Member

msau42 commented Dec 11, 2017

Does this need a release note, since we will now be provisioning GCE disks that are smaller than before?

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Dec 14, 2017
@edisonxiang
Copy link
Contributor Author

@msau42 Done, PTAL, Thanks.

// 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.RoundUpSize(requestBytes, volume.GB)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really tiny nit - but can we simply use volume.RoundUpToGB and remove that reuestBytes variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gnufied, done, Thanks.

@edisonxiang
Copy link
Contributor Author

/test pull-kubernetes-e2e-gce
/test pull-kubernetes-verify

@gnufied
Copy link
Member

gnufied commented Dec 19, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 19, 2017
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: davidz627, edisonxiang, gnufied, msau42

Associated issue: #56081

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

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 here.

@k8s-github-robot k8s-github-robot merged commit 7ede2a0 into kubernetes:master Dec 19, 2017
@edisonxiang edisonxiang deleted the fixvolumesize branch January 30, 2018 08:21
krunaljain added a commit to krunaljain/kubernetes that referenced this pull request Jul 16, 2018
… GiB instead of GBs

Fixing comments and importing constant from util

Importing constant from util

Fixing comment in volume_provisioning.go
k8s-github-robot pushed a commit that referenced this pull request Jul 17, 2018
…ing_to_GB

Automatic merge from submit-queue (batch tested with PRs 66172, 66254). 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>.

Reverting commit #56600 as GCE PD is allocated in chunks of GiB inste…

**What this PR does / why we need it:**
This PR reverts the changes made in commit #56600 which considered GCE PDs are allocated in chunks of GBs. The following set of operations demonstrate the allocation is in GiBs. 

Manually create a PD in GB, and manually attach it to a node:
```
$ gcloud compute disks create msau-test --zone=us-central1-b --size=1GB
```
Run lsblk on it, and it shows the bytes of the disk are 1GiB:
```
$ lsblk -b
sdc       8:32   0  1073741824  0 disk 
```

**Which issue(s) this PR fixes**:
[65285](#65285)
**Special notes for your reviewer**:
```release-note
none
```
krunaljain added a commit to krunaljain/kubernetes that referenced this pull request Jul 19, 2018
… GiB instead of GBs

Fixing comments and importing constant from util

Importing constant from util

Fixing comment in volume_provisioning.go
krunaljain added a commit to krunaljain/kubernetes that referenced this pull request Jul 19, 2018
… GiB instead of GBs

Fixing comments and importing constant from util

Importing constant from util

Fixing comment in volume_provisioning.go
k8s-github-robot pushed a commit that referenced this pull request Jul 21, 2018
…6172-#66324-upstream-release-1.10

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.10.

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

```release-note 
none 
```
openshift-publish-robot pushed a commit to openshift/kubernetes that referenced this pull request Jul 29, 2018
…ated in chunks of GiB inste...

Origin-commit: 5f297b287dee3d96b4a0541c348832a330772713
k8s-github-robot pushed a commit that referenced this pull request Jul 30, 2018
…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
```
tanshanshan pushed a commit to tanshanshan/kubernetes that referenced this pull request Aug 10, 2018
… GiB instead of GBs

Fixing comments and importing constant from util

Importing constant from util

Fixing comment in volume_provisioning.go
openshift-publish-robot pushed a commit to openshift/kubernetes that referenced this pull request Jan 29, 2019
…ated in chunks of GiB inste...

Origin-commit: 5f297b287dee3d96b4a0541c348832a330772713
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GCE CreateVolume allocates in chunks of GiB incorrectly
8 participants