Source:
<code>public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) throws Exception { final String businessKey = execution.getProcessBusinessKey(); Optional<Object> alreadySent = Optional.fromNullable( execution.getVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS)); if (alreadySent.isPresent()) { try { <START> Thread.sleep(60 * 1000); <END> } catch (InterruptedException exception) { LOG.warn("Timeout to make describe calls consistent was interrupted", exception); } } DescribeSpotInstanceRequestsResult result = client.describeSpotInstanceRequests( new DescribeSpotInstanceRequestsRequest() .withFilters(new Filter() .withName("launch-group").withValues(businessKey) .withName("state").withValues("open", "active"))); List<SpotInstanceRequest> pending = result.getSpotInstanceRequests(); if (pending.size() > 0) { LOG.info("Not resending spot instance requests for businessKey: {}.", pending, businessKey); execution.setVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS, collectSpotInstanceRequestIds(pending)); return; } final RequestSpotInstancesRequest request = createSpotInstancesRequest(pool, execution); execution.setVariable(ProcessVariables.SPOT_REQUESTS_SENT, true); RequestSpotInstancesResult requestResult = client.requestSpotInstances(request); List<String> spotInstanceRequestIds = collectSpotInstanceRequestIds(requestResult.getSpotInstanceRequests()); execution.setVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS, spotInstanceRequestIds); }</code><technical_language>I implement this a loop calls describeSpotInstanceRequests 10 seconds for 1 minute more. Check Stopwatch Guava</technical_language>

Target:
public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) throws Exception { final String businessKey = execution.getProcessBusinessKey(); Optional<Object> alreadySent = Optional.fromNullable( execution.getVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS)); if (alreadySent.isPresent()) { DescribeSpotInstanceRequestsRequest describeRequest = new DescribeSpotInstanceRequestsRequest() .withFilters(new Filter() .withName("launch-group").withValues(businessKey) .withName("state").withValues("open", "active")); Stopwatch stopwatch = new Stopwatch().start(); while (stopwatch.elapsedTime(TimeUnit.MINUTES) < 2) { DescribeSpotInstanceRequestsResult result = client.describeSpotInstanceRequests(describeRequest); List<SpotInstanceRequest> pending = result.getSpotInstanceRequests(); if (pending.size() > 0) { LOG.info("Not resending spot instance requests for businessKey: {}.", pending, businessKey); execution.setVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS, collectSpotInstanceRequestIds(pending)); return; } LOG.info("The describe call has not returned anything yet, waiting 20s and retrying."); Uninterruptibles.sleepUninterruptibly(20, TimeUnit.SECONDS); } } final RequestSpotInstancesRequest request = createSpotInstancesRequest(pool, execution); execution.setVariable(ProcessVariables.SPOT_REQUESTS_SENT, true); RequestSpotInstancesResult requestResult = client.requestSpotInstances(request); List<String> spotInstanceRequestIds = collectSpotInstanceRequestIds(requestResult.getSpotInstanceRequests()); execution.setVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS, spotInstanceRequestIds); }