Skip to content

Commit 88a2a7f

Browse files
CherryPicked: [cnv-4.21] [VIRT] Descheduler: Limit pod count to 85% to prevent VM preemption (#5114)
Cherry-pick from `main` branch, original PR: #5030, PR owner: dshchedr Signed-off-by: Den Shchedrivyi <dshchedr@redhat.com> Co-authored-by: Den Shchedrivyi <dshchedr@redhat.com>
1 parent 2021978 commit 88a2a7f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tests/virt/node/descheduler/conftest.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,14 @@ def unallocated_pod_count(
213213
node_with_least_available_memory,
214214
):
215215
non_terminated_pod_count = len(get_non_terminated_pods(client=admin_client, node=node_with_least_available_memory))
216-
return int(node_with_least_available_memory.instance.status.capacity.pods) - non_terminated_pod_count
216+
capacity = int(node_with_least_available_memory.instance.status.capacity.pods)
217+
# Target 85% utilization: high enough to trigger descheduler (>70%) but below scheduler preemption threshold
218+
target_pod_count = int(capacity * 0.85)
219+
pods_to_add = max(0, target_pod_count - non_terminated_pod_count)
220+
LOGGER.info(
221+
f"Node {node_with_least_available_memory.name}: current pods {non_terminated_pod_count}, will add {pods_to_add}"
222+
)
223+
return pods_to_add
217224

218225

219226
@pytest.fixture(scope="class")

0 commit comments

Comments
 (0)