Skip to content

Commit c5fe5af

Browse files
authored
MCLOUD-8405: Change OS validator (#80)
1 parent 2e75785 commit c5fe5af

File tree

14 files changed

+143
-27
lines changed

14 files changed

+143
-27
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
/codeception.yml
1010
/_workdir
1111
/*.code-workspace
12+
**/.phpunit.result.cache

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@
9191
]
9292
},
9393
"config": {
94-
"sort-packages": true
94+
"sort-packages": true,
95+
"allow-plugins": {
96+
"funkjedi/composer-include-files": true
97+
}
9598
},
9699
"prefer-stable": true,
97100
"extra": {

config/schema.error.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,3 +651,9 @@
651651
stage: deploy
652652
step: validate-config
653653
type: warning
654+
!php/const Magento\MagentoCloud\App\Error::DEPLOY_MAGENTO_VERSION_DOES_NOT_SUPPORT_OS:
655+
step: validate-config
656+
title: 'Incorrect search engine'
657+
suggestion: 'This Magento version does not support Opensearch. You must use versions 2.3.7-p3, 2.4.3-p2, or higher'
658+
stage: deploy
659+
type: critical

scenario/deploy.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
<item name="remote-storage" xsi:type="object" priority="1000">Magento\MagentoCloud\Step\Deploy\RemoteStorage</item>
102102
<!-- Config update end -->
103103
<item name="set-admin-url" xsi:type="object" priority="1000">Magento\MagentoCloud\Step\Deploy\InstallUpdate\Update\SetAdminUrl</item>
104+
<item name="clean-cache" xsi:type="object" priority="1050">CleanCache.Deploy</item>
104105
<item name="setup" xsi:type="object" priority="1100">Magento\MagentoCloud\Step\Deploy\InstallUpdate\Update\Setup</item>
105106
<item name="split-db" xsi:type="object" priority="1200">Magento\MagentoCloud\Step\Deploy\SplitDbConnection</item>
106107
<item name="cache-type" xsi:type="object" priority="1300">Magento\MagentoCloud\Step\Deploy\InstallUpdate\ConfigUpdate\CacheType</item>

src/App/Error.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class Error
7878
public const DEPLOY_REMOVED_SPLIT_DB = 136;
7979
public const DEPLOY_OS_CANNOT_CONNECT = 137;
8080
public const DEPLOY_OS_SERVICE_NOT_INSTALLED = 138;
81+
public const DEPLOY_MAGENTO_VERSION_DOES_NOT_SUPPORT_OS = 139;
8182

8283
public const PD_DEPLOY_IS_FAILED = 201;
8384
public const PD_ENV_PHP_IS_NOT_WRITABLE = 202;

src/Config/Validator/Deploy/ElasticSearchIntegrity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __construct(
6666
public function validate(): Validator\ResultInterface
6767
{
6868
try {
69-
if ($this->magentoVersion->isGreaterOrEqual('2.4.4') && $this->openSearch->isInstalled()) {
69+
if ($this->magentoVersion->satisfies('>=2.4.3-p2') && $this->openSearch->isInstalled()) {
7070
return $this->resultFactory->success();
7171
}
7272

src/Config/Validator/Deploy/OpenSearchIntegrity.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ public function validate(): Validator\ResultInterface
7171
return $this->resultFactory->success();
7272
}
7373

74-
if ($this->magentoVersion->isGreaterOrEqual('2.4.4')
74+
if (!$this->magentoVersion->satisfies('>=2.3.7-p3 <2.4.0 || >=2.4.3-p2')
75+
&& $this->openSearch->isInstalled()
76+
) {
77+
return $this->resultFactory->errorByCode(Error::DEPLOY_MAGENTO_VERSION_DOES_NOT_SUPPORT_OS);
78+
}
79+
80+
if ($this->magentoVersion->isGreaterOrEqual('2.4.3-p2')
7581
&& !$this->openSearch->isInstalled()
7682
) {
7783
return $this->resultFactory->errorByCode(Error::DEPLOY_OS_SERVICE_NOT_INSTALLED);

src/Config/Validator/Deploy/ServiceVersion.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function validate(): Validator\ResultInterface
8282
ServiceInterface::NAME_REDIS,
8383
ServiceInterface::NAME_REDIS_SESSION,
8484
ServiceInterface::NAME_ELASTICSEARCH,
85+
ServiceInterface::NAME_OPENSEARCH,
8586
$this->databaseType->getServiceName()
8687
];
8788

src/Service/Validator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class Validator
7171
'>=2.4.0 <2.4.2' => '~7.5.0 || ~7.6.0 || ~7.7.0',
7272
'>=2.4.2' => '~7.5.0 || ~7.6.0 || ~7.7.0 || ~7.9.0',
7373
],
74+
ServiceInterface::NAME_OPENSEARCH => [
75+
'>=2.3.7-p3 <2.4.0 || >=2.4.3-p2' => '~1.1 || ~1.2.1',
76+
],
7477
ServiceInterface::NAME_RABBITMQ => [
7578
'<2.3.0' => '~3.5.0',
7679
'>=2.3.0' => '~3.5.0 || ~3.7.0 || ~3.8.0',
@@ -186,7 +189,8 @@ private function getSupportedVersions(): array
186189
break;
187190
}
188191
}
189-
if (!isset($this->supportedVersionList[$serviceName])) {
192+
if (!isset($this->supportedVersionList[$serviceName])
193+
&& $serviceName !== ServiceInterface::NAME_OPENSEARCH) {
190194
throw new ServiceMismatchException(sprintf(
191195
'Service "%s" does not have defined configurations for "%s" Magento version',
192196
$serviceName,

src/Step/Deploy/InstallUpdate/Install/Setup/InstallCommandFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ private function getEsOptions(): array
246246
);
247247
}
248248

249-
if ($this->openSearch->isInstalled() && $this->magentoVersion->isGreaterOrEqual('2.4.4')) {
249+
if ($this->openSearch->isInstalled()
250+
&& $this->magentoVersion->satisfies('>=2.3.7-p3 <2.4.0 || >=2.4.3-p2')
251+
) {
250252
$engine = $this->openSearch->getFullEngineName();
251253
$host = $this->openSearch->getHost();
252254
$port = $this->openSearch->getPort();

0 commit comments

Comments
 (0)