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

Avoid overflow by calling AsInt64 instead of Value() in volume plugin code #67969

Closed
wants to merge 1 commit into from

Conversation

wongma7
Copy link
Contributor

@wongma7 wongma7 commented Aug 28, 2018

What this PR does / why we need it: It is possible for a PVC.spec.resources.requests.storage to have a value greater than 2^63-1 depending on the unit used, e.g. 73786976299133170k can be found there. In a lot of places we call PVC.spec.resources.requests.stolrage.Value(), which may overflow. To avoid this, I've made RoundUpSize unexported and only exported functions like RoundUpToGiB which returns an error. As well, some volume plugins use int/int32 so there are functions for those specific cases (This continues work in #66464)

BEFORE: (73786976299133170k overflows to 68719477GiB and reaches the API???)
Warning VolumeResizeFailed 18m volume_expand Error expanding volume "default/myclaim" of plugin kubernetes.io/aws-ebs : AWS modifyVolume failed for vol-02b56e31b121d0b0b with InvalidParameterValue: Volume of 68719477GiB is too large for volume type gp2; maximum is 16384GiB
AFTER: (73786976299133170k is detected as too big and the request doesn't reach API)
Warning VolumeResizeFailed 8s volume_expand Error expanding volume "default/myclaim" of plugin kubernetes.io/aws-ebs : quantity {{73786976299133170 3} {} 73786976299133170k DecimalSI} is too great, overflows int64

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 #

Special notes for your reviewer:

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/storage Categorizes an issue or PR as relevant to SIG Storage. labels Aug 28, 2018
@wongma7
Copy link
Contributor Author

wongma7 commented Aug 28, 2018

@kubernetes/sig-storage-pr-reviews

@wongma7
Copy link
Contributor Author

wongma7 commented Aug 28, 2018

TODO note for self: add/fix comments

}

if volSizeBytes < eightGig {
volSizeGB = int64(util.RoundUpSize(eightGig, oneGig))
if volSizeGB < 8 {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we return error when volSizeGB == 0?

	if volSizeGB == 0 {	
		return nil, fmt.Errorf("invalid volume size of 0 specified")	
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the check is unnecessary because kubernetes will validate it when the pvc is created

The PersistentVolumeClaim "myclaim" is invalid: spec.resources[storage]: Invalid value: "0": must be greater than zero

@wongma7
Copy link
Contributor Author

wongma7 commented Aug 29, 2018

/retest

1 similar comment
@wongma7
Copy link
Contributor Author

wongma7 commented Aug 29, 2018

/retest

@childsb childsb added the kind/bug Categorizes issue or PR as related to a bug. label Aug 31, 2018
@k8s-ci-robot
Copy link
Contributor

@wongma7: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 7, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 5, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 4, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@gnufied
Copy link
Member

gnufied commented Feb 11, 2020

/reopen

@k8s-ci-robot k8s-ci-robot reopened this Feb 11, 2020
@k8s-ci-robot
Copy link
Contributor

@gnufied: Reopened this PR.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Feb 11, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wongma7
To complete the pull request process, please assign rootfs, wlan0
You can assign the PR to them by writing /assign @rootfs @wlan0 in a comment when ready.

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

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

@wongma7: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-kubernetes-bazel-test 018a571 link /test pull-kubernetes-bazel-test
pull-kubernetes-bazel-build 018a571 link /test pull-kubernetes-bazel-build
pull-kubernetes-e2e-gce-storage-slow 018a571 link /test pull-kubernetes-e2e-gce-storage-slow
pull-kubernetes-e2e-gce-csi-serial 018a571 link /test pull-kubernetes-e2e-gce-csi-serial
pull-kubernetes-verify 018a571 link /test pull-kubernetes-verify
pull-kubernetes-dependencies 018a571 link /test pull-kubernetes-dependencies
pull-kubernetes-e2e-gce 018a571 link /test pull-kubernetes-e2e-gce
pull-kubernetes-e2e-gce-device-plugin-gpu 018a571 link /test pull-kubernetes-e2e-gce-device-plugin-gpu
pull-kubernetes-e2e-azure-disk 018a571 link /test pull-kubernetes-e2e-azure-disk
pull-kubernetes-e2e-kind-ipv6 018a571 link /test pull-kubernetes-e2e-kind-ipv6
pull-kubernetes-e2e-azure-disk-vmss 018a571 link /test pull-kubernetes-e2e-azure-disk-vmss
pull-kubernetes-integration 018a571 link /test pull-kubernetes-integration
pull-kubernetes-e2e-gce-100-performance 018a571 link /test pull-kubernetes-e2e-gce-100-performance
pull-kubernetes-kubemark-e2e-gce-big 018a571 link /test pull-kubernetes-kubemark-e2e-gce-big
pull-kubernetes-node-e2e 018a571 link /test pull-kubernetes-node-e2e
pull-kubernetes-e2e-gce-storage-snapshot 018a571 link /test pull-kubernetes-e2e-gce-storage-snapshot
pull-kubernetes-e2e-kind 018a571 link /test pull-kubernetes-e2e-kind
pull-kubernetes-typecheck 018a571 link /test pull-kubernetes-typecheck
pull-kubernetes-e2e-azure-file 018a571 link /test pull-kubernetes-e2e-azure-file
pull-kubernetes-node-e2e-containerd 018a571 link /test pull-kubernetes-node-e2e-containerd
pull-kubernetes-e2e-aks-engine-azure 018a571 link /test pull-kubernetes-e2e-aks-engine-azure

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cloudprovider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants