mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 04:50:55 +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,10 +7,38 @@ final class PhabricatorElasticSearchSetupCheck extends PhabricatorSetupCheck {
|
|||
}
|
||||
|
||||
protected function executeChecks() {
|
||||
if ($this->shouldUseElasticSearchEngine()) {
|
||||
if (!$this->shouldUseElasticSearchEngine()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$engine = new PhabricatorElasticSearchEngine();
|
||||
|
||||
if (!$engine->indexExists()) {
|
||||
$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.');
|
||||
|
||||
|
@ -24,7 +52,7 @@ final class PhabricatorElasticSearchSetupCheck extends PhabricatorSetupCheck {
|
|||
->setSummary($summary)
|
||||
->setMessage($message)
|
||||
->addRelatedPhabricatorConfig('search.elastic.host');
|
||||
} else if (!$engine->indexIsSane()) {
|
||||
} else if (!$index_sane) {
|
||||
$summary = pht(
|
||||
'Elasticsearch index exists but needs correction.');
|
||||
|
||||
|
@ -40,11 +68,10 @@ final class PhabricatorElasticSearchSetupCheck extends PhabricatorSetupCheck {
|
|||
->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