-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Medium
-
Affects Version/s: allversions
-
Component/s: Elastic Bamboo
-
None
-
1
-
Severity 2 - Major
-
1
Issue Summary
The “Maximum number of instances to start at once” limit in Elastic Agents Automatic Instance Management is applied to the total number of elastic agents, rather than only to the instances currently starting in the optimization cycle.
This makes the setting behave like a second, lower global cap, preventing Bamboo from starting new elastic agents even when the total number of agents is well below the configured “Maximum number of elastic agents”.
Steps to Reproduce
1. Configure Automatic Instance Management:
- Maximum number of elastic agents = 200
- Maximum number of instances to start at once = 20
2. Have >20 agents of the same image type already running and busy (e.g. 35 Linux agents).
3. Queue another build that uses the same image type.
4. Check Elastic Bamboo logs.
Expected Results
Bamboo should start new elastic agents because:
- Total running agents (35) < max elastic agents (200).
- "Instances to start at once” should only limit how many new instances are started per cycle.
Actual Results
Bamboo logs, for example:
Deferring new Elastic instance(s) startup. Maximum number of instances to start at once (35/20).
- No new instances are started, even though capacity is available.
- The value 35 is the total number of existing agents, not instances being started in that cycle.
Workaround
1. Increase “Maximum number of instances to start at once”
Set it to a value >= expected total elastic agents (e.g. same as “Maximum number of elastic agents”) to neutralise the incorrect comparison.
2. Use Elastic Instance Schedules
Use schedules instead of Automatic Instance Management; scheduled instances follow a separate code path and are not affected.
3. Byteman patch (customer‑provided) – replaces the value at runtime to only count starting instances:
RULE Fix elastic instance start-at-once threshold check CLASS com.atlassian.bamboo.agent.managed.schedule.ManagedAgentContainersOptimizerImpl METHOD findAgentContainersToStart(boolean, boolean) HELPER org.jboss.byteman.rule.helper.Helper NOCOMPILE AT INVOKE getMaxElasticInstancesToStartAtOnce 1 BIND mgr = $0.elasticInstanceManager; starting : int = mgr.getInstancesWithStartingAgents().size() + mgr.getRequestedElasticRemoteAgents().size() + mgr.getStartingElasticInstances().size() IF true DO $totalElasticInstancesStartingAtOnce = starting; traceln("[BYTEMAN] Patched totalElasticInstancesStartingAtOnce to " + starting + " (starting only)") ENDRULE