[release-0.49] Optimize init pool: Reduce webhook API calls#573
Merged
kubevirt-bot merged 5 commits intok8snetworkplumbingwg:release-0.49from Nov 6, 2025
Conversation
Collaborator
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: qinqon The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Currently createPoolManager is only creating poolManager for opt-out mode. This is used by all tests for now. Introduce an optMode option to also allow setting opt-in poolManager. This will be used in future commits in order to check opt-in mode. This commit does not change any logic in code. Signed-off-by: Ram Lavi <ralavi@redhat.com>
Currently the unit test checks the private function isNamespaceSelectorCompatibleWithOptModeLabel. Refactor the unit test to check the public function IsNamespaceManaged instead. Testing public functions rather than private ones ensures tests remain stable during internal refactoring and better validates the actual behavior exposed to consumers of the API. This will be beneficial for when we replace this private function by another in future commits. This commit does not change the test logic, it maintains the same test coverage for both VMs and Pods across all opt-mode scenarios. Assisted-by: Claude <noreply@anthropic.com> Signed-off-by: Ram Lavi <ralavi@redhat.com>
Reduce the function param signature, to send only what is needed. Fix error message format. No logic is changed in this commit. Signed-off-by: Ram Lavi <ralavi@redhat.com>
Refactoring IsNamespaceManaged function, using a new private function isNamespaceManagedFromObject to check purely the "is namespace managed" logic, but without kubeAPI calls, by getting everything it needs as input params. This will be used in future commits in order to check the logic of InitMaps without using kubeAPI on every call to isNamespaceManagedFromObject. Signed-off-by: Ram Lavi <ralavi@redhat.com>
Currently for every ns we fetch the webhook config, which is a redundant API call. Refactor to only call the webhook once, then pass to the functions that checks if the namespace is managed, using the private function isNamespaceManagedFromObject. This significantly increases the performance of the InitMaps function in cases where many namespaces are managed. The logic of the functions is not changed. Signed-off-by: Ram Lavi <ralavi@redhat.com>
391627f to
5ace212
Compare
Member
Author
|
Change: Added the OptMode option to createPoolManager on migratelegacyconfigmap_test.go as well (this file is not present on the main branch). |
Member
|
/lgtm |
fde7cd3
into
k8snetworkplumbingwg:release-0.49
4 of 5 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
This PR is a manual cherry pick of #572
Special notes for your reviewer:
Release note: