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
virt-api, admitter: Refactor & move network validation admitters to the network package #11511
Conversation
Skipping CI for Draft Pull Request. |
/test pull-kubevirt-build |
77154c0
to
d01e238
Compare
/test pull-kubevirt-build |
d01e238
to
8a458c6
Compare
/test pull-kubevirt-build |
1 similar comment
/test pull-kubevirt-build |
Flaky unit test unrelated to this change: https://prow.ci.kubevirt.io/view/gs/kubevirt-prow/pr-logs/pull/kubevirt_kubevirt/11511/pull-kubevirt-unit-test/1768243142961664000 /test pull-kubevirt-unit-test |
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.
Hi Edy, thanks for the PR
I the network related addmiters code is moved to pkg/network
, how about keep it under pkg/virt-api/webhooks/validating-webhook/admitters/
but in new dir for network: pkg/virt-api/webhooks/validating-webhook/admitters/network
?
Since the code is tightly related to the webhook and slirp/ iface APIs, I think it make more sense leaving it closer to to the consuming package.
It may also encourage other sigs who doesn't aggregate all related code under pkg/ move their related content in similar why to what I suggest.
This decision was already made when the Most of the current |
ac9d8b9
to
99a546d
Compare
change: Fix a bug detected during the review. |
I was under the impression this PR introduce |
99a546d
to
e24ff7a
Compare
change: Rebase |
@@ -284,6 +284,7 @@ func validateNetworksMatchInterfaces(field *k8sfield.Path, spec *v1.VirtualMachi | |||
|
|||
networkData, networkExists := networkNameMap[iface.Name] | |||
|
|||
causes = append(causes, netadmitter.ValidateSlirpBinding(field, spec, config)...) |
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 method should be outside of the for loop.
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.
Done
} | ||
|
||
if net.Pod == nil { | ||
causes = append(causes, metav1.StatusCause{ |
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.
Shouldn't it also support multus network with default
true?
Well, if it wasn't supported till now I believe we shouldn't start supporting it now the feature is going to be deprecated.
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.
It was not supported per what I understand.
pkg/virt-api/webhooks/validating-webhook/admitters/vmi-create-admitter_test.go
Show resolved
Hide resolved
e24ff7a
to
108a131
Compare
change: Answered a review comment to move out the slirp validation outside the for-loop. |
Signed-off-by: Edward Haas <edwardh@redhat.com>
Signed-off-by: Edward Haas <edwardh@redhat.com>
Signed-off-by: Edward Haas <edwardh@redhat.com>
Relocate the slirp admitter validations to the network/admitter package. Simplify the implementation and provide clear unit tests to the various checks. Signed-off-by: Edward Haas <edwardh@redhat.com>
Signed-off-by: Edward Haas <edwardh@redhat.com>
Use interfaces on the validation function to ease its testing. By using a focused interface, the tests now can use a simple stub instead of a complex fake. Signed-off-by: Edward Haas <edwardh@redhat.com>
108a131
to
9d3867f
Compare
change: Rebase |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AlonaKaplan 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 |
/sig code-quality |
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.
/lgtm
@@ -15,11 +15,15 @@ go_library( | |||
|
|||
go_test( | |||
name = "go_default_test", | |||
srcs = ["admit_test.go"], | |||
srcs = [ |
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: please consider moving this commit to before the test is moved.
Required labels detected, running phase 2 presubmits: |
/test pull-kubevirt-e2e-k8s-1.29-sig-compute-migrations |
What this PR does
Validation admitters related to network spec are moved under the network package in order to decouple them from the other admitters and allow the sig-network to properly own them.
In addition, work on simplifying the validation code and its tests has been included in this effort.
Fixes #
Why we need it and why it was done in this way
The following tradeoffs were made:
The following alternatives were considered:
Links to places where the discussion took place:
Special notes for your reviewer
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
Release note