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

Fixed up family dependencies with logical and compose names #753

Merged
merged 1 commit into from
Apr 22, 2024
Merged
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
34 changes: 20 additions & 14 deletions ecs_composex/ecs/ecs_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,31 @@ def initialize_family_services(


def handle_families_dependencies(
settings: ComposeXSettings, families_post: list
settings: ComposeXSettings, families_post: list[tuple[str, str]]
) -> None:
"""
Function to handle family to family services based on docker compose depends_on

:param ecs_composex.common.settings.ComposeXSettings settings:
:param list families_post:
Function to handle family to family services based on docker compose depends_on.
Given the stack name and the family (services) name can be different due to special chars,
we need to evaluate each of the families for both names to make sure to find it.
"""
for family in families_post:
for family_name in settings.families[family].services_depends_on:
if family_name not in families_post:
for family_def in families_post:
_family_title, _family_name = family_def
for family_name in settings.families[_family_title].services_depends_on:
for __family_title, __family_def in settings.families.items():
if __family_def.name == family_name:
family_title = __family_title
break
else:
continue
if (
family_name not in settings.families[family].stack.DependsOn
and family_name != settings.families[family].name
family_title not in settings.families[_family_title].stack.DependsOn
and family_title != settings.families[_family_title].name
):
LOG.info(f"Adding dependency between {family_name} and {family}")
settings.families[family].stack.DependsOn.append(
settings.families[family_name].stack.title
LOG.info(
f"Adding dependency between {family_name}|{family_title} and {_family_name}|{_family_title}"
)
settings.families[_family_title].stack.DependsOn.append(
settings.families[family_title].stack.title
)


Expand Down Expand Up @@ -133,7 +139,7 @@ def add_compose_families(
family.validate_compute_configuration_for_task(settings)

families_stacks = [
family
(family, settings.families[family].name)
for family in settings.root_stack.stack_template.resources
if (
family in settings.families
Expand Down
Loading