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

User input for dynamic pipelines & selecting a particular self hosted runner

Garrett_LoVerde June 12, 2024

Background

I have ~30 self hosted runners and intend to scale up to ~100 and beyond in the next year or so.

These runners generally do the following

  • execute builds of embedded firmware, for various microcontrollers
  • flash firmware to USB connected boards
  • Execute a test harness to test the firmware

The linux runners have an always running container image which also runs the bb runner software. (So standard Linux shell runners)

Our bitbucket-pipelines.yml is ~6000 lines

Immediate Needs

1. Be able to select what runner a pipeline runs on in order to troubleshoot environmental problems, boards with worn out flash etc., without needing to make a branch that sets the runs on label to a single label

2. There is a desire to have an expensive protocol analyzer or two attached to some machines, have our 'standard' pipelines run on these machines, and have the pipelines start + stop a protocol trace if the protocol analyzer runner is assigned to the pipeline.

 

For number two, I suppose we can build detection of the analyzer into our test harness and automatically start and stop tracing.

However, we still need to be able to enable our devs to select what runner is assigned to a custom pipeline run.

We also could just duplicate all the relevant pipelines in our dynamic pipelines prover, append -`with-analyzer` to their names and adjust the runs-on labels; but we already have a very large list of pipelines to look through and this doesn't provide the ability to assign a particular runner to a pipeline.

 

Any thoughts on how to make this happen with dynamic pipelines?

1 comment

Comment

Log in or Sign up to comment
Edmund Munday
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 13, 2024

Hi @Garrett_LoVerde 

So the use-case you're talking about here should be absolutely achievable, we've discussed similar use-cases with other users in the past.

You might need to reverse the order of operations/thinking a little bit though. e.g You'll probably need to have a dedicated batch of runners for each of the different scenarios that you need to handle, with each batch of runners having custom labels to indicate that they support the particular scenario.

You would then use a Dynamic Pipeline to assign Pipeline execution runs to the different runners dynamically, by assigning labels to the build when the Dynamic Pipeline runs.

You then need a way of telling the Dynamic Pipeline which jobs you want to run on which runners based on user input.

The easiest way to do this (that I can think of immediately) is by coming up with some kind of tagging convention for your branch name (like wrapping some comma seperated strings between {tags} markup blocks), and then having the Dynamic Pipeline just pull the labels you want to apply to the build from the branch the build is running against.

For example:

const branchName = "{tags}flash-board-x,exec-test-harness-y,run-profiler{tags}-some-human-relevant-stuff";

// Use a regular expression to find the content between {tags}
const regExp = /{tags}(.*?){tags}/;

// Extract the matched group, which are the tags
const match = branchName.match(regExp);

if (match) {
// Split the extracted string by comma to get individual tags

const tags = match[1].split(',');

// Then add each of the tags as custom labels to the build so it runs on the correct runner.
} else {
console.log("No tags found.");
}

 

Garrett_LoVerde June 17, 2024

@Edmund Munday 

I had thought of the approach you mentioned. I was hoping to avoid forcing the developer to create a new branch before running the custom pipeline.

 

I think to do this properly we would either need a change in the paradigm for specification and selection of run-on labels or, more on topic with this discussion group, multiple opportunities to modify pipeline yaml with the dynamic pipeline feature.

The current order of operations for configuration of custom pipelines (2&3 might be flipped)

  1. Select branch
  2. Invoke pipeline modification logic in forge
  3. Select custom pipeline from list
  4. Pipeline variables selection
  5. Select runner that has specified run-on labels and execute pipeline on it

Order of operations would need/desire

  1. Select branch
  2. Invoke postBranchSelectHandler
  3. Select custom pipeline from list
  4. Invoke postPipelineSelectHandler
  5. Pipeline variables selection
  6. Invoke postPipelineVariableSelectHandler
  7. Select runner that has specified run-on labels and execute pipeline on it

With each 'handler' being executed by an associated function of a single dynamic pipeline provider, according to the current one pipeline provider per repo approach.

 

TAGS
AUG Leaders

Atlassian Community Events