degica / barcelona

PaaS built on top of AWS
MIT License
52 stars 6 forks source link

Update service count in place #733

Closed davidsiaw closed 2 years ago

davidsiaw commented 2 years ago

Previously we used the heritage deploy service to set the task count desired. The issue with this was that the heritage deployer would always create a new task definition, and then deploy that. This meant that ECS would create a new set of tasks with the new count before removing the old set of tasks. This resulted in if you wanted to scale a service from 10 to 20 tasks, you would have a transient situation of 30 tasks online.

This was suboptimal, and this PR fixes that. It calls ECS directly to modify the task count, and updates the db so non-changes do not get propagated.

How to test

You can use a local ver to test it on any account you have

  1. bcn login https://mytestbarcelona
  2. bcn district create --region ap-northeast-1 test
  3. bcn endpoint create -d test --public hello
  4. cd barcelona-hello <- this is just the barcelona hello repo
  5. bcn create -e hello -d test
  6. bcn api post /districts/test/heritages/hello/services/web/count '{"desired_container_count": 2}'

note that no new task definition is created but the container count is immediately updated.

degicat commented 2 years ago

@essa can you help us review this PR, please?

degicat commented 2 years ago

@kenta-s can you help us review this PR, please?

davidsiaw commented 2 years ago

@essa @kenta-s I added some error handling. Please have another look. Thanks.