Index: src/applications/drydock/blueprint/DrydockAmazonEC2HostBlueprintImplementation.php =================================================================== --- src/applications/drydock/blueprint/DrydockAmazonEC2HostBlueprintImplementation.php +++ src/applications/drydock/blueprint/DrydockAmazonEC2HostBlueprintImplementation.php @@ -727,8 +727,12 @@ pht('Waiting for successful %s connection', $protocol_name)); $resource->save(); + $last_attempt = PhabricatorTime::getNow(); + while (true) { try { + $last_attempt = PhabricatorTime::getNow(); + $this->log(pht( 'Attempting to connect to \'%s\' via %s', $instance_id, @@ -808,6 +812,16 @@ throw new Exception( 'Allocated instance, but ended up in unexpected state \''. $instance_state.'\'!'); + } else { + $check_time = PhabricatorTime::getNow() - $last_attempt; + if ($check_time < 60) { + $this->log(pht( + '%s connection returned too quickly, manually sleeping '. + 'for %d seconds to avoid a large number of AWS calls.', + $protocol_name, + 60 - $check_time)); + sleep(60 - $check_time); + } } continue; @@ -925,8 +939,8 @@ '%s connection returned too quickly, manually sleeping '. 'for %d seconds to avoid a large number of AWS calls.', $protocol_name, - $check_time)); - sleep($check_time); + 60 - $check_time)); + sleep(60 - $check_time); } }