We use machine learning technology to do auto-translation. Click "English" on top navigation bar to check Chinese version.
Improving operational visibility with Amazon Web Services Fargate task retirement notifications
Introduction
Amazon Web Services has recently updated the Amazon Web Services Fargate task retirement process, consolidating the
Background
When deploying an
Over time, Amazon Web Services may determine that an existing platform version revision that is supporting running tasks needs to be retired. When a revision is retired, all tasks running on that revision will be stopped by Amazon Web Services Fargate. There are a number of reasons why a revision may need to be retired, including security vulnerabilities and performance improvements. In the past Amazon Web Services Fargate has retired one to two platform version revisions each month, however there is no fixed support period for a particular platform version revision. Due to the typical life span of a platform version revision, customers with short lived workloads will experience far fewer task retirements then a customer with a task running for multiple weeks.
The diagram above shows the full lifecycle of an Amazon Web Services Fargate platform version revision. Once a new platform version revision is launched, all new tasks will be scheduled on to this revision. Existing tasks that have already been scheduled and running will remain on the revision they were originally placed on for the duration of the task and will not be migrated to the new revision. If the task is replaced, for example as part of an
Task retirement
The following diagram shows the end-to-end process of Amazon Web Services Fargate task retirement.
When Amazon Web Services marks a platform version revision as needing to be retired, we identify all of the tasks that are running on that platform version revision in all Amazon Web Services Regions. We then send out one notification per account per Region, highlighting the affected tasks or services and a date when the retirements will start to take place. The notification is sent via email to the primary email contact on the Amazon Web Services account, as well as to the
Once a notification has been sent, a customer has a period of time (known as the task retirement wait period) to take manual action if they want to control the exact timing before Amazon Web Services Fargate initiates the automatic task retirement process. When Amazon Web Services Fargate stops a task, if the task is part of an ECS service, it will be stopped respecting the service’s
To minimalize the impact of Amazon Web Services Fargate task retirement, workloads should be deployed following
For more information on the task retirement process, see the
Task retirement wait period
The length of the task retirement wait period can now be controlled by a new
fargateTaskRetirementWaitPeriod
. Before Amazon Web Services Fargate will stop a task for task retirement, customers can leverage the task retirement wait period to stop tasks on their own schedule, for example if they have workloads that can only be stopped in a specific window.
The task retirement wait period can be configured to one of the set time intervals in the table below. We recommend biasing towards a shorter wait period where possible, to pick up new platform version revisions sooner.
Days | Action |
0 | Amazon Web Services sends the notification and immediately starts to retire affected tasks. |
7 | Amazon Web Services sends the notification and waits 7 calendar days before starting to retire affected tasks. |
14 | Amazon Web Services sends the notification and waits 14 calendar days before starting to retire affected tasks. |
In the rare scenario of a critical security update, Amazon Web Services Fargate may override this task retirement wait period, sending a task retirement notification and immediately retiring the affected tasks. Mirroring the effect of setting the fargateTaskRetirementWaitPeriod
to 0
.
The existing fargateTaskRetirementWaitPeriod
value can be seen with the aws ecs list-account-settings
command.
The fargateTaskRetirementWaitPeriod
can be configured with the aws ecs put-account-setting-default
command.
For more information on the task retirement wait time, see the
Solution overview: Capturing task retirement notifications
When there is an upcoming task retirement, Amazon Web Services sends a
Event Detail Type: "AWS Health Event"
and the Event Detail Type Code: "AWS_ECS_TASK_PATCHING_RETIREMENT"
. Once the rule has captured a notification, it will trigger an
The following diagram below shows the high-level architecture of this solution.
Prerequisites
To complete the walkthrough, the following prerequisites need to be in place:
- An existing Slack workspace with the
Incoming Webhook Slack application installed and enabled. - An Amazon Web Services account with the relevant permissions to deploy an Amazon EventBridge rule and Amazon Web Services Lambda function.
- The
Amazon Web Services SAM CLI installed and configured on a local development workstation.
Solution walkthrough
- The sample code of the walkthrough is stored in a
GitHub repository . The first step of this walkthrough is to clone the repository to a local development workstation.
- Next, we build and deploy the Lambda function and the EventBridge rule defined in an Amazon Web Services SAM template
cloudformation.yaml
. Note you will need to enter parameters in to the deployment wizard, including your Slack workspace URI and Slack channel.
- Test it! Here we send two sample events to Amazon EventBridge to ensure everything is working correctly. Because we are unable to simulate Amazon Web Services Health notifications, we will instead trigger the workflow by creating EventBridge events that match the EventBridge rule. There are two events in the sample repository, one for tasks attached to an Amazon ECS service and one for standalone tasks.
- In your Slack workspace, you should now see two Slack notifications, one for each test event.
Clean Up
To clean up the sample walkthrough, use the Amazon Web Services SAM CLI to remove the CloudFormation stack with $ sam delete
.
Conclusion
In this blog post, we dived deep into the Amazon Web Services Fargate task retirement process. We have shown how the task retirement wait period can be adjusted if customers want to control the time between a notification and a retirement. Finally, we have shown how customers can capture task retirement notifications with Amazon EventBridge and Amazon Web Services Lambda. To learn more about the Amazon Web Services Fargate task retirement, please the
The mentioned AWS GenAI Services service names relating to generative AI are only available or previewed in the Global Regions. Amazon Web Services China promotes AWS GenAI Services relating to generative AI solely for China-to-global business purposes and/or advanced technology introduction.