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

UPSTREAM: 57214: Remove mutation from pvc validation #17876

Merged
merged 2 commits into from
Dec 20, 2017

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Dec 19, 2017

fixes #17769

/assign gnufied
/assign sttts

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 19, 2017
@openshift-ci-robot openshift-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Dec 19, 2017
@deads2k deads2k added queue/critical-fix and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 19, 2017
@openshift-merge-robot openshift-merge-robot added the vendor-update Touching vendor dir or related files label Dec 19, 2017
@@ -1773,27 +1773,26 @@ func ValidatePersistentVolumeClaimSpec(spec *core.PersistentVolumeClaimSpec, fld
func ValidatePersistentVolumeClaimUpdate(newPvc, oldPvc *core.PersistentVolumeClaim) field.ErrorList {
allErrs := ValidateObjectMetaUpdate(&newPvc.ObjectMeta, &oldPvc.ObjectMeta, field.NewPath("metadata"))
allErrs = append(allErrs, ValidatePersistentVolumeClaim(newPvc)...)
newPvcClone := newPvc.DeepCopy()
Copy link
Contributor

Choose a reason for hiding this comment

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

fix lgtm. Would even add a big red warning sign and a 😱 .

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: do not even call them *Clone, better shadow them. Avoid that somebody chooses the wrong PVC by accident.

Copy link
Member

Choose a reason for hiding this comment

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

ack, I think that is sensible I wrote upstream code. :((

@sttts sttts added the kind/bug Categorizes issue or PR as related to a bug. label Dec 19, 2017
@sttts
Copy link
Contributor

sttts commented Dec 19, 2017

/approve

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, sttts

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 19, 2017
if newPvc.Status.Phase == core.ClaimBound && newPVCSpecCopy.Resources.Requests != nil {
newPVCSpecCopy.Resources.Requests["storage"] = oldPvc.Spec.Resources.Requests["storage"]
if newPvc.Status.Phase == core.ClaimBound && newPvcClone.Spec.Resources.Requests != nil {
newPvcClone.Spec.Resources.Requests["storage"] = oldPvc.Spec.Resources.Requests["storage"]
}

oldSize := oldPvc.Spec.Resources.Requests["storage"]
newSize := newPvc.Spec.Resources.Requests["storage"]
Copy link
Contributor

Choose a reason for hiding this comment

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

this is still so much spaghetti here that newSize is the value without the mutation above.

Copy link
Member

Choose a reason for hiding this comment

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

hrm, why would we pick newSize from mutated spec? because that will simply return old size...

Copy link
Contributor

Choose a reason for hiding this comment

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

The logic in the code is correct. But it is hard to read when you have the original and the clone in the context.

Copy link
Contributor

Choose a reason for hiding this comment

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

at least call it originalNewSize or something explicit like that.

@deads2k deads2k added the lgtm Indicates that a PR is ready to be merged. label Dec 19, 2017
@deads2k
Copy link
Contributor Author

deads2k commented Dec 19, 2017

fix lgtm. Would even add a big red warning sign and a .

This is a pick of an already merged pull upstream. I'm taking this to be good enough to tag.

@deads2k
Copy link
Contributor Author

deads2k commented Dec 19, 2017

#17811
#17882

/retest

@deads2k
Copy link
Contributor Author

deads2k commented Dec 19, 2017

/retest

1 similar comment
@deads2k
Copy link
Contributor Author

deads2k commented Dec 19, 2017

/retest

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue.

@openshift-merge-robot openshift-merge-robot merged commit 5fceec5 into openshift:master Dec 20, 2017
@deads2k deads2k deleted the server-55-pvcmutation branch January 24, 2018 14:38
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. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. queue/critical-fix vendor-update Touching vendor dir or related files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pkg/apis/core/validation TestValidatePersistentVolumeClaimUpdate 0.01s
5 participants