Differential D13421 Diff 32502 src/applications/drydock/blueprint/DrydockAmazonEC2HostBlueprintImplementation.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/blueprint/DrydockAmazonEC2HostBlueprintImplementation.php
Show First 20 Lines • Show All 689 Lines • ▼ Show 20 Lines | if ($resource->getAttribute('protocol') === 'ssh') { | ||||
$ssh->setConnectTimeout(60); | $ssh->setConnectTimeout(60); | ||||
} | } | ||||
$resource->setAttribute( | $resource->setAttribute( | ||||
'aws-status', | 'aws-status', | ||||
pht('Waiting for successful %s connection', $protocol_name)); | pht('Waiting for successful %s connection', $protocol_name)); | ||||
$resource->save(); | $resource->save(); | ||||
$last_attempt = PhabricatorTime::getNow(); | |||||
while (true) { | while (true) { | ||||
try { | try { | ||||
$last_attempt = PhabricatorTime::getNow(); | |||||
$this->log(pht( | $this->log(pht( | ||||
'Attempting to connect to \'%s\' via %s', | 'Attempting to connect to \'%s\' via %s', | ||||
$instance_id, | $instance_id, | ||||
$protocol_name)); | $protocol_name)); | ||||
$ssh_future = $ssh->getExecFuture('echo "test"'); | $ssh_future = $ssh->getExecFuture('echo "test"'); | ||||
$ssh_future->resolvex(); | $ssh_future->resolvex(); | ||||
if ($ssh_future->getWasKilledByTimeout()) { | if ($ssh_future->getWasKilledByTimeout()) { | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | while (true) { | ||||
$resource->setAttribute( | $resource->setAttribute( | ||||
'aws-status', | 'aws-status', | ||||
'Terminated'); | 'Terminated'); | ||||
$resource->save(); | $resource->save(); | ||||
throw new Exception( | throw new Exception( | ||||
'Allocated instance, but ended up in unexpected state \''. | 'Allocated instance, but ended up in unexpected state \''. | ||||
$instance_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, | |||||
$check_time)); | |||||
sleep($check_time); | |||||
} | |||||
} | } | ||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
// Update the resource into open status. | // Update the resource into open status. | ||||
$resource->setStatus(DrydockResourceStatus::STATUS_OPEN); | $resource->setStatus(DrydockResourceStatus::STATUS_OPEN); | ||||
▲ Show 20 Lines • Show All 435 Lines • Show Last 20 Lines |