Skip to content

Commit 69535a4

Browse files
authored
[VIRT] Restart descheduler-operator before running tests (#5133)
Add descheduler_operator_reconciled fixture that restarts the descheduler-operator deployment before creating KubeDescheduler objects. This ensures the operator reconciles after all OpenShift operators are installed, properly protecting all "openshift-*" namespaces from eviction. Without this, descheduler evicts pods from openshift-cnv namespace. Co-Authored-By: Claude Sonnet 4.5 ##### What this PR does / why we need it: Adds a module-scoped fixture that restarts the descheduler-operator deployment to trigger reconciliation, ensuring proper namespace protection before running descheduler tests. ##### Which issue(s) this PR fixes: ##### Special notes for reviewer: ##### jira-ticket: <!-- full-ticket-url needs to be provided. This would add a link to the pull request to the jira and close it when the pull request is merged If the task is not tracked by a Jira ticket, just write "NONE". --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Enhanced descheduler test suite with improved operator reconciliation verification to ensure consistent test execution. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Denys Shchedrivyi <dshchedr@redhat.com>
1 parent 4358368 commit 69535a4

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

tests/virt/node/descheduler/conftest.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
get_boot_time_for_multiple_vms,
2727
get_non_terminated_pods,
2828
)
29-
from utilities.constants import TIMEOUT_5MIN, TIMEOUT_5SEC
29+
from utilities.constants import TIMEOUT_5MIN, TIMEOUT_5SEC, NamespacesNames
3030
from utilities.infra import wait_for_pods_deletion
3131
from utilities.virt import wait_for_migration_finished
3232

@@ -36,8 +36,28 @@
3636
LOCALHOST = "localhost"
3737

3838

39+
@pytest.fixture(scope="package")
40+
def descheduler_operator_reconciled():
41+
"""Restart descheduler-operator deployment to trigger reconciliation.
42+
43+
Workaround for the issue when descheduler is installed before other OpenShift operators.
44+
After restart, the operator reconciles and adds all namespaces with prefix "openshift-"
45+
to the protected list.
46+
"""
47+
LOGGER.info("Restarting descheduler-operator deployment to trigger reconciliation")
48+
deployment = Deployment(
49+
name="descheduler-operator",
50+
namespace=NamespacesNames.OPENSHIFT_KUBE_DESCHEDULER_OPERATOR,
51+
)
52+
initial_replicas = deployment.instance.spec.replicas
53+
deployment.scale_replicas(replica_count=0)
54+
deployment.wait_for_replicas(deployed=False)
55+
deployment.scale_replicas(replica_count=initial_replicas)
56+
deployment.wait_for_replicas()
57+
58+
3959
@pytest.fixture(scope="module")
40-
def descheduler_long_lifecycle_profile(admin_client):
60+
def descheduler_long_lifecycle_profile(admin_client, descheduler_operator_reconciled):
4161
with create_kube_descheduler(
4262
admin_client=admin_client,
4363
profiles=["LongLifecycle"],
@@ -53,6 +73,7 @@ def descheduler_long_lifecycle_profile(admin_client):
5373
def descheduler_kubevirt_relieve_and_migrate_profile(
5474
admin_client,
5575
schedulable_nodes,
76+
descheduler_operator_reconciled,
5677
nodes_taints_before_descheduler_test_run,
5778
):
5879
with create_kube_descheduler(

0 commit comments

Comments
 (0)