Skip to content

Comments

[release-0.49] Optimize init pool: Reduce webhook API calls#573

Merged
kubevirt-bot merged 5 commits intok8snetworkplumbingwg:release-0.49from
RamLavi:release-0.49_optimize_init_pool_multiple_ns
Nov 6, 2025
Merged

[release-0.49] Optimize init pool: Reduce webhook API calls#573
kubevirt-bot merged 5 commits intok8snetworkplumbingwg:release-0.49from
RamLavi:release-0.49_optimize_init_pool_multiple_ns

Conversation

@RamLavi
Copy link
Member

@RamLavi RamLavi commented Nov 5, 2025

What this PR does / why we need it:
This PR is a manual cherry pick of #572

Special notes for your reviewer:

Release note:

Optimize internal cache setup duration by reducing redundant API calls.

Copy link
Member

@qinqon qinqon left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@kubevirt-bot
Copy link
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

Details 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

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>
@RamLavi RamLavi force-pushed the release-0.49_optimize_init_pool_multiple_ns branch from 391627f to 5ace212 Compare November 6, 2025 07:52
@kubevirt-bot kubevirt-bot removed the lgtm label Nov 6, 2025
@RamLavi
Copy link
Member Author

RamLavi commented Nov 6, 2025

Change: Added the OptMode option to createPoolManager on migratelegacyconfigmap_test.go as well (this file is not present on the main branch).

@qinqon
Copy link
Member

qinqon commented Nov 6, 2025

/lgtm
/retest
transitory error

+ /tmp/kubemacpool/kubemacpool/_kubevirtci//cluster-up/down.sh
selecting podman as container runtime
Trying to pull quay.io/kubevirtci/gocli:2408151028-a0ad3359...
Error: initializing source docker://quay.io/kubevirtci/gocli:2408151028-a0ad3359: pinging container registry quay.io: Get "https://quay.io/v2/": proxyconnect tcp: dial tcp 172.30.251.153:3128: connect: connection refused
make: *** [Makefile:138: cluster-down] Error 125
+ EXIT_VALUE=2

@kubevirt-bot kubevirt-bot merged commit fde7cd3 into k8snetworkplumbingwg:release-0.49 Nov 6, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants