Skip to content
Permalink
Browse files
Merge pull request #65 from mriddle/master
JENKINS-19500 Fix: Unable to delete slave for spot request that no longer exists.
  • Loading branch information
francisu committed Sep 9, 2013
2 parents c33e297 + 6a105ea commit 53d256ae988304ebd765bcc33d0b8d47694c1ce7
Showing 1 changed file with 16 additions and 3 deletions.
@@ -92,9 +92,22 @@ private SpotInstanceRequest getSpotRequest(String spotRequestId){
AmazonEC2 ec2 = cloud.connect();

DescribeSpotInstanceRequestsRequest dsirRequest = new DescribeSpotInstanceRequestsRequest().withSpotInstanceRequestIds(spotRequestId);
DescribeSpotInstanceRequestsResult dsirResult = ec2.describeSpotInstanceRequests(dsirRequest);
List<SpotInstanceRequest> siRequests = dsirResult.getSpotInstanceRequests();
if (siRequests.size() <= 0) return null;
DescribeSpotInstanceRequestsResult dsirResult = null;
List<SpotInstanceRequest> siRequests = null;

try{
dsirResult = ec2.describeSpotInstanceRequests(dsirRequest);
siRequests = dsirResult.getSpotInstanceRequests();

} catch (AmazonServiceException e){
// Spot request is no longer valid
LOGGER.log(Level.WARNING, "Failed to fetch spot instance request for requestId: " + spotRequestId);
} catch (AmazonClientException e){
// Spot request is no longer valid
LOGGER.log(Level.WARNING, "Failed to fetch spot instance request for requestId: " + spotRequestId);
}

if (dsirResult == null || siRequests.size() <= 0) return null;
return siRequests.get(0);
}

0 comments on commit 53d256a

Please sign in to comment.