Why did my ECS Fargate Spot task ignore the stopTimeout?

0
24
Asked By TechieBard7 On

I'm encountering an issue with my ECS Fargate Spot task where it's getting killed prematurely. According to the AWS documentation, the task should receive a SIGTERM signal before being forcefully stopped, and there's a stopTimeout that can be set, up to a maximum of 120 seconds. I have configured my task definition with stopTimeout set to 120 seconds:

```json
"containerDefinitions": [
{
"name": "default",
"stopTimeout": 120,
...
}
]
```

However, in practice, my task was killed after only about 21 seconds. I logged the application events, and this is what the timeline shows:

- 18:08:30.619Z: "Received SIGTERM"
- 18:08:51.746Z: Process killed with SIGKILL (exitCode: 137)

The execution details also confirm that my task was interrupted with:
- stopCode: SpotInterruption
- stoppedReason: Your Spot Task was interrupted.

Given this, is it normal for stopTimeout to be disregarded during Spot interruptions? Or could this be a bug?

2 Answers

Answered By QueryNinja22 On

It sounds like you're on the right track questioning the stopTimeout. When AWS needs resources, they can prioritize that over your custom timeout settings. So, yes, it's quite common for spot interruptions to not honor the configured stopTimeout. Just ensure your app handles SIGTERM properly to avoid abrupt kills and potential data loss!

Answered By DevGuru91 On

Actually, the docs are clear that Fargate Spot should give you a heads-up before the task is killed. They mention a two-minute warning for interruptions, but it's crucial that your application is set up to handle the SIGTERM correctly. If it's not processing that signal as expected, it might lead to a forced SIGKILL, which could explain the early termination.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.