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

Adding load balancer causes ecs_composex up to fail #175

Closed
delahayethierry opened this issue Aug 28, 2020 · 5 comments · Fixed by #176
Closed

Adding load balancer causes ecs_composex up to fail #175

delahayethierry opened this issue Aug 28, 2020 · 5 comments · Fixed by #176
Assignees
Labels
bug Something isn't working

Comments

@delahayethierry
Copy link

Describe the bug
A clear and concise description of what the bug is.

Issue when creating stack that needs a load balancer.

To Reproduce
Steps to reproduce the behavior:

  1. How you installed ECS ComposeX'...'

  2. How you are executing it ? : As a CLI tool, as a library, in lambda?

  3. Link / share your Docker compose file

  4. See error

  5. Installed ECS ComposeX with "pip install ecs_composex" with python 3.7

  6. We execute it as part of a shell script:
    ecs_composex up -f docker_compose.yml -d outputs -n outputname -b dashboard-cfn-templates

  7. Docker compose file (with project name replaced):

x-configs:
  project-forecast:
    network:
      is_public: True
      lb_type: network
      use_cloudmap: True

services:
  project-forecast:
    environment:
      NAME: DASHBOARD
    image: accountnb.dkr.ecr.eu-west-1.amazonaws.com/project-folder/project-forecast:latest
    ports:
      - 80:80
    deploy:
      replicas: 1
      resources:
        reservations:
          cpus: "1"
          memory: "2048M"

x-tags:
  - name: project
    value: project-forecast

Expected behavior
A clear and concise description of what you expected to happen.

We'd expect the shell script to create the stack on AWS cloudformation

Logs
If applicable, add logs of errors using from ECS ComposeX

2020-08-25 15:15:28 [INFO], No x-vpc detected. Creating a new VPC.
2020-08-25 15:15:28 [INFO], cluster.lan
Traceback (most recent call last):
  File “/Users/user/dev/1a/covid-19/dashboard/venv/bin/ecs_composex”, line 10, in <module>
    sys.exit(main())
  File “/Users/user/dev/1a/covid-19/dashboard/venv/lib/python3.7/site-packages/ecs_composex/cli.py”, line 179, in main
    root_stack = generate_full_template(settings)
  File “/Users/user/dev/1a/covid-19/dashboard/venv/lib/python3.7/site-packages/ecs_composex/ecs_composex.py”, line 331, in generate_full_template
    root_stack, settings, vpc_stack, dns_settings.nested_params, create_cluster
  File “/Users/user/dev/1a/covid-19/dashboard/venv/lib/python3.7/site-packages/ecs_composex/ecs_composex.py”, line 268, in create_services
    stack = ServicesStack(“services”, settings)
  File “/Users/user/dev/1a/covid-19/dashboard/venv/lib/python3.7/site-packages/ecs_composex/ecs/__init__.py”, line 113, in __init__
    services = generate_services(settings, cluster_sg)
  File “/Users/user/dev/1a/covid-19/dashboard/venv/lib/python3.7/site-packages/ecs_composex/ecs/ecs_template.py”, line 328, in generate_services
    services = handle_families_services(families, cluster_sg, settings)
  File “/Users/user/dev/1a/covid-19/dashboard/venv/lib/python3.7/site-packages/ecs_composex/ecs/ecs_template.py”, line 292, in handle_families_services
    settings=settings,
  File “/Users/user/dev/1a/covid-19/dashboard/venv/lib/python3.7/site-packages/ecs_composex/ecs/ecs_service.py”, line 363, in __init__
    self.define_service_ingress(settings)
  File “/Users/user/dev/1a/covid-19/dashboard/venv/lib/python3.7/site-packages/ecs_composex/ecs/ecs_service.py”, line 785, in define_service_ingress
    service_lb = self.add_service_load_balancer(settings)
  File “/Users/user/dev/1a/covid-19/dashboard/venv/lib/python3.7/site-packages/ecs_composex/ecs/ecs_service.py”, line 722, in add_service_load_balancer
    service_lb = self.add_load_balancer(settings)
  File “/Users/user/dev/1a/covid-19/dashboard/venv/lib/python3.7/site-packages/ecs_composex/ecs/ecs_service.py”, line 644, in add_load_balancer
    self.add_public_ips(settings.aws_azs)
  File “/Users/user/dev/1a/covid-19/dashboard/venv/lib/python3.7/site-packages/ecs_composex/ecs/ecs_service.py”, line 518, in add_public_ips
    f”EipPublicNlb{az.replace(‘-’, ‘’).strip()}{self.service_name}“,
AttributeError: ‘dict’ object has no attribute ‘replace’

Desktop (please complete the following information):

  • OS: [e.g. Fedora/Windows/Mac]
  • Python version (3.6,3.7,3.8)
  • If you were doing things from a branch, which one?
  • Commit ID ?
  • Tag/Version?

OS: Ubuntu 18.04, python version 3.7, latest ecs_composex version

@delahayethierry delahayethierry added the bug Something isn't working label Aug 28, 2020
@JohnPreston
Copy link
Member

JohnPreston commented Aug 29, 2020

Hi @delahayethierry Thanks for raising that error. I will have a look into this.
Can you just confirm for me the version you are using?
ecs-composex version

In the meantime, if you moved x-configs into the service definition in the form below, do you get the same error ?
If not that's definitely a bug to fix for me but that might unblock you.

services:
  project-forecast:
    x-configs:
      network:
        is_public: True
        lb_type: network
        use_cloudmap: True
    environment:
      NAME: DASHBOARD
    image: accountnb.dkr.ecr.eu-west-1.amazonaws.com/project-folder/project-forecast:latest
    ports:
      - 80:80
    deploy:
      replicas: 1
      resources:
        reservations:
          cpus: "1"
          memory: "2048M"

@JohnPreston JohnPreston linked a pull request Aug 29, 2020 that will close this issue
@JohnPreston
Copy link
Member

@delahayethierry Hello.
If you could do me a favor and try with your existing docker-compose file (as it is, which I used to try the code changes out with) then you should be good to go.
To install it on your local virtual environment, just do
pip uninstall ecs_composex ; pip install git+https://github.com/lambda-my-aws/ecs_composex@fix/nlbeip which would install ecs_composex from the branch fix. If then you run the command again and it generates the templates as expected (you can try with render) you should then be able to see the Eips and NLB.
Tried with NGINX as image, all worked.

@JohnPreston
Copy link
Member

@delahayethierry Merged to master, fixes a number of small issues.
If you could install it from master and try to confirm it's all good for you that'd be brilliant.

@JohnPreston
Copy link
Member

@delahayethierry any feedback ? Good to close this issue?

@JohnPreston
Copy link
Member

Thanks @delahayethierry
Without any feedback I am not closing this issue. Thanks for reporting it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants