Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions modules/python/clusterloader2/autoscale/autoscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from utils.common import str2bool
from utils.logger_config import get_logger, setup_logging

CPU_SCALE_FACTOR = 0.85

setup_logging()
logger = get_logger(__name__)

Expand Down Expand Up @@ -218,8 +220,8 @@ def calculate_cpu_request_for_clusterloader2(
# Calculate the cpu request for each pod
pods_per_node = pod_count // node_count
cpu_request = cpu_value // pods_per_node
# Consider 5% less CPU request for deployment pods
cpu_request = int(cpu_request * 0.95)
# Consider 15% less CPU request for deployment pods
cpu_request = int(cpu_request * CPU_SCALE_FACTOR)
return cpu_request


Expand Down
7 changes: 4 additions & 3 deletions modules/python/tests/test_autoscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
override_config_clusterloader2,
execute_clusterloader2,
collect_clusterloader2,
main
main,
CPU_SCALE_FACTOR,
)
from kubernetes.client.models import (
V1Node, V1NodeStatus, V1NodeCondition, V1NodeSpec, V1ObjectMeta, V1Pod, V1PodSpec
Expand Down Expand Up @@ -67,8 +68,8 @@ def test_calculate_cpu_request_with_warmup_success(self, mock_cleanup, mock_kube
without_warmup_cpu_request = calculate_cpu_request_for_clusterloader2('{"autoscaler": "true"}', 1, 1, 'false', '/mock/path', 'warmup_deployment.yaml')

# Assert the CPU request calculation
self.assertEqual(with_warmup_cpu_request, 1800*0.95) # 2000m - 100m (allocated) - 100m (warmup)
self.assertEqual(without_warmup_cpu_request, 1900*0.95) # 2000m - 100m (allocated)
self.assertEqual(with_warmup_cpu_request, int(1800 * CPU_SCALE_FACTOR)) # 2000m - 100m (allocated) - 100m (warmup)
self.assertEqual(without_warmup_cpu_request, int(1900 * CPU_SCALE_FACTOR)) # 2000m - 100m (allocated)

# Assert cleanup is called
mock_cleanup.assert_called_once_with('/mock/path', 'warmup_deployment.yaml')
Expand Down
Loading