-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
UPSTREAM: 57214: Remove mutation from pvc validation #17876
Conversation
@@ -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() |
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.
fix lgtm. Would even add a big red warning sign and a 😱 .
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.
nit: do not even call them *Clone
, better shadow them. Avoid that somebody chooses the wrong PVC by accident.
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.
ack, I think that is sensible I wrote upstream code. :((
/approve |
[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 |
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"] |
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.
this is still so much spaghetti here that newSize
is the value without the mutation above.
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.
hrm, why would we pick newSize from mutated spec? because that will simply return old size...
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.
The logic in the code is correct. But it is hard to read when you have the original and the clone in the context.
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.
at least call it originalNewSize
or something explicit like that.
This is a pick of an already merged pull upstream. I'm taking this to be good enough to tag. |
/retest |
1 similar comment
/retest |
Automatic merge from submit-queue. |
fixes #17769
/assign gnufied
/assign sttts