Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

INACTIVE task - how to kill them

When I create a new revision of my tasks in aws ecs, ecs creates two new instances as requested.

However, it leaves the other two untouched:

enter image description here

AWS does know, however that this is not correct:

enter image description here

Why is it like that?

I have a minimum health of 100% (two tasks) and a max of 200%.

My understanding is that it starts two new tasks and then kills the inactive ones. But the inactive ones just stay there forever (until I manually kill them), doing unpredicable things on old code.

like image 548
shredding Avatar asked Jun 15 '18 16:06

shredding


1 Answers

Note that it isn't the old tasks, but the old task-definition that is inactive. You have two running tasks that are using taskdef:34 and 2 older ones that are using an older, now inactive taskdef.

ECS/ALB does stop routing new requests to the old tasks immediately, but they will stay around as long as there are active connections to them. This is really a mechanism to enable zero-downtime graceful switchover. If your app keep long lived connections, or that is the nature of your transactions, your old tasks will stick around for longer.

You can, if you so desire, select the old tasks and terminate them manually and immediately; or even write up a script to terminate all tasks running on older taskdefs. Needless to say, this can be disruptive to active connections/transactions.

like image 197
RaGe Avatar answered Sep 21 '22 22:09

RaGe