magento / ece-tools

All Submissions you make to Magento Inc. (“Magento") through GitHub are subject to the following terms and conditions: (1) You grant Magento a perpetual, worldwide, non-exclusive, no charge, royalty free, irrevocable license under your applicable copyrights and patents to reproduce, prepare derivative works of, display, publically perform, sublicense and distribute any feedback, ideas, code, or other information (“Submission") you submit through GitHub. (2) Your Submission is an original work of authorship and you are the owner or are legally entitled to grant the license stated above. (3) You agree to the Contributor License Agreement found here: https://github.com/magento/magento2/blob/master/CONTRIBUTOR_LICENSE_AGREEMENT.html
Open Software License 3.0
117 stars 83 forks source link

ElasticSuite Integrity Check Is Not Compatible With OpenSearch #807

Closed JosephLeedy closed 2 years ago

JosephLeedy commented 2 years ago

Preconditions

  1. ECE Tools 2002.1.10
  2. Adobe Commerce 2.4.4
  3. OpenSearch 1.2
  4. Valid OpenSearch configuration in YAML files
  5. PHP 8.1

Steps to reproduce

  1. Deploy a 2.4.4 install configured for PHP 8.1 and OpenSearch 1.2

Expected result

  1. Deployment should complete without any errors logged

Actual result

  1. "ElasticSuite is installed without available ElasticSearch service." error is logged

Solution

The following patch resolves this error:

diff --git a/vendor/magento/ece-tools/src/Config/Validator/Deploy/ElasticSuiteIntegrity.php b/vendor/magento/ece-tools/src/Config/Validator/Deploy/ElasticSuiteIntegrity.php
index bc045e2..f66d508 100644
--- a/vendor/magento/ece-tools/src/Config/Validator/Deploy/ElasticSuiteIntegrity.php
+++ b/vendor/magento/ece-tools/src/Config/Validator/Deploy/ElasticSuiteIntegrity.php
@@ -15,6 +15,7 @@ use Magento\MagentoCloud\Config\Validator;
 use Magento\MagentoCloud\Config\ValidatorException;
 use Magento\MagentoCloud\Config\ValidatorInterface;
 use Magento\MagentoCloud\Service\ElasticSearch;
+use Magento\MagentoCloud\Service\OpenSearch;

 /**
  * Validates different aspects of ElasticSuite's configuration.
@@ -31,6 +32,11 @@ class ElasticSuiteIntegrity implements ValidatorInterface
      */
     private $elasticSearch;

+    /**
+     * @var OpenSearch
+     */
+    private $openSearch;
+
     /**
      * @var Validator\ResultFactory
      */
@@ -44,24 +50,27 @@ class ElasticSuiteIntegrity implements ValidatorInterface
     /**
      * @param ElasticSuite $elasticSuite
      * @param ElasticSearch $elasticSearch
+     * @param OpenSearch $openSearch
      * @param Validator\ResultFactory $resultFactory
      * @param DeployInterface $config
      */
     public function __construct(
         ElasticSuite $elasticSuite,
         ElasticSearch $elasticSearch,
+        OpenSearch $openSearch,
         Validator\ResultFactory $resultFactory,
         DeployInterface $config
     ) {
         $this->elasticSuite = $elasticSuite;
         $this->elasticSearch = $elasticSearch;
+        $this->openSearch = $openSearch;
         $this->resultFactory = $resultFactory;
         $this->config = $config;
     }

     /**
      * If ElasticSuite is absent - skip validation.
-     * If ElasticSuite is present and no ElasticSearch connection - fail validation.
+     * If ElasticSuite is present and no ElasticSearch or OpenSearch connection - fail validation.
      * If search engine is manually set to non-ElasticSuite it will fail after deploy - fail validation.
      *
      * Otherwise - validation is successful.
@@ -76,9 +85,9 @@ class ElasticSuiteIntegrity implements ValidatorInterface
             return $this->resultFactory->success();
         }

-        if (!$this->elasticSearch->isInstalled()) {
+        if (!$this->elasticSearch->isInstalled() && !$this->openSearch->isInstalled()) {
             return $this->resultFactory->error(
-                'ElasticSuite is installed without available ElasticSearch service.',
+                'ElasticSuite is installed without available ElasticSearch or OpenSearch service.',
                 '',
                 Error::DEPLOY_ELASTIC_SUITE_WITHOUT_ES
             );
diff --git a/vendor/magento/ece-tools/src/Test/Unit/Config/Validator/Deploy/ElasticSuiteIntegrityTest.php b/vendor/magento/ece-tools/src/Test/Unit/Config/Validator/Deploy/ElasticSuiteIntegrityTest.php
index 1048928..48d02ca 100644
--- a/vendor/magento/ece-tools/src/Test/Unit/Config/Validator/Deploy/ElasticSuiteIntegrityTest.php
+++ b/vendor/magento/ece-tools/src/Test/Unit/Config/Validator/Deploy/ElasticSuiteIntegrityTest.php
@@ -89,7 +89,7 @@ class ElasticSuiteIntegrityTest extends TestCase
         $this->resultFactoryMock->expects($this->once())
             ->method('error')
             ->with(
-                'ElasticSuite is installed without available ElasticSearch service.',
+                'ElasticSuite is installed without available ElasticSearch or OpenSearch service.',
                 '',
                 AppError::DEPLOY_ELASTIC_SUITE_WITHOUT_ES
             )
ssx commented 2 years ago

For the life of me, I can't believe Magento have become this poor.

BarnyShergold commented 2 years ago

@JosephLeedy - As you have supplied the solution , can you not create a PR on ECE-Tools to fix?

BaDos commented 2 years ago

There is an internal task to fix it: MCLOUD-8767

JosephLeedy commented 2 years ago

@BarnyShergold I could, I just did not have time to when I created this PR.

BaDos commented 2 years ago

@JosephLeedy I'm going to apply your patch, test it and merge it to the develop branch.

If you want to create a PR - I can process it.

JosephLeedy commented 2 years ago

Thanks @BaDos! Go ahead and do whatever you need to.

BaDos commented 2 years ago

@JosephLeedy the fix was merged to the develop branch Please check it, if need feel free to reopen this issue Thank you for your contribution

JosephLeedy commented 2 years ago

Thanks @BaDos!