1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Skip some repository checks in cluster enviornments

Summary:
Ref T2783. Currently, the repository edit page does some checks agaisnt the local system to look for binaries and files on disk. These checks don't make sense in a cluster environment.

Ideally, we could make a Conduit call to the host (e.g., add something like `diffusion.querysetupstatus`) to do these checks, but since they're pretty basic config things and cluster installs are advanced, it doesn't seem super worthwhile for now.

Test Plan: Saw fewer checks in a cluster repo.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2783

Differential Revision: https://secure.phabricator.com/D11102
This commit is contained in:
epriestley 2014-12-31 11:50:35 -08:00
parent 376729b44c
commit 8c4f3edd8a
2 changed files with 66 additions and 47 deletions

View file

@ -683,6 +683,7 @@ final class DiffusionRepositoryEditMainController
PhabricatorRepository $repository) { PhabricatorRepository $repository) {
$viewer = $this->getRequest()->getUser(); $viewer = $this->getRequest()->getUser();
$is_cluster = $repository->getAlmanacServicePHID();
$view = new PHUIStatusListView(); $view = new PHUIStatusListView();
@ -756,54 +757,61 @@ final class DiffusionRepositoryEditMainController
} }
$binaries = array_unique($binaries); $binaries = array_unique($binaries);
foreach ($binaries as $binary) { if (!$is_cluster) {
$where = Filesystem::resolveBinary($binary); // We're only checking for binaries if we aren't running with a cluster
if (!$where) { // configuration. In theory, we could check for binaries on the
$view->addItem( // repository host machine, but we'd need to make this more complicated
id(new PHUIStatusItemView()) // to do that.
->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')
->setTarget(
pht('Missing Binary %s', phutil_tag('tt', array(), $binary)))
->setNote(pht(
"Unable to find this binary in the webserver's PATH. You may ".
"need to configure %s.",
$this->getEnvConfigLink())));
} else {
$view->addItem(
id(new PHUIStatusItemView())
->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')
->setTarget(
pht('Found Binary %s', phutil_tag('tt', array(), $binary)))
->setNote(phutil_tag('tt', array(), $where)));
}
}
// This gets checked generically above. However, for svn commit hooks, we foreach ($binaries as $binary) {
// need this to be in environment.append-paths because subversion strips $where = Filesystem::resolveBinary($binary);
// PATH. if (!$where) {
if ($svnlook_check) {
$where = Filesystem::resolveBinary('svnlook');
if ($where) {
$path = substr($where, 0, strlen($where) - strlen('svnlook'));
$dirs = PhabricatorEnv::getEnvConfig('environment.append-paths');
$in_path = false;
foreach ($dirs as $dir) {
if (Filesystem::isDescendant($path, $dir)) {
$in_path = true;
break;
}
}
if (!$in_path) {
$view->addItem( $view->addItem(
id(new PHUIStatusItemView()) id(new PHUIStatusItemView())
->setIcon(PHUIStatusItemView::ICON_WARNING, 'red') ->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')
->setTarget( ->setTarget(
pht('Missing Binary %s', phutil_tag('tt', array(), $binary))) pht('Missing Binary %s', phutil_tag('tt', array(), $binary)))
->setNote(pht( ->setNote(pht(
'Unable to find this binary in `environment.append-paths`. '. "Unable to find this binary in the webserver's PATH. You may ".
'You need to configure %s and include %s.', "need to configure %s.",
$this->getEnvConfigLink(), $this->getEnvConfigLink())));
$path))); } else {
$view->addItem(
id(new PHUIStatusItemView())
->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')
->setTarget(
pht('Found Binary %s', phutil_tag('tt', array(), $binary)))
->setNote(phutil_tag('tt', array(), $where)));
}
}
// This gets checked generically above. However, for svn commit hooks, we
// need this to be in environment.append-paths because subversion strips
// PATH.
if ($svnlook_check) {
$where = Filesystem::resolveBinary('svnlook');
if ($where) {
$path = substr($where, 0, strlen($where) - strlen('svnlook'));
$dirs = PhabricatorEnv::getEnvConfig('environment.append-paths');
$in_path = false;
foreach ($dirs as $dir) {
if (Filesystem::isDescendant($path, $dir)) {
$in_path = true;
break;
}
}
if (!$in_path) {
$view->addItem(
id(new PHUIStatusItemView())
->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')
->setTarget(
pht('Missing Binary %s', phutil_tag('tt', array(), $binary)))
->setNote(pht(
'Unable to find this binary in `environment.append-paths`. '.
'You need to configure %s and include %s.',
$this->getEnvConfigLink(),
$path)));
}
} }
} }
} }
@ -829,6 +837,12 @@ final class DiffusionRepositoryEditMainController
->execute(); ->execute();
if ($pull_daemon) { if ($pull_daemon) {
// TODO: In a cluster environment, we need a daemon on this repository's
// host, specifically, and we aren't checking for that right now. This
// is a reasonable proxy for things being more-or-less correctly set up,
// though.
$view->addItem( $view->addItem(
id(new PHUIStatusItemView()) id(new PHUIStatusItemView())
->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green') ->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')
@ -861,7 +875,12 @@ final class DiffusionRepositoryEditMainController
->setNote($daemon_instructions)); ->setNote($daemon_instructions));
} }
if ($repository->usesLocalWorkingCopy()) {
if ($is_cluster) {
// Just omit this status check for now in cluster environments. We
// could make a service call and pull it from the repository host
// eventually.
} else if ($repository->usesLocalWorkingCopy()) {
$local_parent = dirname($repository->getLocalPath()); $local_parent = dirname($repository->getLocalPath());
if (Filesystem::pathExists($local_parent)) { if (Filesystem::pathExists($local_parent)) {
$view->addItem( $view->addItem(

View file

@ -55,7 +55,7 @@ final class PhabricatorWorkerArchiveTaskQuery
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn_r,
'ids in (%Ld)', 'id in (%Ld)',
$this->ids); $this->ids);
} }