Skip to content

Commit df74fd0

Browse files
Revert "MCLOUD-5706: Add support of new ES option to ECE-Tools"
1 parent 97d4a5f commit df74fd0

File tree

7 files changed

+81
-227
lines changed

7 files changed

+81
-227
lines changed

config/services.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
<service id="Magento\MagentoCloud\Scenario\Exception\ValidationException" autowire="false" />
3636
<service id="Magento\MagentoCloud\Service\ServiceMismatchException" autowire="false" />
3737
<service id="Magento\MagentoCloud\Config\ValidatorException" autowire="false" />
38-
<service id="Magento\MagentoCloud\Service\ServiceException" autowire="false" />
3938
<service id="Magento\MagentoCloud\Shell\Process" autowire="false" />
4039
<service id="Magento\MagentoCloud\Shell\ProcessException" autowire="false" />
4140
<service id="Magento\MagentoCloud\Step\Build\BackupData" autowire="false" />

src/Config/SearchEngine.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,12 @@ private function getSolrConfiguration(array $config): array
179179
*/
180180
private function getElasticSearchConfiguration(array $config): array
181181
{
182-
$engine = $this->elasticSearch->getFullVersion();
182+
$engine = ElasticSearch::ENGINE_NAME;
183+
184+
$esVersion = $this->elasticSearch->getVersion();
185+
if (Semver::satisfies($esVersion, '>= 5')) {
186+
$engine .= (int)$esVersion;
187+
}
183188

184189
$elasticSearchConfig = [
185190
'engine' => $engine,

src/Config/SearchEngine/ElasticSuite.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,6 @@ public function get(): array
7373
return $this->configMerger->merge($this->getConfig(), $envConfig);
7474
}
7575

76-
/**
77-
* @return string
78-
*/
79-
public function getServers(): string
80-
{
81-
return $this->get()['es_client']['servers'] ?? '';
82-
}
83-
8476
/**
8577
* Checks if both ElasticSearch and ElasticSuite are installed.
8678
*

src/Service/ElasticSearch.php

Lines changed: 13 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@
77

88
namespace Magento\MagentoCloud\Service;
99

10-
use Composer\Semver\Semver;
1110
use Magento\MagentoCloud\Config\Environment;
1211
use Magento\MagentoCloud\Http\ClientFactory;
1312
use Psr\Log\LoggerInterface;
14-
use Throwable;
1513

1614
/**
1715
* Returns ElasticSearch service configurations.
1816
*/
1917
class ElasticSearch implements ServiceInterface
2018
{
21-
private const RELATIONSHIP_KEY = 'elasticsearch';
22-
public const ENGINE_NAME = 'elasticsearch';
19+
const RELATIONSHIP_KEY = 'elasticsearch';
20+
const ENGINE_NAME = 'elasticsearch';
2321

2422
/**
2523
* @var ClientFactory
@@ -82,79 +80,33 @@ public function getConfiguration(): array
8280
* elasticsearch doesn't exist in relationships.
8381
*
8482
* @return string
85-
*
86-
* @throws ServiceException
8783
*/
8884
public function getVersion(): string
8985
{
90-
if (!$this->isInstalled()) {
91-
throw new ServiceException('ES service is not installed');
92-
}
93-
9486
if ($this->version === null) {
87+
$this->version = '0';
88+
89+
$config = $this->getConfiguration();
90+
if (!$config) {
91+
return $this->version;
92+
}
93+
9594
try {
9695
$esConfiguration = $this->call(sprintf(
9796
'%s:%s',
98-
$this->getHost(),
99-
$this->getPort()
97+
$config['host'],
98+
$config['port']
10099
));
101100

102101
$this->version = $esConfiguration['version']['number'];
103-
} catch (Throwable $exception) {
104-
throw new ServiceException('Can\'t get version of elasticsearch: ' . $exception->getMessage());
102+
} catch (\Exception $exception) {
103+
$this->logger->warning('Can\'t get version of elasticsearch: ' . $exception->getMessage());
105104
}
106105
}
107106

108107
return $this->version;
109108
}
110109

111-
/**
112-
* Retrieve host.
113-
*
114-
* @return string
115-
* @throws ServiceException
116-
*/
117-
public function getHost(): string
118-
{
119-
if (!$this->isInstalled()) {
120-
throw new ServiceException('ES service is not installed');
121-
}
122-
123-
return (string)$this->getConfiguration()['host'];
124-
}
125-
126-
/**
127-
* Retrieve port.
128-
*
129-
* @return string
130-
* @throws ServiceException
131-
*/
132-
public function getPort(): string
133-
{
134-
if (!$this->isInstalled()) {
135-
throw new ServiceException('ES service is not installed');
136-
}
137-
138-
return (string)$this->getConfiguration()['port'];
139-
}
140-
141-
/**
142-
* Return full version with engine name.
143-
*
144-
* @return string
145-
* @throws ServiceException
146-
*/
147-
public function getFullVersion(): string
148-
{
149-
$version = $this->getVersion();
150-
151-
if (Semver::satisfies($version, '>= 5')) {
152-
return self::ENGINE_NAME . (int)$version;
153-
}
154-
155-
return self::ENGINE_NAME;
156-
}
157-
158110
/**
159111
* Retrieves default template configuration.
160112
* May contain configuration for replicas and shards.

src/Service/ServiceException.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)