We have an issue that sometimes developers are not cleaning up properly, and there might be orphan docker containers kept alive on our Bamboo build agents. (started from the build job).
Is there anything in place that I can use for this?
A simple solution to this would be if Bamboo had a trigger similar to the final-task, that could be configured for example in `bamboo-agent.cfg.xml`.
Hi @Jan Nylund,
I think I would try to create a final stage on any build that runs those containers to make sure that they are cleaned at the end of the build.
You can use a final stage for that. Final stages are present as a beta feature in Bamboo since version 5.14. It will become a native feature in Bamboo 5.8+ as you can see from [BAM-9771] Final Stage for plans - Create and track feature requests for Atlassian products.
This is how you can enable the dark feature:
curl -X PUT <server_url>/rest/admin/latest/darkFeatures/bamboo.final.stages -u <user>:<password> -H "Content-Type: application/json" -d'{"key":"bamboo.final.stages","enabled":true}'
Another option I can think is trying an external solution based on the OS of your remote agents. It could be a service or cron job that would constantly look for those containers running for a longer time and killing them.
I hope that helps.
Thanks @[deleted]
1. The Final stage solution would mean updating 200+ build plans. At least 50 of these are created with bamboo-specs, which make them readonly. So this wont work. I would love to see this on a global level though. (both a pre and post build plan / deploy plan)
2. Listening to the atlassian log would work in theory, if I'm fast enough to find it before a next job is started. During our rush hours, there's no free time, so in practice this is not doable. A cron job is too slow and would likely collide with the running builds.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for explaining. I imagined it wouldn't be an easy change, but that was what I had to share.
I'm curious about something:
Bamboo should not allow a docker task to keep running after the build has ended.
Also, I want to share an idea:
I'm sharing some thoughts so you can have more options, but I think this should not be happening in the first place.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We primarily use script tasks since Bamboo tasks tend to cause more issues than they gain. (I would really love to go towards a nice simple yaml like in bitbucket pipelines)
Sometimes Bamboo fires up a testcase using docker-compose, which spawns a network, etc. I wrap this in a shellscript that is using a trap that force cleans up, but we still see cases when this is not handled and this leaves me with a bunch of wild docker containers that Bamboo no longer can see.
Basically, something similar to the checkbox "Clean working directory after each build" that would allow running a custom script taks would solve this problem. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @jan,
I got it, thanks for explaining. Maybe for this specific scenario, you would get some benefits from using docker tasks. It is not really easy to be safe on error handling using OS scripts. They are not designed in a way to make this an easy task. I mean, you can wrap everything up, but that would require some special attention depending on how complex is your script.
Regarding your suggestion, do you want to create a feature request for the suggestion you just gave?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes please do. Please request it for both global and plan level. In it's simplest way it could be used to simply echo timing information for log aggregation. (which means it would be nice to have a before start as well) :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey, I was writing the feature request about this and realize that this is not that simple. I will need your help to better write this request.
Please confirm if my understanding is correct. Wath I understood from your opinion is that we should have a mechanism where a given task could be configured to run for every building plan, right?
Some things to consider:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.