Skip to content

Commit

Permalink
Add count of builds left for instances (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
imuqtadir authored Nov 9, 2021
1 parent 9a0fc90 commit 8c02bb0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,19 @@ public EC2FleetNode getNode() {
@Nonnull
@Override
public String getDisplayName() {
if(cloud != null) {
final String displayName = String.format("%s %s", cloud.getDisplayName(), name);
final EC2FleetNode node = getNode();
if(node != null) {
final int totalUses = node.getMaxTotalUses();
if(totalUses != -1) {
return String.format("%s Builds left: %d ", displayName, totalUses);
}
}
return displayName;
}
// in some multi-thread edge cases cloud could be null for some time, just be ok with that
return (cloud == null ? "unknown fleet" : cloud.getDisplayName()) + " " + name;
return "unknown fleet" + " " + name;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public void taskAccepted(Executor executor, Queue.Task task) {
} else if (maxTotalUses <= 1) {
LOGGER.info("maxTotalUses drained - suspending agent after current build " + computer.getName());
computer.setAcceptingTasks(false);
ec2FleetNode.setMaxTotalUses(ec2FleetNode.getMaxTotalUses() - 1);
} else {
ec2FleetNode.setMaxTotalUses(ec2FleetNode.getMaxTotalUses() - 1);
LOGGER.info("Agent " + computer.getName() + " has " + ec2FleetNode.getMaxTotalUses() + " builds left");
Expand Down

0 comments on commit 8c02bb0

Please sign in to comment.