Skip to content

Commit

Permalink
Bugfix ecs_composex.ecs.ecs_family.ComposeFamily.task_ephemeral_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
thorfi authored Nov 29, 2023
1 parent 89f8292 commit 476bad5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
6 changes: 2 additions & 4 deletions ecs_composex/compose/compose_services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,7 @@ def container_start_condition(self, value):
@property
def ephemeral_storage(self):
storage_key = "ecs.ephemeral.storage"
storage_value = set_else_none(
storage_key, set_else_none("labels", self.deploy, alt_value={}), alt_value=0
)
storage_value = set_else_none(storage_key, self.deploy_labels, 0)
if isinstance(storage_value, (int, float)):
ephemeral_storage = int(storage_value)
elif isinstance(storage_value, str):
Expand All @@ -520,8 +518,8 @@ def ephemeral_storage(self):
)
if ephemeral_storage <= 21:
return 0

elif ephemeral_storage > 200:
LOG.warning(f"{self.name} - {storage_key} set to maximum 200 ({ephemeral_storage} > 200)")
return 200
else:
LOG.info(f"{self.name} - {storage_key} set to {ephemeral_storage}")
Expand Down
11 changes: 5 additions & 6 deletions ecs_composex/ecs/ecs_family/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(self, services: list[ComposeService], family_name):
self.xray_service = None
self.task_definition = None
self.service_tags = None
self.task_ephemeral_storage = 0
# self.task_ephemeral_storage = 0
self.enable_execute_command = False
self.ecs_service = None
self.runtime_cpu_arch = None
Expand Down Expand Up @@ -201,7 +201,7 @@ def set_task_definition(self):
EphemeralStorage(SizeInGiB=self.task_ephemeral_storage),
NoValue,
)
if 0 < self.task_ephemeral_storage >= 21
if self.task_ephemeral_storage >= 21
else NoValue,
InferenceAccelerators=NoValue,
IpcMode=If(
Expand Down Expand Up @@ -370,7 +370,6 @@ def add_service(self, service: ComposeService):
service.container_definition
)
self.set_secrets_access()
self.set_task_ephemeral_storage()
set_enable_execute_command(self)
set_family_hostname(self)

Expand Down Expand Up @@ -596,13 +595,13 @@ def set_services_to_services_dependencies(self):
if service_depends_on not in self.services_depends_on:
self.services_depends_on.append(service_depends_on)

def set_task_ephemeral_storage(self):
@property
def task_ephemeral_storage(self):
"""
If any service ephemeral storage is defined above, sets the ephemeral storage to the maximum of them.
"""
max_storage = max(service.ephemeral_storage for service in self.services)
if max_storage >= 21:
self.task_ephemeral_storage = max_storage
return max_storage if max_storage >= 21 else 0

def set_enable_execute_command(self) -> None:
"""
Expand Down

0 comments on commit 476bad5

Please sign in to comment.