Priority/order for which self-hosted runner to use?
Asked by Fabregas4:

Let's say I have 2 self-hosted runners available to build for my C++ projects.

One runner is on a server much more powerful than the other, so it finishes jobs faster. I'd like Bitbucket Pipelines to use this one when it's free, and only use the 2nd one on the rare occasions when the 1st is already running a job.

Is there a way to configure this, i.e. have Pipelines prioritize a runner over another? Or will Bitbucket Pipelines always randomly pick from the list of available runners?


Answers:
author: Patrik S
body: Hello [@Fabregas4](/t5/user/viewprofilepage/user-id/3616282) ,

Thank you for reaching out to Atlassian Community!

At this moment, there's no option on Bitbucket Runners to configure the priority/order that a runner will be chosen when there are multiple runners available.

Currently, a build step configured to use runners will run on the next available runner that has all the required labels, with the following remarks :

* If all matching runners are busy, your step will wait until one becomes available again.

* If you don't have any online runners in your repository that match all labels, the step will fail.

That being said, I went ahead and raised a feature request on our public issue tracker to add the functionality to set priority/order of runners, as you can see in the following link:

* <https://jira.atlassian.com/browse/BCLOUD-21535>

I would suggest you to add your vote there, since this helps both developers and product managers to understand the interest. Also, make sure you add yourself as a watcher in case you want to receive first-hand updates from that ticket. Please note that all features are implemented with this policy in mind: <https://confluence.atlassian.com/support/implementation-of-new-features-policy-201294576.html>

Let us know if you have any other questions.

Best regards,

Patrik S

comments: author: Russell Schultz
body: Can you tell us what the current bitbucket cloud pipeline algorithm is if multiple matching runners are available?

First matching available in the list as shown in repository runners, then fall over to workspace runners and follow the same?

First matching sorted by name? UUID? something?

Randomly?

I realize this would require some code inspection on atlassian's part, but these sort of things are important and the lack of this feature is pretty maddening.


author: Patrik S
body: Hello [@Russell Schultz](/t5/user/viewprofilepage/user-id/4655629) ,

The way how available runners will be selected follows the logic below:

* get the list of ***repository runners*** in unspecified order
  * if there is more than one available repository runner, the first one will be selected
  * else, get the list of ***workspace runners*** in unspecified order
    * if there is more than one available workspace runner, the first one will be selected

This means that repository runners have priority over workspace runners.

Thank you, [@Russell Schultz](/t5/user/viewprofilepage/user-id/4655629) !

Patrik S


author: Kacper Nowak
body: This is not really accurate answere when it comes to:  
"get the list of ***repository runners*** in unspecified order"   
actually the order is specific and always the same. I think the author of this question wanted to know what is the algorithm, so he can create runner that will be always first when all runner are idle.

I have the same problem, that my slower runner is always running first, then faster runner if slower is busy.


author: Kacper Nowak
body: Ahh ok, accoring to my testing it seams that runners are sorted by UUID in alphabetic order, eg.:

{df082842-ac4d-5...}

{57bcfe0e-9255-5...} - This one will be running as first priority as 5 is less than d when sorting by name.

So i had to click "Add runner" until my priority runner got lower uuid :) then remove old runner. Maybe it is a bit pathetic, but it works for me ! :)


Tags: bitbucket-pipelines

bitbucket-cloud

cloud