jenkinsci/ec2-plugin — pull request #25 by zzzeek (2012-10-10 03:51:00+00:00)
Title: keep track of instances being provisioned; use this count when determining total/AMI instance caps

This change adds a static map to the EC2Cloud class, which stores string AMI names mapped to an integer count of how many instances of this AMI are undergoing provisioning. As EC2Cloud.provision() adds PlannedNode instances, it checks a new method addProvisionedSlave(), which replaces the previously inlined checks against Amazon's reported numbers. addProvisionedSlave() checks not just Amazon's reporting of running EC2 instances, but also adds the number of nodes currently under "provisioning". addProvisionedSlave() and it's complementing decrementAmiSlaveProvision() method both synchronize access to the essentially global map as the counts are read, increased, and decreased.

I've been testing this for several hours, both by starting lots of jobs manually and also watching as a cluster of jobs are started at once due to an event; I now get the correct number of EC2 nodes spawned, and consistent messaging as to the status when there are already too many nodes present.