-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
add validations for spec.topologySpreadConstraints #8273
add validations for spec.topologySpreadConstraints #8273
Conversation
Hi @alaypatel07. Thanks for your PR. I'm waiting for a kubevirt member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
63af91b
to
d0836b9
Compare
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.
/ok-to-test
vmi.Spec.TopologySpreadConstraints = nil | ||
vmiBytes, _ := json.Marshal(&vmi) | ||
|
||
ar := &admissionv1.AdmissionReview{ | ||
Request: &admissionv1.AdmissionRequest{ | ||
Resource: webhooks.VirtualMachineInstanceGroupVersionResource, | ||
Object: runtime.RawExtension{ | ||
Raw: vmiBytes, | ||
}, | ||
}, | ||
} | ||
|
||
resp := vmiCreateAdmitter.Admit(ar) |
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.
Would it make sense to create a function that sets the given TopologySpreadConstraints
for the vmi
? The above code seems to be used in all the tests. This will reduce duplication.
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 think so, will update
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.
@vasiliy-ul I see that a lot of code duplication is happening due to
ar := &admissionv1.AdmissionReview{
Request: &admissionv1.AdmissionRequest{
Resource: webhooks.VirtualMachineInstanceGroupVersionResource,
Object: runtime.RawExtension{
Raw: vmiBytes,
},
},
}
resp := vmiCreateAdmitter.Admit(ar)
And that is across all the tests. Since the scope of that is larger, can I take that up in a follow up cleanup PR? or may be address in #8239
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.
Still, I would consider creating a local helper function within the topologySpreadConstraints context scope with the following content:
vmi.Spec.TopologySpreadConstraints = topologySpreadConstraints
vmiBytes, _ := json.Marshal(&vmi)
ar := &admissionv1.AdmissionReview{
Request: &admissionv1.AdmissionRequest{
Resource: webhooks.VirtualMachineInstanceGroupVersionResource,
Object: runtime.RawExtension{
Raw: vmiBytes,
},
},
}
return vmiCreateAdmitter.Admit(ar)
This will not extend the current scope.
But I do not insist. If you prefer to do that outside of this PR I am okay with that.
/approve happy if @vasiliy-ul can conclude the review. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rmohr The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold Trying out suggestions from @vasiliy-ul |
Signed-off-by: Alay Patel <alayp@nvidia.com>
d0836b9
to
392ee0c
Compare
/hold cancel |
/refresh |
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.
Looks good. Thanks 👍
@alaypatel07: The following test failed, say
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. |
Failure looks unrelated to the changes https://prow.ci.kubevirt.io/view/gs/kubevirt-prow/pr-logs/pull/kubevirt_kubevirt/8273/pull-kubevirt-unit-test/1557741671075024896 |
/retest-required |
Signed-off-by: Alay Patel alayp@nvidia.com
What this PR does / why we need it:
This PR adds validation for spec.topologySpreadConstraints field which was introduced in #7846
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 #8250
Special notes for your reviewer:
Release note: