mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
Raise a setup issue for misconfigured Elasticsearch
Summary: Fixes T8274. That report is very light on details, but I think the issue is that their Elasticsearch is misconfigured and the new setup warning dies a little too hard if the server is just completely dead. Test Plan: Set `search.elastic.host` to an invalid server, got a similar-looking exception (?), applied patch, got a setup warning instead. Reviewers: btrahan, joshuaspence Reviewed By: btrahan, joshuaspence Subscribers: epriestley Maniphest Tasks: T8274 Differential Revision: https://secure.phabricator.com/D12948
This commit is contained in:
parent
f99c7beb90
commit
f5a9d1f8d4
1 changed files with 57 additions and 30 deletions
|
@ -7,44 +7,71 @@ final class PhabricatorElasticSearchSetupCheck extends PhabricatorSetupCheck {
|
|||
}
|
||||
|
||||
protected function executeChecks() {
|
||||
if ($this->shouldUseElasticSearchEngine()) {
|
||||
$engine = new PhabricatorElasticSearchEngine();
|
||||
if (!$this->shouldUseElasticSearchEngine()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$engine->indexExists()) {
|
||||
$summary = pht(
|
||||
'You enabled Elasticsearch but the index does not exist.');
|
||||
$engine = new PhabricatorElasticSearchEngine();
|
||||
|
||||
$message = pht(
|
||||
'You likely enabled search.elastic.host without creating the '.
|
||||
'index. Run `./bin/search init` to correct the index.');
|
||||
|
||||
$this
|
||||
->newIssue('elastic.missing-index')
|
||||
->setName(pht('Elasticsearch index Not Found'))
|
||||
->setSummary($summary)
|
||||
->setMessage($message)
|
||||
->addRelatedPhabricatorConfig('search.elastic.host');
|
||||
} else if (!$engine->indexIsSane()) {
|
||||
$summary = pht(
|
||||
'Elasticsearch index exists but needs correction.');
|
||||
|
||||
$message = pht(
|
||||
'Either the Phabricator schema for Elasticsearch has changed '.
|
||||
'or Elasticsearch created the index automatically. Run '.
|
||||
'`./bin/search init` to correct the index.');
|
||||
|
||||
$this
|
||||
->newIssue('elastic.broken-index')
|
||||
->setName(pht('Elasticsearch index Incorrect'))
|
||||
->setSummary($summary)
|
||||
->setMessage($message);
|
||||
$index_exists = null;
|
||||
$index_sane = null;
|
||||
try {
|
||||
$index_exists = $engine->indexExists();
|
||||
if ($index_exists) {
|
||||
$index_sane = $engine->indexIsSane();
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
$summary = pht('Elasticsearch is not reachable as configured.');
|
||||
$message = pht(
|
||||
'Elasticsearch is configured (with the %s setting) but Phabricator '.
|
||||
'encountered an exception when trying to test the index.'.
|
||||
"\n\n".
|
||||
'%s',
|
||||
phutil_tag('tt', array(), 'search.elastic.host'),
|
||||
phutil_tag('pre', array(), $ex->getMessage()));
|
||||
|
||||
$this->newIssue('elastic.misconfigured')
|
||||
->setName(pht('Elasticsearch Misconfigured'))
|
||||
->setSummary($summary)
|
||||
->setMessage($message)
|
||||
->addRelatedPhabricatorConfig('search.elastic.host');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$index_exists) {
|
||||
$summary = pht(
|
||||
'You enabled Elasticsearch but the index does not exist.');
|
||||
|
||||
$message = pht(
|
||||
'You likely enabled search.elastic.host without creating the '.
|
||||
'index. Run `./bin/search init` to correct the index.');
|
||||
|
||||
$this
|
||||
->newIssue('elastic.missing-index')
|
||||
->setName(pht('Elasticsearch index Not Found'))
|
||||
->setSummary($summary)
|
||||
->setMessage($message)
|
||||
->addRelatedPhabricatorConfig('search.elastic.host');
|
||||
} else if (!$index_sane) {
|
||||
$summary = pht(
|
||||
'Elasticsearch index exists but needs correction.');
|
||||
|
||||
$message = pht(
|
||||
'Either the Phabricator schema for Elasticsearch has changed '.
|
||||
'or Elasticsearch created the index automatically. Run '.
|
||||
'`./bin/search init` to correct the index.');
|
||||
|
||||
$this
|
||||
->newIssue('elastic.broken-index')
|
||||
->setName(pht('Elasticsearch index Incorrect'))
|
||||
->setSummary($summary)
|
||||
->setMessage($message);
|
||||
}
|
||||
}
|
||||
|
||||
protected function shouldUseElasticSearchEngine() {
|
||||
$search_engine = PhabricatorSearchEngine::loadEngine();
|
||||
return $search_engine instanceof PhabricatorElasticSearchEngine;
|
||||
return ($search_engine instanceof PhabricatorElasticSearchEngine);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue