When using multiple agents in a hostgroup and running multiple instances of a job where there is also a PUT_ATT host in the Pre-Process, if the PUT_ATT puts an agent that was not originally chosen in the agentgroup calculation, the originally chosen agent's mas resources do not decrease.
Steps to reproduce:
Create hostgroup with 2 agents - it can have type ANY and be whatever kind of agent.
Set a limit for Max Resource jobs in Administration -> Advanced option for each agent (for example, 6)
Create a job that uses the hostgroup from step 1
Keep "Consume x Resources" at 0
Add a pre-process script to put_att HOST to one of the agents
Have generate at runtime
Run many of the job at the same time (2-3 times as many as the limit for each agent)
Go to Administration -> Agents
Add Job res. max. column
Each Agent resources will go back down to 0 once all jobs are finished
The agent that does not get set via PUT_ATT stays at max resources once hit and does not decrease
Set the agent that is incorrectly high to unlimited resource limit and then back to previous limit
Release : 12.x, 21.0
Component : AUTOMATION ENGINE
Behavior by design
This behavior is by design. If a valid HOSTG is used within the attributes tab, the first thing done is that the host is assigned and the resources used is increased. When the put_att is used to change the agent, the resources used for that agent are increased as well, but there is no designed check on if a previous agent was assigned before that.
When the job finishes, it will decrease the resources for the agent that was used in the job which in this case would be the second agent assigned. There is no check to decrease the first agent assigned.
The recommendation if PUT_ATT should be used is to use the <UNIX> dummy entry for the agent and then use the PREP_PROCESS_AGENTGROUP script and use put_att within that same block. This should allow for the expected increase/decrease of agent resources.