Skip to content
Permalink
Browse files
JENKINS-19500 Fix: Unable to delete slave for spot request that no lo…
…nger exists.
  • Loading branch information
mriddle committed Sep 9, 2013
1 parent c33e297 commit 6a105ea81120820817d1cc6cf94ff87da34fdaa1
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 6a105ea

Please sign in to comment.