9

I have a pool with 10 agents. I have noticed that usually only some of them are used, and others still there have hardly ever been used.

I am wondering if is there a way to say to TFS to use all of them? For example, something like TFS grabs them based on the order. At the first time uses the number 1, then 2, 3. After using the agent it puts the agent to the end of the queue. So, before using number 1 again TFS would use all the numbers first.

That would be very good to have that logic in place to have the best use of all the agents we have in place.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Janissetti
  • 93
  • 1
  • 4
  • 2
    Why does it matter? I'm not seeing a problem that needs solving here. It's not like the agents that are being used more are going to wear out. They're not tires; they don't need to be rotated. If you have more agents available than are being used, get rid of some of them. – Daniel Mann Sep 14 '17 at 23:29
  • 1
    It matters because I have 10 agents and I would like to use them equally. Our build and deployment processes creates a lot of temporary archives and them need to be removed periodically. However, for some reason TFS is not taking care of it (I bet it is a bug on the retention system). So, if we keep using one agent more than other we have run out of space in that specific agent, which is not good because I have others that are not used. – Janissetti Sep 16 '17 at 00:44
  • 2
    @DanielMann agent 1 runs out of space. ALL BUILDS FAIL. yeah, why does it matter? no idea. – 4c74356b41 Apr 13 '18 at 09:44

2 Answers2

7

Just as Daniel said, they don't need to be rotated. If some of them are not required, you can get rid of them.

However, you can set Demands in your build definition if you want to use a specific agent every time.

In the build definition, under General, add the Demand Agent.Name and set it equal to the name of the build agent under the value column, or add the custom demands (for example, use USER CAPABILITIES) to identify the specific agent. This will ensure the build is serviced by only this agent.

So, you can create different build definitions to use each of the agents.

Please reference this article for details: Build vNext, distributing load to different agents.

However, we can not achieve that for now. There is a user voice request here for the feature. You can go and vote it up to achieve it in the future.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55
  • Thanks for replying Andy. I thought about using the Demands feature, but I do not want to save for example 3 Agents for PullRequest, 3 for Builds and 3 for Release. Sometimes I will need more than that for one or another, depends on the day and time. I would like to workaround that retention issue related above. Appreciate your reply and suggestion :-) – Janissetti Sep 16 '17 at 00:46
  • @WagnerCJ Unfortunately, there isn't the feature to rotate the agents, the only way is specifying the demands against the agents for now. However, Michel submitted a user voice to suggest the feature, you can go and vote it op. See the updated answer for the link. – Andy Li-MSFT Sep 18 '17 at 09:55
  • thanks for letting me know that it is not available at this moment. Also, thanks for sharing the "user voice" hyperlink. I have added my considerations and voted there! It is good to know that I am not alone ;-) – Janissetti Sep 18 '17 at 16:08
  • @WagnerCJ Yeah, we hope that feature can be achieved soon. And if that helps, you can [Accept it as an Answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), This can be beneficial to other community members reading this thread. – Andy Li-MSFT Sep 19 '17 at 02:01
  • In VSTS: Choose a Build Definition -> Edit -> Options -> Demands - Add "Agent.Name" equals "MYAGENT" – SushiGuy Feb 27 '18 at 19:37
4

I wondered about the same thing. The cleanup process seems to leave artefacts from time to time. With the amount of builds we run, the servers tend to get low on space eventually (even though we wrote our own cleanup utilities).

It seems that there is a method to the TFS madness: VSTS Build Agent Selection Demystified

After discussing this with some folks at Microsoft, it turns out that the selection routine works something like this – when a new build is queued:

  1. Select all build agents that match the specified demands
  2. Sort the results by the clustered index on agent name

Translation: The build agents are selected in the same order in which they were registered with VSTS. I suppose that’s a simple approach, but not the one that I was expecting.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Daniel Morritt
  • 1,787
  • 17
  • 25
  • Awesome! Very helpful article! Thanks for sharing it! Unfortunately it does not help me (helped me to understand!) to solve my problem. Since VSTS works that way I cannot change the logic it uses to select the next agent. I will not change the order they are registered because it will not help me. I have commented and voted on the user voice listed above. Maybe you can do it too. Good to see that I am not alone in this request. – Janissetti Sep 18 '17 at 16:14
  • Yeah! That worked for me! I was able to manage priority between agent pools by uninstalling and then installing the agent again. The order keeps unchanged in the screen, but now TFS chooses following the priority I want. So, I have 4 different agents in 4 servers and now my capacity is more equally distributed. Thanks! – tgarcia Aug 27 '19 at 21:49