Agent selection sequence

I am using agent selection mechanism at stage level:
$Agent.Hostname.ToLower()$ | In | $Utils.GetString(%BuildAgents%).SplitWithQuotes(",","double",true)$
Which ofcourse works properly, but I was wondering what is the mechanism behind it and is it possible to prioritize certain agents (which might have better HW).

Hi Michal,

Agents are selected in order of capacity available. This value is based on the number of stages currently running on agent and the concurrent stage limit for that agent.

e.g. agentCapacityAvailable = 100 - ((activeStagesOnAgent / concurrentStageLimit) * 100)

Therefore you can prioritise an agent by increasing its concurrent stage limit in relation to other agents.

Hello,
we currently we have setting of 1 concurrent stage per agent, as we mostly do compilation there.
So I understand that all have the same “capacity”, but I am guessing that agent list is somehow sorted ? Or is it randomized ?

Hi Michal,

Providing the agents all have the same capacity, they are ordered alphabetically by hostname. We are considering making this configurable in the future but it’s not currently a priority.

1 Like

An agent priority field has been to the Agent Requirements tab of the Stage Options dialog for v1.9.2.1199. This can be used specify the order in which an agent is selected for the associated stage.

1 Like

would it be possible to have this option globally ?

You know what, I somehow though this is a list of agents to be looked for.
But that is not the case ?
It seems I do not understand how to use this feature :slight_smile:

Can you elaborate on how to configure this ?

After some testing I think I got it. But it’s not that obvious.
Also I added new properties for each agent but it was not visible in the agenet priority setting, does that require server restart ?

Better description (with example could be added). Explaining how priority numbers are treated.

Hi Michal,

There is a new agent property collector (on the Property Collectors page in the Admin section), which is called Priority. As this is a simple numerical property collector, it generates a Priority.Value property on each agent with a default value of 0. You can edit the Priority property on each agent to provide the global priority value for all stages where the Agent Priority is set to $Agent.Priority.Value$. This is the default priority for new stages - we didn’t change existing stages as this may be a breaking change for anyone relying on the current order.

If you want to use a different priority for a stage or set of stages, then add a new agent property collector. Agent property collectors appear in the autocomplete list as $Agent.PropertyNamespace.PropertyName$. Properties added to individual agents don’t appear in the autocomplete list as some agents may not have the property.

We’ll update the documentation on Monday - we had to release before updating the documentation to quickly fix for bug which was a showstopper for one user.

1 Like