3 final class PhabricatorElasticsearchSetupCheck
extends PhabricatorSetupCheck
{
5 public function getDefaultGroup() {
6 return self
::GROUP_OTHER
;
9 protected function executeChecks() {
10 // TODO: Avoid fataling if we don't have a master database configured
11 // but have the MySQL search index configured. See T12965.
12 if (PhabricatorEnv
::isReadOnly()) {
16 $services = PhabricatorSearchService
::getAllServices();
18 foreach ($services as $service) {
20 $host = $service->getAnyHostForRole('read');
21 } catch (PhabricatorClusterNoHostForRoleException
$e) {
25 if ($host instanceof PhabricatorElasticsearchHost
) {
29 $engine = $host->getEngine();
30 $index_exists = $engine->indexExists();
32 $index_sane = $engine->indexIsSane();
34 } catch (Exception
$ex) {
35 $summary = pht('Elasticsearch is not reachable as configured.');
37 'Elasticsearch is configured (with the %s setting) but an '.
38 'exception was encountered when trying to test the index.'.
41 phutil_tag('tt', array(), 'cluster.search'),
42 phutil_tag('pre', array(), $ex->getMessage()));
44 $this->newIssue('elastic.misconfigured')
45 ->setName(pht('Elasticsearch Misconfigured'))
46 ->setSummary($summary)
47 ->setMessage($message)
48 ->addRelatedPhabricatorConfig('cluster.search');
54 'You enabled Elasticsearch but the index does not exist.');
57 'You likely enabled cluster.search without creating the '.
58 'index. Use the following command to create a new index.');
61 ->newIssue('elastic.missing-index')
62 ->setName(pht('Elasticsearch Index Not Found'))
63 ->addCommand('./bin/search init')
64 ->setSummary($summary)
65 ->setMessage($message);
67 } else if (!$index_sane) {
69 'Elasticsearch index exists but needs correction.');
72 'Either the schema for Elasticsearch has changed '.
73 'or Elasticsearch created the index automatically. '.
74 'Use the following command to rebuild the index.');
77 ->newIssue('elastic.broken-index')
78 ->setName(pht('Elasticsearch Index Schema Mismatch'))
79 ->addCommand('./bin/search init')
80 ->setSummary($summary)
81 ->setMessage($message);