Skip to content

Commit

Permalink
[FIXED JENKINS-7883] Stopped (as opposed to terminated) slaves are co…
Browse files Browse the repository at this point in the history
…unted against the active instance count for the purpose of launching; can prevent launching of instances
  • Loading branch information
Francis Upton IV committed Feb 15, 2012
1 parent f13f065 commit fb48500
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/hudson/plugins/ec2/EC2Cloud.java
Expand Up @@ -39,6 +39,7 @@
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.CreateKeyPairRequest;
import com.amazonaws.services.ec2.model.Instance;
import com.amazonaws.services.ec2.model.InstanceStateName;
import com.amazonaws.services.ec2.model.InstanceType;
import com.amazonaws.services.ec2.model.KeyPair;
import com.amazonaws.services.ec2.model.KeyPairInfo;
Expand Down Expand Up @@ -152,7 +153,8 @@ public int countCurrentEC2Slaves() throws AmazonClientException {
int n=0;
for (Reservation r : connect().describeInstances().getReservations()) {
for (Instance i : r.getInstances()) {
if(!"terminated".equals(i.getState().getName()))
InstanceStateName stateName = InstanceStateName.fromValue(i.getState().getName());
if (stateName == InstanceStateName.Pending || stateName == InstanceStateName.Running)
n++;
}
}
Expand Down

0 comments on commit fb48500

Please sign in to comment.