Skip to content

feat: randomize runner selection#3722

Merged
fiftin merged 3 commits intosemaphoreui:developfrom
agrrh:feat/random-runner-selection
Mar 31, 2026
Merged

feat: randomize runner selection#3722
fiftin merged 3 commits intosemaphoreui:developfrom
agrrh:feat/random-runner-selection

Conversation

@agrrh
Copy link
Copy Markdown
Contributor

@agrrh agrrh commented Mar 25, 2026

Hello!

Just ran into same issue as mentioned here:
#1519 (comment)

I noticed the selection of the runners for task execution was not random.
[...]
Is there anyway this behaviour can be changed? Ideally the runner selection, as its most basic form, is completely random, or just straight round robin?

For me, tasks also kept scheduling on the same runner

Seems that issue is fixed by adding 2 shuffle calls, still keeping "project" runners preferred over "global" ones

To verify that tasks are distributed randomly, I've built and ran docker image locally:

  • before: A, A, A, A, A, A -> semaphoreui/semaphore:v2.17.28
  • after: A, A, B, B, A, B -> agrrh/semaphoreui:random-runner-selection

(First contribution here, please, let me know if I missed something)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates remote-runner task scheduling to reduce repeated selection of the same runner by randomizing the order in which eligible runners are considered, while still preferring project runners over global runners.

Changes:

  • Added a shuffleRunners helper to randomize runner ordering.
  • Shuffled project and global runner lists before concatenating them for selection.

Work on a copy so that if randomness fails, we can safely return the original order.

Co-authored-by: Copilot <[email protected]>
@fiftin fiftin merged commit 9132123 into semaphoreui:develop Mar 31, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants