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

ecs: support container definition's restart policy #31127

Closed
2 tasks
tmokmss opened this issue Aug 16, 2024 · 8 comments · Fixed by #31228
Closed
2 tasks

ecs: support container definition's restart policy #31127

tmokmss opened this issue Aug 16, 2024 · 8 comments · Fixed by #31228
Assignees
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p2

Comments

@tmokmss
Copy link
Contributor

tmokmss commented Aug 16, 2024

Describe the feature

Amazon Elastic Container Services (Amazon ECS) now improves container resiliency by giving you the ability to define a flexible container restart policy for restarting individual containers locally, without requiring a full task relaunch. With local container restarts, Amazon ECS can recover your containers from unexpected failures within a few seconds, enhancing your overall task stability by avoiding unnecessary task relaunches.

https://aws.amazon.com/about-aws/whats-new/2024/08/amazon-ecs-restart-containers-task-relaunch/

Use Case

automated container restarts in-place to recover your containers from transient failures such as network disruption or cases where your containers stop unexpectedly

Proposed Solution

Restart policy configuration is added to container definition in task definition. https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_restart_policy

Apparently CFn still does not support it yet though. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-taskdefinition-containerdefinition.html Maybe they are just updating docs?

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.152.0

Environment details (OS name and version, etc.)

macOS

@tmokmss tmokmss added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 16, 2024
@github-actions github-actions bot added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Aug 16, 2024
@ashishdhingra ashishdhingra self-assigned this Aug 16, 2024
@ashishdhingra ashishdhingra added p2 investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Aug 16, 2024
@ashishdhingra
Copy link
Contributor

@tmokmss Good morning. Thanks for opening the feature request. I'm unsure if restart policy is a new feature supported by Docker containers. The CloudFormationSchema::aws-ecs-taskdefinition.json and AWS::ECS::TaskDefinition ContainerDefinition doesn't appear to specify support for Restart policy. So looks like CloudFormation is yet to add support for restartPolicy.

I will open a ticket with CloudFormation team for their inputs.

Thanks,
Ashish

@ashishdhingra ashishdhingra added effort/small Small work item – less than a day of effort needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Aug 16, 2024
@ashishdhingra
Copy link
Contributor

Internal tracking ticket: P148765181

@ashishdhingra
Copy link
Contributor

Per CloudFormation support, this feature is not available in CFN yet. Opened a new issue aws-cloudformation/cloudformation-coverage-roadmap#2109 in CloudFormation coverage roadmap.

@sparrc
Copy link

sparrc commented Aug 30, 2024

Hello, this feature is now available in Cloudformation, can it now be added to CDK?

@ashishdhingra
Copy link
Contributor

Hello, this feature is now available in Cloudformation, can it now be added to CDK?

@sparrc The CFN spec aws-ecs-taskdefinition.json is not yet updated with the specification where RestartPolicy property has been supported in ContainerDefinition. As soon as the change is available there, CDK L1 constructs should be updated shortly thereafter.

@MartinKvL
Copy link

Looks like you guys implemented it: CDK-docs
Thanks a lot 👏

@ashishdhingra
Copy link
Contributor

Looks like you guys implemented it: CDK-docs
Thanks a lot 👏

@MartinKvL Glad it works for you now. Thanks.

@ashishdhingra ashishdhingra self-assigned this Sep 10, 2024
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2024
mergify bot pushed a commit that referenced this issue Sep 24, 2024
### Issue # (if applicable)

Closes #31127 #31425.

### Reason for this change



A restart policy can be specified in CloudFormation, but not in L2.

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/container-restart-policy.html

### Description of changes



Add `enableRestartPolicy` and some properties to the container definition.

### Description of how you validated changes



unit tests and integ tests.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https:/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https:/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants