Jenkins builds on multiple nodes with least load plugin

Hello.
I have configured Jenkins with 2 docker nodes.
I then installed the “Least load” plugin and my jenkinsfile contains this line:

agent {
label ‘!master’
//label(‘android-slave-label-1 || android-slave-label-2’)
}

So I was expecting to see builds also executed on the slave 2, but it always tries to use the slave 1. What can I do to make jenkins distribute builds on my 2 available nodes?

Thanks
GP

I’ve never even heard of that plugin before, so i don’t know how much I can help, but it seems to not be working right.

Looking at leastload-plugin/LeastLoadBalancer.java at c47ef96892fcf5ce304ad224a7763a6a50ca747e · jenkinsci/leastload-plugin · GitHub it seems like its sorting based on the number of idle slots left. Is one agent bigger than the other?

It should just automatically set itself as the load balancer on startup - leastload-plugin/LeastLoadPlugin.java at c47ef96892fcf5ce304ad224a7763a6a50ca747e · jenkinsci/leastload-plugin · GitHub - though I don’t know if other load balancers do the same thing. The plugin really needs a PR to add logging to say its working or not for debugging purposes.

1 Like

hi Gavin, thanks for answering :slight_smile:

how can I determine if one agent is “bigger” than the other? which is the criteria?
cpu and ram are equals, for example.

In case, do you know other ways to do a sort of load balncing with jenkins?

the code says number of idle slots, so I’m thinking its the Number of executors but i’m not really sure?

i’m sorry I don’t. I tend to use cloud agents when I can, so when things get overloaded, more agents spin up.

1 Like

I tend to use cloud agents when I can, so when things get overloaded, more agents spin up.

oh, that’s interesting, how do you that? any tutorial I can look at?

we have an internal cloud and my idea, initially, was something like that, but since I didnt know how to do it, I tried, at least, to do a kind of balancing with two nodes

I’ve been around so long that i’ve learned things organically, so i’m really bad at knowing if there are tutorials, but there should be at least posts on google about it.

Generally you want to pick one of the cloud provider plugins - Search Results - most will connect to an api and spin up an instance when one gets overloaded. You just gotta make sure you setup max executors right so jenkins knows when an agent has too many jobs. We don’t have any fancy scheduler that looks at cpu/etc (at least not one i’m aware of).

There’s a few like vmware that will handle internal clouds though the focus seems to be public clouds.

1 Like