Skip to content

Commit

Permalink
Merge pull request jenkinsci#120 from syncron/master
Browse files Browse the repository at this point in the history
[JENKINS-25029 ] Retry updating remote tags also for ondemand instances
  • Loading branch information
francisu committed Dec 10, 2014
2 parents 420806e + ccf31c3 commit bac1a72
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/main/java/hudson/plugins/ec2/SlaveTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,21 @@ private EC2AbstractSlave provisionOndemand(TaskListener listener) throws AmazonC
// Have to create a new instance
Instance inst = ec2.runInstances(riRequest).getReservation().getInstances().get(0);


/* Now that we have our instance, we can set tags on it */
if (inst_tags != null) {
updateRemoteTags(ec2, inst_tags, inst.getInstanceId());
for (int i = 0; i < 5; i++) {
try {
updateRemoteTags(ec2, inst_tags, inst.getInstanceId());
break;
} catch (AmazonServiceException e) {
if (e.getErrorCode().equals("InvalidSpotInstanceRequestID.NotFound")) {
Thread.sleep(5000);
continue;
}
throw e;
}
}

// That was a remote request - we should also update our local instance data.
inst.setTags(inst_tags);
Expand Down Expand Up @@ -458,6 +470,8 @@ private EC2AbstractSlave provisionOndemand(TaskListener listener) throws AmazonC

} catch (FormException e) {
throw new AssertionError(); // we should have discovered all configuration issues upfront
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}

Expand Down

0 comments on commit bac1a72

Please sign in to comment.