Open janmyszkier opened 5 years ago
@pszreder can You step in on here please?
@janmyszkier I see that you have a problem with non-default index (vue_storefront_catalog_eur). You have to remember that in this case each storeview has a separate elasticsearch configuration (including the host / port), it does not inherit from the "main".
Could you show us the content of your local.json file? At least, "elasticsearch" and "storeViews" root properties.
@pszreder elasticsearch:
"elasticsearch": {
"host": "172.24.0.8",
"port": 9200,
"user": "elastic",
"password": "changeme",
"min_score": 0.01,
"indices": [
"vue_storefront_catalog_eur",
"vue_storefront_catalog_usd",
"vue_storefront_catalog_gbp",
"vue_storefront_catalog"
],
"indexTypes": [
"product",
"category",
"cms",
"attribute",
"taxrule",
"review"
]
},
storeviews:
"storeViews": {
"multistore": true,
"mapStoreUrlsFor": [
"eur",
"gbp",
"usd"
],
"eur": {
"storeCode": "eur",
"disabled": false,
"storeId": 2,
"name": "MyStore Europe",
"url": "/eur/",
"elasticsearch": {
"host": "localhost:8080/api/catalog",
"index": "vue_storefront_catalog_eur"
},
"tax": {
"defaultCountry": "DE",
"defaultRegion": "",
"calculateServerSide": true,
"sourcePriceIncludesTax": true
},
"i18n": {
"fullCountryName": "Europe",
"fullLanguageName": "English",
"defaultLanguage": "EN",
"defaultCountry": "DE",
"defaultLocale": "en-US",
"currencyCode": "EUR",
"currencySign": "€ ",
"dateFormat": "HH:mm D-M-YYYY"
}
},
"usd": {
"storeCode": "usd",
"disabled": false,
"storeId": 3,
"name": "MyStore USA",
"url": "/usd/",
"elasticsearch": {
"host": "localhost:8080/api/catalog",
"index": "vue_storefront_catalog_usd"
},
"tax": {
"defaultCountry": "USA",
"defaultRegion": "",
"calculateServerSide": true,
"sourcePriceIncludesTax": true
},
"i18n": {
"fullCountryName": "United States of America",
"fullLanguageName": "English",
"defaultCountry": "USA",
"defaultLanguage": "en-US",
"defaultLocale": "en-US",
"currencyCode": "USD",
"currencySign": "$ ",
"dateFormat": "HH:mm D-M-YYYY"
}
},
"gbp": {
"storeCode": "gbp",
"disabled": false,
"storeId": 4,
"name": "MyStore UK",
"url": "/gbp/",
"elasticsearch": {
"host": "localhost:8080/api/catalog",
"index": "vue_storefront_catalog_gbp"
},
"tax": {
"defaultCountry": "UK",
"defaultRegion": "",
"calculateServerSide": true,
"sourcePriceIncludesTax": true
},
"i18n": {
"fullCountryName": "United Kingdom",
"fullLanguageName": "English",
"defaultCountry": "UK",
"defaultLanguage": "en-US",
"defaultLocale": "en-US",
"currencyCode": "GBP",
"currencySign": "£ ",
"dateFormat": "HH:mm D-M-YYYY"
}
}
},
Please note, however, the problem is not that elasticsearch is trying to write to incorrect index. Problem is the app queries wrong HOST.
Ok, so it's clearly defined in your configuration file:
"storeViews": {
"multistore": true,
"mapStoreUrlsFor": [
"eur",
"gbp",
"usd"
],
"eur": {
"storeCode": "eur",
"disabled": false,
"storeId": 2,
"name": "MyStore Europe",
"url": "/eur/",
"elasticsearch": {
"host": "localhost:8080/api/catalog",
"index": "vue_storefront_catalog_eur"
},
When you're using eur storeView, application is trying to reach vue_storefront_catalog_eur
index using localhost:8080
ES instance.
You have to remember that in this case each storeview has a separate elasticsearch configuration (including the host / port), it does not inherit from the "main".
But... In this case, there could be also some problem inside "mage2vs import" action.
There is a possibility that it ignore ES configuration comes from node-config and using hard-coded "localhost" value as an elasticsearch host.
@pkarw wdyt?
@pszreder I don't think you're right. Well.. or you are, but this is still a bug. Even if this is source config
"host": "localhost:8080/api/catalog",
why it's connected to localhost:9200
we see in the error? localhost:9200 was nowhere configured.
ALSO localhost:8080/api is api SOURCE, not a write endpoint, so I don't think localhost:8080 provided in elasticsearch host has anything to do with it.
The config.elasticsearch
in vue-storefront-api SHOULD BE write
endpoint - elasticsearch itself. This config property is used in the npm run db ...
scripts.
The URL is set in this line: https://github.com/DivanteLtd/vue-storefront-api/blob/37d8ee822009629dffac252b907afb47e58ac99e/scripts/mage2vs.js#L35
... and then used by `mage2vuestorefront: https://github.com/DivanteLtd/mage2vuestorefront/blob/91e18075afebb57c367e0e25aad3e2b7c71a03b6/src/config.js#L30
Would be awesome if @janmyszkier could help us to debug this issue, why the right value hasn't been passed to mage2vs?
@janmyszkier is the issue still present in v1.8.3?
@lukeromanowicz steps to reproduce fresh git clone of this repo
"elasticsearch": {
"host": "IP.OF.DO.DROPLET",
docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml up -d
docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml exec app yarn mage2vs import
see how you get:
== CREATING NEW DATABASE ==
Elasticsearch INFO: 2019-04-13T20:35:32Z
Adding connection to http://elasticsearch:9200/
** Hello! I am going to create NEW ES index
Elasticsearch DEBUG: 2019-04-13T20:35:32Z starting request { "method": "DELETE", "path": "/*/_alias/vue_storefront_catalog", "query": {} }
Elasticsearch ERROR: 2019-04-13T20:35:32Z
Error: Request error, retrying
DELETE http://elasticsearch:9200/*/_alias/vue_storefront_catalog => getaddrinfo ENOTFOUND elasticsearch elasticsearch:9200
at Log.error (/var/www/node_modules/elasticsearch/src/lib/log.js:226:56)
at checkRespForFailure (/var/www/node_modules/elasticsearch/src/lib/transport.js:259:18)
at HttpConnector.
It tried to query named host `elasticsearch` completely ignoring the `host` config node.
@lukeromanowicz has this issue been addressed? I am encountering the same thing with my configured version of the api.
@cmcmannus my GUESS it's because of this file:
https://github.com/DivanteLtd/vue-storefront-api/blob/master/docker/vue-storefront-api/default.env
which is used during the docker instance creation and from my experience ENV vars CAN override the local config.
and that seems to be the case, because elasticsearch:9200
is exactly what's in this config file.
Still, if I have provided the config in the config file, that's what should be used.
@janmyszkier that was exactly it. Sorry I forgot to update the thread saying I'd figured it out, but thanks for following up!
Just tried to run the app with docker: docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml exec app yarn mage2vs import
However, localhost is not what I have given in my config before I started the app. There's
http://172.24.0.8:9200
in there and I can confirm there's correct ES on that IP withdocker-compose -f docker-compose.yml -f docker-compose.nodejs.yml exec app curl http://172.24.0.8:9200
.I would expect the app to query what was given in config, but that's not the case. Why?