Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot deploy module to a fresh production install #763

Closed
shavounet opened this issue Feb 16, 2018 · 7 comments
Closed

Cannot deploy module to a fresh production install #763

shavounet opened this issue Feb 16, 2018 · 7 comments

Comments

@shavounet
Copy link

shavounet commented Feb 16, 2018

This might or might not be a native Magento issue... but it prevent your module from being deployed in a standard production procedure.
Might be an edge case, or not... I'm not sure what is triggered

Preconditions

Magento Version : 2.2 (EE B2B, but unrelevent)
ElasticSuite Version : 2.5 (with new --es-hosts install flags)
Environment : prod but reproducible in dev

Steps to reproduce

  1. Get yourself a new env, with no db, ES, environment var... just a composer install & right permissions
  2. ./bin/magento setup:di:compile
  3. ./bin/magento setup:install (with no params, only to trigger param validation)

Expected result

  1. An error message should tell us there is no alive ES node found

Actual result

  1. Unable to connect ElasticSearch server : Notice: Undefined index: data in /var/www/html/vendor/magento/framework/App/Config/Initial.php on line 60

Note that this message prevent totally the install, even with right parameters (including es-hosts).

Here are the workarounds, I found :

  • delete generated folder (not ideal due to specific hosting platform...)
  • create a patch for Magento core to fix this silly notice what shouldn't exists anyway... (there is a second place to patch before it can work : Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248)
    • Once applied, the error message is Unable to connect ElasticSearch server : No alive nodes found in your cluster which is fine

I think it might be due to your code checking configuration, looking for es-hosts definition.

@romainruaud
Copy link
Collaborator

romainruaud commented Feb 19, 2018

Yeah, I am able to reproduce some strange behaviors (not exactly this one, but the "undefined index: websites" is easily reproduceable).

Imho this is due to the fact that when injecting the client during the setup:install, you may fall in a case where the client is calling $scopeConfig->getValue($path) which indeed would fail when called during setup:install

I will dig a bit more on this one.

Regards

@romainruaud
Copy link
Collaborator

Imho we should not try to "always" validate, even if no params were submitted :

https://github.com/Smile-SA/elasticsuite/blob/master/src/module-elasticsuite-core/Setup/ConfigOptionsList.php#L121

The validate() function should check if the $clientOptions variable is not empty before trying to validate it.

Same should apply for the createConfig function : configuration should be written only if $clientOptions is not empty.

@afoucret any thought ?

@romainruaud
Copy link
Collaborator

Note for myself : There is also an array_filter call on $clientOptions : this will remove the potential null value for enable_https_mode and then will lead the client to call $scopeConfig->getValue() which is not possible during setup:install.

@shavounet
Copy link
Author

FYI here are my Magento core patches to avoid this issue: https://gist.github.com/shavounet/bd0ac80e7fd63d97d17643ce316d5136

@romainruaud
Copy link
Collaborator

@shavounet yes that's sure that the error triggered by magento is quite unclear. But after more digging I'm now sure these errors are triggered when trying to access the ScopeConfiguration during the install process : this is impossible since the configuration has not been already built properly.

I agree that magento could handle this more nicely, but we'll also have to address this issue in Elasticsuite.

I will propose a fix to @afoucret soon and we'll keep you in touch.

Regards

@shavounet
Copy link
Author

Yeah I've hesitated to push the issue directly to Magento... but your module is for now the only one impacted. I think it could be up to you to push this issue directly to Magento (and see their reaction).

@afoucret
Copy link
Contributor

PR #769 will merge this one and will be part of release 2.5.2.

Feel free to test it

afoucret added a commit that referenced this issue Feb 20, 2018
Fix client connection in branch 2.5.x (#763 and #738).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants