Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do you drain self-hosted Bitbucket runners?

Ian Chesal April 13, 2022

I'd like to recycle and update my VMs that I use for my self-hosted Bitbucket runners on a regular basis. There's no time of day where I can be certain that the runners aren't doing some work on behalf of pipelines in Bitbucket.

That means I can't just blindly shut things down. I need to drain and restart them in a less interruptive way.

Is there a way to tell a docker-based runner to shut itself down after it finishes with whatever current task it happens to be processing?

1 answer

0 votes
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 18, 2022

Hi @Ian Chesal

Welcome to the community.

Unfortunately, a Docker runners container is not gracefully shutting down at the moment.
In the same way, it is not possible to configure a runners' container to shut down itself after a task is done.
We do have an existing feature request for it to gracefully shutdown a Runners container that can be located through this link. - https://jira.atlassian.com/browse/BCLOUD-21664
You can upvote and watch it for now so that you'll be notified of any updates from our team when the feature becomes available on Bitbucket Cloud.
Please do note that we don't have an exact ETA for the feature request as all new features will be implemented according to our policy here.

As a workaround, as mentioned in the BCLOUD ticket as well, you can either:

  • Perform a manual stop on the container itself verifying there are no builds on the Pipelines UI; or,
  • With the use of Pipelines APIs, verify if there is a pipeline running on a particular repository and verify the status of the pipelines build and script to stop the runner container using `docker stop` command

You can check this link for the Pipelines API.

Do let me know if you have further questions.

Regards,
Mark C

Ian Chesal April 19, 2022

The API link is super helpful. Thank you!

Like Mark C likes this
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 20, 2022

Great. Glad to know it helps.

Let me know if you have further questions that I can help with.
Otherwise, feel free to mark the question as answered.

Regards,
Mark C

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events