-
Notifications
You must be signed in to change notification settings - Fork 4k
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
aws-cdk/hotswap: ecs hotswap not updating image in new task definition #27343
Comments
Hi thanks for reporting the issue, and I confirmed it reproduces. Sorry for inconvenience 🙏 From v2.93.0 (#26404), we hotswap ECS task definition in the following steps:
The root cause of this is the order of I guess we'd better revert #26404 for now, as it turned out to be unreliable (e.g. there can be more arrays that will get shuffled, but we don't know because it's undocumented). I'll create a PR later. In the mean time, you should be able to use hotswap properly on cdk v2.92.0. |
Thanks for confirming @tmokmss. #26404 allows ecs hotswap to work in the first place for an app like https://github.com/akbisw/localstack-sample/tree/main with references from other stacks as env vars 😓 so I think I'll be waiting a while 😢 |
Many thanks! @tmokmss |
CDK Team Member here. Thank you for reporting this. This does indeed look like a regression. I can see that @tmokmss has put in a PR for this - Thank you! |
…tain intrinsics" (#27358) Closes #27343 From v2.93.0 (#26404), we hotswap ECS task definition in the following steps: 1. Calculate patch from old/new CFn template 2. Apply the patch to the task definition fetched from describeTaskDefinition API 3. register the new task definition and update services The root cause of the issue #27343 is the order of containerDefinitions array is somehow shuffled when deployed to ECS, so the patch calculated from CFn template becomes invalid. For example, when the containerDefinitions in a CFn template is like below: ```json "ContainerDefinitions": [ { "Name": "main", "Image": "imageA" }, { "Name": "sidecar", "Image": "imageB" } ], ``` the deployed task definition can sometimes become like this: ```json "ContainerDefinitions": [ { "Name": "sidecar", "Image": "imageB" }, { "Name": "main", "Image": "imageA" } ], ``` This makes a patch calculated from CFn template diff completely invalid. We can sort both CFn template and the response of describeTaskDefinition API in a deterministic order, but it is still unreliable because there can be more arrays whose order will be shuffled. [The response of describeTaskDefinition](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeTaskDefinition.html#API_DescribeTaskDefinition_ResponseSyntax) has many array fields, and it is not documented if they may be shuffled or not. I guess we should completely abandon this approach, because it cannot be reliable enough. I have an idea for more reliable approach, but at least it should be reverted asap as it's breaking the ECS hotswap feature. I'm really sorry for me not being aware with this behavior 🙏 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Describe the bug
ECS Hotswap is supposed push a new image on change, create a new task definition and update ECS service with that new task definition.
It is doing all of that except updating the new image ARN in the new task definition. Hotswap is effectively swapping in old code.
Expected Behavior
When there is code change, I expect new image to be built, uploaded to ECR and task definition updated with that new image.
Current Behavior
hotswap command completes without errors
This ecs service has 3 containers:
web-api
datadog-agent
log_router
In the logs we see that web-api image and datadog-agent image is being built due to code changes:
But only datadog-agent image is updated in the task definition. Web-api image does not change or match the one that was just published:
b03bf6f842d1d9783f11fe80fd3d324a3d47f2f4bbc14552fe97cbaf2ff99ccd matches the logs above. 8a2e97dddc47d3dc5151a4d29b812f2f5e5fb0921283f821cad6cf58086a3a73 does not
Note that web-api marked as the only essential container.
Reproduction Steps
Simplified version of the ECS app:
https://github.com/akbisw/localstack-sample/tree/main
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.99.0
Framework Version
2.99.0
Node.js Version
v20.7.0
OS
macOS
Language
Python
Language Version
3.9.6
Other information
No response
The text was updated successfully, but these errors were encountered: