-
Notifications
You must be signed in to change notification settings - Fork 601
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
Remove containers on swarm service scale down #1372
Comments
By default, we leave the most recent 5 containers per replica in place to aid troubleshooting (for example, providing the ability to execute a shell in one of these containers and inspect logs). This is a configurable setting, so you could set the number of containers to retain to 0 with cc @sfsmithcha - not sure if this is well-documented. |
@igrcic Note that it is also safe to remove exited containers manually. Something like the following can run on the work nodes periodically: $ docker ps -qa -f label=com.docker.swarm.task -f status=exited | xargs docker rm -f This can be used if you'd like to have a more aggressive policy about cleaning up resources but would like to have some task history for debugging purposes. |
Thank you @aaronlehmann, i have tried with --task-history-limit 0, but it doesnt really do anything. Scaling from 7 to 1 instances leaves 6 exited ones.
@stevvooe tnx i'm already doing that. I just thought that TaskReaper thingy can do it for us though ;) |
I know there is a bug where |
Hi, i just tried with both, |
I guess its related to moby/moby#24394 |
The limit is per replica, so you wouldn't see the default limit of 5 come into play until at least one replica restarts 5 times. When you try with a limit of 0, do the old scaled-down tasks disappear from |
@igrcic For the most part, orphan containers have been mitigated. There may still be a slight race condition described in moby/moby#24858, but it should be unrealistic. In addition to troubleshooting suggested by @aaronlehmann, it would also be good to get the output of the logs during the period when you expect removal to happen. There could be some condition on your hosts that are preventing the removal from proceeding and we'd need to track that down. |
tnx @aaronlehmann now i see what you mean, this actually applies for service replica history count ( In that case, no it doesnt work for me, it always stays at 4+1 replicas @stevvooe the only thing I can see in logs is:
Do not know if that is related though. Tnx, |
I tried this out and changing BTW, I misremembered how the limit is applied. It actually counts all tasks for a given instance, not just the old tasks. So |
@aaronlehmann Should we actually nuke tasks when we scale down? No point in keeping the history for those I guess? Slot history makes sense for crashes, rolling updates, etc but when you scale down they're pretty useless. |
The only reason I can think of to keep them is to show a record of the scaling itself. It's not a very strong reason. Deleting the tasks immediately when scaling down would probably be fine. |
@aaronlehmann @aluzzardi Delete or not, these can be removed from the assignment set. |
Hi all, +1 for nuking the tasks :) @stevvooe can you explain what do you mean by that? |
@igrcic We dispatch tasks by maintaining an "Assignment Set" to the target node. The dispatcher protocol maintains this assignment set between the worker and manager. If a task is outside the assignment set, the node can choose to remove the resources associated with that task (ie delete the container). The point here is, the discussion of deletion is moot. All that needs to be done from the perspective of the work is to not include these tasks in the assignment set and the node will delete them. The manager can choose to keep them around or delete them separately. |
The consensus is to reduce the number of slots upon scale down /cc @aaronlehmann |
Hi everyone,
first I'd like to ask if this is the right repo to be asking questions regarding to
docker swarm *
engine commands?I am currently testing docker swarm engine in order to see if I can use this new functionality for some of our (non-critical) production environment.
I noticed that when scaling down services, containers in exited status remain (1.12) in docker. When I was testing beta2 or beta3 the containers were automatically removed.
Can one achieve this behavior somehow in v1.12?
Thank you,
Ivan
The text was updated successfully, but these errors were encountered: