amazon-ecs-agent icon indicating copy to clipboard operation
amazon-ecs-agent copied to clipboard

Support for --stop-timeout

Open simplesteph opened this issue 9 years ago • 10 comments

Now that the main ECS Linux has been updated to Docker 17.03, we have the capability of specifying a timeout per task using:

docker run -d --stop-timeout=20 alpine sleep 500
time docker stop 187626bd862f
187626bd862f
docker stop 187626bd862f  0.01s user 0.01s system 0% cpu 20.711 total

Can ECS please support that?

simplesteph avatar Jun 22 '17 05:06 simplesteph

Hi @simplesteph, thanks for bringing this to our attention. This will require work on the agent codebase, as well the as the ECS API's task definition. Unfortunately we can't commit to a delivery date right now, but we will continue to track it as a feature request. Thanks.

adnxn avatar Jun 29 '17 21:06 adnxn

Seems to be supported now through ECS_CONTAINER_STOP_TIMEOUT http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html

TheTweak avatar Jul 29 '17 07:07 TheTweak

Hey @TheTweak! Thanks for the pointing out that configuration environment variable. ECS_CONTAINER_STOP_TIMEOUT does cause the Agent to kill containers after timing out, but this configuration setting is global and cannot be set or overridden on a per-task basis. If I understand @simplesteph correctly, it would be desirable to configure each Task independently to give containers more or less time to stop.

jahkeup avatar Aug 02 '17 20:08 jahkeup

Yes please. A per Task parameter for the stop timeout would be useful.

coen-hyde avatar Dec 21 '17 22:12 coen-hyde

Per Task parameter would be useful especially with Fargate where you don't have a control over environment.

Halama avatar Dec 27 '17 13:12 Halama

I believe this is the same issue as https://github.com/aws/amazon-ecs-agent/issues/1241 is it not? Either way, I wanted to let everyone on this thread know that we on the ECS team are aware of the issue and that it is under active consideration. If you have additional details/use cases to share, they are always appreciated and will help inform our work.

coultn avatar Oct 31 '18 20:10 coultn

I guess there is a misunderstanding. @simplesteph described the timeout for a task even if it is running. I need also such this feature. I know this feature is strange regarding ecs logic.. Just I want to limit a task life.

ECS_CONTAINER_STOP_TIMEOUT is yes global but also it is used for stopped task and defining the time period from a stopped task to a starting container kill.

deeptechs avatar Dec 19 '18 13:12 deeptechs

@deeptechs The --stop-timeout parameter that @simplesteph referenced is the same thing as ECS_CONTAINER_STOP_TIMEOUT but at a per-container level instead of global. It sounds like you're describing a maximum-lifetime for a container, which would be a separate feature request.

samuelkarp avatar Dec 19 '18 18:12 samuelkarp

@samuelkarp Thanks for the clarification, you are right this can be a separate feature which we shouldn't request since we can manage any task via api. We are now handling a running-task life in our app side. By the way we will try to handle Sigterm signal during ECS_CONTAINER_STOP_TIMEOUT to stop docker containers gracefully.

deeptechs avatar Dec 23 '18 12:12 deeptechs

im closing this in favor of https://github.com/aws/amazon-ecs-agent/issues/1241. both issues are tracking granular per container stop timeouts. given the current proposal, we would be able to set "timeout per task" by configuring the each container in the task to have the same timeout.

please add any feedback to the other issue tracking this feature request.

adnxn avatar Feb 06 '19 19:02 adnxn