Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getCurrentSpareInstanceCount - check busy nodes in given fleet, not whole Jenkins instance #343

Merged
merged 5 commits into from
Aug 18, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main/java/com/amazon/jenkins/ec2fleet/EC2FleetCloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
Expand Down Expand Up @@ -467,7 +468,7 @@ public FleetStateStats update() {
fine("start cloud %s", this);

// Make a snapshot of current cloud state to work with.
// We should always work with the snapshot since data could be modified in another thread
// We should always work with ]the snapshot since data could be modified in another thread
FleetStateStats currentState = EC2Fleets.get(fleet).getState(
getAwsCredentialsId(), region, endpoint, getFleet());

Expand Down Expand Up @@ -852,6 +853,11 @@ private int getCurrentSpareInstanceCount(final FleetStateStats currentState, fin
if (compNode == null) {
continue;
}

// Do not count computer if it is not a part of the given fleet
if (!Objects.equals(((EC2FleetNodeComputer) computer).getCloud().getFleet(), currentState.getFleetId())) {
continue;
}
currentBusyInstances++;
}
}
Expand Down