Differential D19778 Diff 47264 src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php
Show All 24 Lines | protected function executeRepositoryOperations() { | ||||
$cluster_engine = id(new DiffusionRepositoryClusterEngine()) | $cluster_engine = id(new DiffusionRepositoryClusterEngine()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->setRepository($repository) | ->setRepository($repository) | ||||
->setLog($this); | ->setLog($this); | ||||
if ($this->shouldProxy()) { | if ($this->shouldProxy()) { | ||||
$command = $this->getProxyCommand(true); | $command = $this->getProxyCommand(true); | ||||
$did_synchronize = false; | $did_write = false; | ||||
if ($device) { | if ($device) { | ||||
$this->writeClusterEngineLogMessage( | $this->writeClusterEngineLogMessage( | ||||
pht( | pht( | ||||
"# Push received by \"%s\", forwarding to cluster host.\n", | "# Push received by \"%s\", forwarding to cluster host.\n", | ||||
$device->getName())); | $device->getName())); | ||||
} | } | ||||
} else { | } else { | ||||
$command = csprintf('git-receive-pack %s', $repository->getLocalPath()); | $command = csprintf('git-receive-pack %s', $repository->getLocalPath()); | ||||
$did_synchronize = true; | $did_write = true; | ||||
$cluster_engine->synchronizeWorkingCopyBeforeWrite(); | $cluster_engine->synchronizeWorkingCopyBeforeWrite(); | ||||
if ($device) { | if ($device) { | ||||
$this->writeClusterEngineLogMessage( | $this->writeClusterEngineLogMessage( | ||||
pht( | pht( | ||||
"# Ready to receive on cluster host \"%s\".\n", | "# Ready to receive on cluster host \"%s\".\n", | ||||
$device->getName())); | $device->getName())); | ||||
} | } | ||||
} | } | ||||
$caught = null; | $caught = null; | ||||
try { | try { | ||||
$err = $this->executeRepositoryCommand($command); | $err = $this->executeRepositoryCommand($command); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
$caught = $ex; | $caught = $ex; | ||||
} | } | ||||
// We've committed the write (or rejected it), so we can release the lock | // We've committed the write (or rejected it), so we can release the lock | ||||
// without waiting for the client to receive the acknowledgement. | // without waiting for the client to receive the acknowledgement. | ||||
if ($did_synchronize) { | if ($did_write) { | ||||
$cluster_engine->synchronizeWorkingCopyAfterWrite(); | $cluster_engine->synchronizeWorkingCopyAfterWrite(); | ||||
} | } | ||||
if ($caught) { | if ($caught) { | ||||
throw $caught; | throw $caught; | ||||
} | } | ||||
if (!$err) { | if (!$err) { | ||||
$this->waitForGitClient(); | |||||
// When a repository is clustered, we reach this cleanup code on both | |||||
// the proxy and the actual final endpoint node. Don't do more cleanup | |||||
// or logging than we need to. | |||||
if ($did_write) { | |||||
$repository->writeStatusMessage( | $repository->writeStatusMessage( | ||||
PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE, | PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE, | ||||
PhabricatorRepositoryStatusMessage::CODE_OKAY); | PhabricatorRepositoryStatusMessage::CODE_OKAY); | ||||
$this->waitForGitClient(); | |||||
$host_wait_end = microtime(true); | $host_wait_end = microtime(true); | ||||
$this->updatePushLogWithTimingInformation( | $this->updatePushLogWithTimingInformation( | ||||
$this->getClusterEngineLogProperty('writeWait'), | $this->getClusterEngineLogProperty('writeWait'), | ||||
$this->getClusterEngineLogProperty('readWait'), | $this->getClusterEngineLogProperty('readWait'), | ||||
($host_wait_end - $host_wait_start)); | ($host_wait_end - $host_wait_start)); | ||||
} | |||||
} | } | ||||
return $err; | return $err; | ||||
} | } | ||||
private function executeRepositoryCommand($command) { | private function executeRepositoryCommand($command) { | ||||
$repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
$command = PhabricatorDaemon::sudoCommandAsDaemonUser($command); | $command = PhabricatorDaemon::sudoCommandAsDaemonUser($command); | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |