Differential D13421 Diff 32882 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 721 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, | |||||
60 - $check_time)); | |||||
sleep(60 - $check_time); | |||||
} | |||||
} | } | ||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
if ($resource->getAttribute('platform') === 'windows') { | if ($resource->getAttribute('platform') === 'windows') { | ||||
$drive_path = $this->getDetail('storage-path'); | $drive_path = $this->getDetail('storage-path'); | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | if ($resource->getAttribute('platform') === 'windows') { | ||||
$instance_state.'\'!'); | $instance_state.'\'!'); | ||||
} else { | } else { | ||||
$check_time = PhabricatorTime::getNow() - $last_attempt; | $check_time = PhabricatorTime::getNow() - $last_attempt; | ||||
if ($check_time < 60) { | if ($check_time < 60) { | ||||
$this->log(pht( | $this->log(pht( | ||||
'%s connection returned too quickly, manually sleeping '. | '%s connection returned too quickly, manually sleeping '. | ||||
'for %d seconds to avoid a large number of AWS calls.', | 'for %d seconds to avoid a large number of AWS calls.', | ||||
$protocol_name, | $protocol_name, | ||||
$check_time)); | 60 - $check_time)); | ||||
sleep($check_time); | sleep(60 - $check_time); | ||||
} | } | ||||
} | } | ||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 442 Lines • Show Last 20 Lines |