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

add validations for spec.topologySpreadConstraints #8273

Merged
merged 1 commit into from Aug 11, 2022

Conversation

alaypatel07
Copy link
Contributor

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:

add server-side validations for spec.topologySpreadConstraints during object creation

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/L labels Aug 11, 2022
@kubevirt-bot kubevirt-bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 11, 2022
@kubevirt-bot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@alaypatel07 alaypatel07 force-pushed the validate-topology-spread branch 2 times, most recently from 63af91b to d0836b9 Compare August 11, 2022 02:20
@alaypatel07 alaypatel07 marked this pull request as ready for review August 11, 2022 02:21
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 11, 2022
Copy link
Contributor

@vasiliy-ul vasiliy-ul left a comment

Choose a reason for hiding this comment

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

/ok-to-test

Comment on lines 4343 to 4358
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)
Copy link
Contributor

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.

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 think so, will update

Copy link
Contributor Author

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

Copy link
Contributor

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.

@kubevirt-bot kubevirt-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 11, 2022
@rmohr
Copy link
Member

rmohr commented Aug 11, 2022

/approve

happy if @vasiliy-ul can conclude the review.

@kubevirt-bot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 11, 2022
@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 11, 2022
@alaypatel07
Copy link
Contributor Author

/hold

Trying out suggestions from @vasiliy-ul

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 11, 2022
Signed-off-by: Alay Patel <alayp@nvidia.com>
@alaypatel07
Copy link
Contributor Author

/hold cancel

@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 11, 2022
@alaypatel07
Copy link
Contributor Author

/refresh

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 11, 2022
Copy link
Contributor

@vasiliy-ul vasiliy-ul left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks 👍

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 11, 2022
@kubevirt-bot
Copy link
Contributor

kubevirt-bot commented Aug 11, 2022

@alaypatel07: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubevirt-fossa 392ee0c link false /test pull-kubevirt-fossa

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.

@alaypatel07
Copy link
Contributor Author

• [SLOW TEST] [13.016 seconds]
KubeVirt Operator On install strategy dump should generate latest install strategy and post as config map
pkg/virt-operator/kubevirt_test.go:2990
------------------------------
-- Test timed out at 2022-08-11 15:17:11 UTC --
================================================================================

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

@rmohr
Copy link
Member

rmohr commented Aug 11, 2022

/retest-required

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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add validation for topology spread constraints
4 participants