Index: src/applications/drydock/blueprint/DrydockAmazonEC2HostBlueprintImplementation.php =================================================================== --- src/applications/drydock/blueprint/DrydockAmazonEC2HostBlueprintImplementation.php +++ src/applications/drydock/blueprint/DrydockAmazonEC2HostBlueprintImplementation.php @@ -409,6 +409,30 @@ 'Spot instance request has been fulfilled, and the instance ID is %s.', $instance_id)); + // Wait until the instance has appeared. + while (true) { + try { + $result = $this->getAWSEC2Future() + ->setRawAWSQuery( + 'DescribeInstances', + array( + 'InstanceId.0' => $instance_id, + )) + ->resolve(); + break; + } catch (PhutilAWSException $ex) { + $this->log(pht( + 'Instance could not be found (due '. + 'to eventual consistency), trying again in 5 seconds.')); + sleep(5); + continue; + } + } + + $this->log(pht( + 'Instance %s is now consistent for API access.', + $instance_id)); + } else { $settings['MinCount'] = 1; $settings['MaxCount'] = 1;