-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Conversation
pkg/api/validation/validation.go
Outdated
@@ -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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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?
f303a58
to
fd8304c
Compare
@liggitt I updated the PR, PTAL. Thanks! |
@liggitt I addressed your comment. Could you please help review it again? Thanks! |
Is there a date when this gets merged? |
38138a0
to
7d33b15
Compare
7d33b15
to
e378a7e
Compare
pkg/api/validation/validation.go
Outdated
@@ -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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
one question on the zero compare (and associated validation), needs rebase, then LGTM |
e378a7e
to
28c8564
Compare
61ad488
to
416b692
Compare
/test pull-kubernetes-e2e-gce-bazel |
/retest |
looks like a new usage cropped up:
|
@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.. |
This PR fixes issue kubernetes#50121
generated files
416b692
to
e1460ef
Compare
/lgtm |
[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 |
/retest |
/retest Review the full test history for this PR. |
1 similar comment
/retest Review the full test history for this PR. |
/test all [submit-queue is verifying that this PR is safe to merge] |
@jingxu97: The following test failed, say
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. |
/test pull-kubernetes-bazel |
Automatic merge from submit-queue (batch tested with PRs 51707, 51662, 51723, 50163, 51633) |
…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. ```
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"` |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
This PR fixes #50121