Skip to content

Commit 7481456

Browse files
authored
Fix CPU allocation on single required container (#779)
* Fixing condition where no managed sidecar but single required container should get all the CPU
1 parent b742ccc commit 7481456

2 files changed

Lines changed: 75 additions & 68 deletions

File tree

ecs_composex/ecs/task_compute/helpers.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from troposphere import If, NoValue
1212

13+
from ecs_composex.common.logging import LOG
1314
from ecs_composex.ecs.ecs_conditions import USE_FARGATE_CON_T
1415

1516

@@ -44,9 +45,6 @@ def handle_multi_services(sidecar_used_memory: int, family: ComposeFamily) -> No
4445
"""
4546
Identifies the essential containers. If there is only one, we assume that's the one
4647
that would make use of the left-over CPU/RAM from the Fargate profile
47-
48-
:param int sidecar_used_memory:
49-
:param ComposeFamily family:
5048
"""
5149
essential_containers = []
5250
containers_used_ram = 0
@@ -76,8 +74,6 @@ def unlock_compute_for_main_container(family: ComposeFamily) -> None:
7674
7775
This aims to identify the main service running in the family and grant it to us
7876
all unreserved CPU/RAM of the task
79-
80-
:param family:
8177
"""
8278
if len(family.ordered_services) == 1 and not family.managed_sidecars:
8379
reset_for_single_main_container(
@@ -98,3 +94,9 @@ def unlock_compute_for_main_container(family: ComposeFamily) -> None:
9894
)
9995
else:
10096
handle_multi_services(sidecar_used_memory, family)
97+
elif family.ordered_services and not family.managed_sidecars:
98+
handle_multi_services(sidecar_used_memory, family)
99+
else:
100+
LOG.warning(
101+
f"{family.name} - Unable to define services compute config to optimize."
102+
)

0 commit comments

Comments
 (0)