Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix ecs_composex.ecs.ecs_family.ComposeFamily.task_ephemeral_storage #719 #720

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: 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
Loading