mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-31 08:58:20 +01:00
Allow timeouts to be specified on Drydock SSH connections
Summary: This allows timeouts to be specified on SSH connections that Drydock makes. Used in the EC2 allocator to poll for the SSH server starting. Test Plan: Used in EC2 allocator diff. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D10225
This commit is contained in:
parent
e48aaa563a
commit
d2111214f2
1 changed files with 18 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
||||||
final class DrydockSSHCommandInterface extends DrydockCommandInterface {
|
final class DrydockSSHCommandInterface extends DrydockCommandInterface {
|
||||||
|
|
||||||
private $passphraseSSHKey;
|
private $passphraseSSHKey;
|
||||||
|
private $connectTimeout;
|
||||||
|
|
||||||
private function openCredentialsIfNotOpen() {
|
private function openCredentialsIfNotOpen() {
|
||||||
if ($this->passphraseSSHKey !== null) {
|
if ($this->passphraseSSHKey !== null) {
|
||||||
|
@ -25,6 +26,11 @@ final class DrydockSSHCommandInterface extends DrydockCommandInterface {
|
||||||
PhabricatorUser::getOmnipotentUser());
|
PhabricatorUser::getOmnipotentUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setConnectTimeout($timeout) {
|
||||||
|
$this->connectTimeout = $timeout;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getExecFuture($command) {
|
public function getExecFuture($command) {
|
||||||
$this->openCredentialsIfNotOpen();
|
$this->openCredentialsIfNotOpen();
|
||||||
|
|
||||||
|
@ -44,8 +50,19 @@ final class DrydockSSHCommandInterface extends DrydockCommandInterface {
|
||||||
$full_command = 'C:\\Windows\\system32\\cmd.exe /C '.$full_command;
|
$full_command = 'C:\\Windows\\system32\\cmd.exe /C '.$full_command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$command_timeout = '';
|
||||||
|
if ($this->connectTimeout !== null) {
|
||||||
|
$command_timeout = csprintf(
|
||||||
|
'-o %s',
|
||||||
|
'ConnectTimeout='.$this->connectTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
return new ExecFuture(
|
return new ExecFuture(
|
||||||
'ssh -o StrictHostKeyChecking=no -p %s -i %P %P@%s -- %s',
|
'ssh '.
|
||||||
|
'-o StrictHostKeyChecking=no '.
|
||||||
|
'-o BatchMode=yes '.
|
||||||
|
'%C -p %s -i %P %P@%s -- %s',
|
||||||
|
$command_timeout,
|
||||||
$this->getConfig('port'),
|
$this->getConfig('port'),
|
||||||
$this->passphraseSSHKey->getKeyfileEnvelope(),
|
$this->passphraseSSHKey->getKeyfileEnvelope(),
|
||||||
$this->passphraseSSHKey->getUsernameEnvelope(),
|
$this->passphraseSSHKey->getUsernameEnvelope(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue