jenkinsci/ec2-plugin — pull request #85 by ikikko (2014-04-20 07:34:38+00:00)
Title: Retry updating remote tags when spot instance launches

Sometimes I met a problem that spot instances were launched and weren't terminated forever. I investigated it, then I saw an error log below.

```
WARNING: Provisioned slave backlog-build (ami-87d3a286) failed to launch
com.amazonaws.AmazonServiceException: Status Code: 400, AWS Service: AmazonEC2, AWS Request ID: e9120dea-c57a-4592-947f-c1692e67e158, AWS Error Code: InvalidSpotInstanceRequestID.NotFound, AWS Error Message: The spot instance request ID 'sir-6001c25b' does not exist
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:766)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:414)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:228)
at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:7902)
at com.amazonaws.services.ec2.AmazonEC2Client.createTags(AmazonEC2Client.java:4530)
at hudson.plugins.ec2.SlaveTemplate.updateRemoteTags(SlaveTemplate.java:567)
at hudson.plugins.ec2.SlaveTemplate.provisionSpot(SlaveTemplate.java:527)
at hudson.plugins.ec2.SlaveTemplate.provision(SlaveTemplate.java:247)
at hudson.plugins.ec2.EC2Cloud$1.call(EC2Cloud.java:365)
at hudson.plugins.ec2.EC2Cloud$1.call(EC2Cloud.java:361)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
```

The problem was that Jenkins tried to update a spot request's tag before the request didn't exist. So I have added retry code when updating a tag.