Skip to content

Commit

Permalink
Merge pull request #5 from elatt/master
Browse files Browse the repository at this point in the history
Fix scaling to respect numExecutors
  • Loading branch information
schmutze authored Jul 21, 2017
2 parents 64609a2 + fb2ab3f commit 4b06b32
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/com/amazon/jenkins/ec2fleet/EC2FleetCloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,17 @@ public static void log(final Logger logger, final Level level,
if (stats.getNumDesired() >= maxAllowed || !"active".equals(stats.getState()))
return Collections.emptyList();

int targetCapacity = stats.getNumDesired() + excessWorkload;
// Presumably ceil() would also be correct but I think round() works best for
// scenarios when numExecutors is of reasonable size.
int weightedExcessWorkload = Math.round((float)excessWorkload / this.numExecutors);
int targetCapacity = stats.getNumDesired() + weightedExcessWorkload;

if (targetCapacity > maxAllowed)
targetCapacity = maxAllowed;

int toProvision = targetCapacity - stats.getNumDesired();

LOGGER.log(Level.INFO, "Provisioning nodes. Excess workload: " + Integer.toString(excessWorkload) + ", Provisioning: " + Integer.toString(toProvision));
LOGGER.log(Level.INFO, "Provisioning nodes. Excess workload: " + Integer.toString(weightedExcessWorkload) + ", Provisioning: " + Integer.toString(toProvision));

final ModifySpotFleetRequestRequest request=new ModifySpotFleetRequestRequest();
request.setSpotFleetRequestId(fleet);
Expand All @@ -231,7 +234,7 @@ public static void log(final Logger logger, final Level level,
{
final SettableFuture<Node> futureNode=SettableFuture.create();
final NodeProvisioner.PlannedNode plannedNode=
new NodeProvisioner.PlannedNode("FleetNode-"+f, futureNode, 1);
new NodeProvisioner.PlannedNode("FleetNode-"+f, futureNode, this.numExecutors);
resultList.add(plannedNode);
this.plannedNodes.add(plannedNode);
}
Expand Down

0 comments on commit 4b06b32

Please sign in to comment.