akeneo / pim-community-dev

[Community Development Repository] The open source Product Information Management (PIM)
http://www.akeneo.com
Other
954 stars 514 forks source link

APP_INDEX_HOSTS setting is ignored during "pim:installer:db" command #14970

Open djalal opened 3 years ago

djalal commented 3 years ago

:bug: I'm reporting a Bug :bug:

APP_INDEX_HOSTS setting is ignored during "pim:installer:db" command.

Use case

We try to run the installer command like this:

APP_ENV=dev php bin/console pim:installer:db --catalog vendor/akeneo/pim-community-dev/src/Akeneo/Platform/Bundle/InstallerBundle/Resources/fixtures/minimal

Encountered behavior

The command ends with a fatal error " No alive nodes found in your cluster", like below:

...
Reset elasticsearch indexes
[2021-07-13 22:37:43] console.CRITICAL: Error thrown while running command "pim:installer:db --catalog 'vendor/akeneo/pim-community-dev/src/Akeneo/Platform/Bundle/InstallerBundle/Resources/fixtures/minimal'". Message: "No alive nodes found in your cluster" {"exception":"[object] (Elasticsearch\\Common\\Exceptions\\NoNodesAvailableException(code: 0): No alive nodes found in your cluster at /var/www/html/pim-community-standard/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ConnectionPool/StaticNoPingConnectionPool.php:64)","command":"pim:installer:db --catalog 'vendor/akeneo/pim-community-dev/src/Akeneo/Platform/Bundle/InstallerBundle/Resources/fixtures/minimal'","message":"No alive nodes found in your cluster"} []
[2021-07-13 22:37:43] console.DEBUG: Command "pim:installer:db --catalog 'vendor/akeneo/pim-community-dev/src/Akeneo/Platform/Bundle/InstallerBundle/Resources/fixtures/minimal'" exited with code "1" {"command":"pim:installer:db --catalog 'vendor/akeneo/pim-community-dev/src/Akeneo/Platform/Bundle/InstallerBundle/Resources/fixtures/minimal'","code":1} []

In StaticNoPingConnectionPool.php line 64:

  No alive nodes found in your cluster

Troubleshooting

with a simple var_dump() inside "__construct()" method in ./vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php, we can see the APP_INDEX_HOSTS is ignored:

array(5) {
  ["scheme"]=>
  string(4) "http"
  ["host"]=>
  string(13) "elasticsearch"
  ["port"]=>
  int(9200)
  ["user"]=>
  string(7) "elastic"
  ["pass"]=>
  string(8) "changeme"
}
array(5) {
  ["scheme"]=>
  string(4) "http"
  ["host"]=>
  string(13) "elasticsearch"
  ["port"]=>
  int(9200)
  ["user"]=>
  string(7) "elastic"
  ["pass"]=>
  string(8) "changeme"
}
Prepare database schema
Dropped database `akeneo` for connection named default

Same env. var with another command is working well (the double displayed var is not a typo, its from the software):

./bin/console akeneo:elasticsearch:reset-indexes -n

array(3) {
  ["scheme"]=>
  string(5) "https"
  ["host"]=>
  string(81) "vpc-elasticsearch-REDACTED.eu-west-1.es.amazonaws.com"
  ["port"]=>
  int(443)
}
array(3) {
  ["scheme"]=>
  string(5) "https"
  ["host"]=>
  string(81) "vpc-elasticsearch-REDACTED.eu-west-1.es.amazonaws.com"
  ["port"]=>
  int(443)
}

This action will entirely reset the following indexes in the PIM:
akeneo_pim_product_and_product_model
akeneo_connectivity_connection_error
Resetting the index: akeneo_pim_product_and_product_model
Resetting the index: akeneo_connectivity_connection_error

All the indexes have been successfully reset!
tseho commented 3 years ago

Hello,

Thanks for opening an issue. Can you tell us which exact version you are using ?

on master, I tried to reproduce your issue, without success.


With APP_INDEX_HOSTS=elasticsearch:9200 in my .env file:

$ APP_ENV=dev run php bin/console pim:installer:db --catalog src/Akeneo/Platform/Bundle/InstallerBundle/Resources/fixtures/minimal
array(3) {
  ["scheme"]=>
  string(4) "http"
  ["host"]=>
  string(13) "elasticsearch"
  ["port"]=>
  int(9200)
}
Prepare database schema
Dropped database `akeneo_pim` for connection named default
Created database `akeneo_pim` for connection named default

// ...

:heavy_check_mark:


With APP_INDEX_HOSTS=foo:9200 in my .env file:

$ APP_ENV=dev run php bin/console pim:installer:db --catalog src/Akeneo/Platform/Bundle/InstallerBundle/Resources/fixtures/minimal
array(3) {
  ["scheme"]=>
  string(4) "http"
  ["host"]=>
  string(3) "foo"
  ["port"]=>
  int(9200)
}

// ...

Reset elasticsearch indexes

In StaticNoPingConnectionPool.php line 64:

  No alive nodes found in your cluster  

:heavy_check_mark: