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

Change SizeLimit to a pointer #50163

Merged
merged 2 commits into from
Sep 1, 2017

Conversation

jingxu97
Copy link
Contributor

@jingxu97 jingxu97 commented Aug 4, 2017

This PR fixes #50121

The `emptyDir.sizeLimit` field is now correctly omitted from API requests and responses when unset.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 4, 2017
@k8s-github-robot k8s-github-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. release-note-label-needed labels Aug 4, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 4, 2017
@jingxu97 jingxu97 requested a review from liggitt August 4, 2017 20:08
@@ -383,8 +383,7 @@ func validateVolumeSource(source *api.VolumeSource, fldPath *field.Path) field.E
if source.EmptyDir != nil {
numVolumes++
if !utilfeature.DefaultFeatureGate.Enabled(features.LocalStorageCapacityIsolation) {
unsetSizeLimit := resource.Quantity{}
if unsetSizeLimit.Cmp(source.EmptyDir.SizeLimit) != 0 {
if source.EmptyDir.SizeLimit != nil {
Copy link
Member

Choose a reason for hiding this comment

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

1.7 clients will send "0" and we could have 1.7 data stored as 0... need to tolerate that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a check. Will this work for the case of data stored as 0? Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a unit test for that?

@jingxu97 jingxu97 force-pushed the Aug/sizeLimit branch 3 times, most recently from f303a58 to fd8304c Compare August 4, 2017 21:07
@jingxu97
Copy link
Contributor Author

jingxu97 commented Aug 7, 2017

@liggitt I updated the PR, PTAL. Thanks!

@jingxu97
Copy link
Contributor Author

jingxu97 commented Aug 9, 2017

@liggitt I addressed your comment. Could you please help review it again? Thanks!

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 10, 2017
@kyessenov
Copy link

Is there a date when this gets merged?

@jingxu97 jingxu97 force-pushed the Aug/sizeLimit branch 2 times, most recently from 38138a0 to 7d33b15 Compare August 16, 2017 22:37
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 16, 2017
@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 18, 2017
@@ -383,8 +383,7 @@ func validateVolumeSource(source *api.VolumeSource, fldPath *field.Path) field.E
if source.EmptyDir != nil {
numVolumes++
if !utilfeature.DefaultFeatureGate.Enabled(features.LocalStorageCapacityIsolation) {
unsetSizeLimit := resource.Quantity{}
if unsetSizeLimit.Cmp(source.EmptyDir.SizeLimit) != 0 {
if source.EmptyDir.SizeLimit != nil && source.EmptyDir.SizeLimit.Cmp(resource.Quantity{}) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Previously, this checked != 0, not > 0

Is < 0 even valid? I'm not seeing that forbidden by validation… but I'd expect < 0 to be forbidden even when the feature gate is enabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am thinking I only need to check sizeLimit != nil. No matter >0, <0 or =0 should not be allowed

Copy link
Member

Choose a reason for hiding this comment

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

1.7 clients (and existing data) could have 0, which you now have to tolerate.

@@ -507,7 +507,7 @@ func GetResourceRequest(pod *v1.Pod) *schedulercache.Resource {
// Account for storage requested by emptydir volumes
// If the storage medium is memory, should exclude the size
for _, vol := range pod.Spec.Volumes {
Copy link
Member

Choose a reason for hiding this comment

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

For example, a negative value here would mess up this calculation

@liggitt
Copy link
Member

liggitt commented Aug 18, 2017

one question on the zero compare (and associated validation), needs rebase, then LGTM

@liggitt liggitt added this to the v1.7 milestone Aug 18, 2017
@jingxu97
Copy link
Contributor Author

/test pull-kubernetes-e2e-gce-bazel

@liggitt
Copy link
Member

liggitt commented Aug 30, 2017

/retest

@liggitt
Copy link
Member

liggitt commented Aug 30, 2017

looks like a new usage cropped up:

W0829 00:13:59.563] 2017/08/29 00:13:59 error running compiler: exit status 1 W0829 00:13:59.563] Use --strategy=GoCompile=standalone to disable sandboxing for the failing actions. I0829 00:13:59.664] test/e2e_node/local_storage_isolation_eviction_test.go:221: cannot use *resource.NewQuantity(int64(100000), resource.BinarySI) (type resource.Quantity) as type *resource.Quantity in field value

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 30, 2017
@jingxu97
Copy link
Contributor Author

@liggitt I already changed the code in test/e2e_node/local_storage_isolation_eviction_test.go:221: to use pointer, could not figure out why it has the compile error..

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 30, 2017
@liggitt
Copy link
Member

liggitt commented Aug 30, 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 Aug 30, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jingxu97, liggitt, timothysc, vishh

Associated issue: 50121

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

@jingxu97
Copy link
Contributor Author

/retest

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

@k8s-github-robot
Copy link

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

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Sep 1, 2017

@jingxu97: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-bazel a5cada9383abeafc0c3ad764598b3116b1234768 link /test pull-kubernetes-bazel

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.

@liggitt
Copy link
Member

liggitt commented Sep 1, 2017

/test pull-kubernetes-bazel
/test pull-kubernetes-e2e-kops-aws

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 51707, 51662, 51723, 50163, 51633)

@k8s-github-robot k8s-github-robot merged commit 8679a8f into kubernetes:master Sep 1, 2017
@wojtek-t wojtek-t added the cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. label Sep 6, 2017
k8s-github-robot pushed a commit that referenced this pull request Sep 6, 2017
…3-upstream-release-1.7

Automatic merge from submit-queue

Automated cherry pick of #50163

Cherry pick of #50163 on release-1.7.

fixes #50121

#50163: Change SizeLimit to a pointer

```release-note
The alpha `emptyDir.sizeLimit` field is now correctly omitted from API requests and responses when unset.
```
@k8s-cherrypick-bot
Copy link

Commit found in the "release-1.7" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked.

@@ -739,7 +739,7 @@ type EmptyDirVolumeSource struct {
// The default is nil which means that the limit is undefined.
// More info: http://kubernetes.io/docs/user-guide/volumes#emptydir
// +optional
SizeLimit resource.Quantity `json:"sizeLimit,omitempty" protobuf:"bytes,2,opt,name=sizeLimit"`
SizeLimit *resource.Quantity `json:"sizeLimit,omitempty" protobuf:"bytes,2,opt,name=sizeLimit"`
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this break backward compatibility?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, the introduction of the non-pointer field broke compatibility, and this restored it

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. cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. 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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SizeLimit violates k8s API convention