amenezes / config-client

config-client package for spring cloud config and cloud foundry
https://config-client.amenezes.net/
Apache License 2.0
24 stars 18 forks source link

Question: I need an advice on how to troubleshoot "Failed to establish connection with ConfigServer." #28

Closed agorina closed 4 years ago

agorina commented 4 years ago

Our app runs fine in the docker container locally and is able to connect to the remote config server. However, when deployed to K8s (in the same docker container) it logs "Failed to establish connection with ConfigServer.". When I exec into K8s pod I am able to CURL (after I manually installed CURL) to the config server as well.

Any advice on how to troubleshoot this would be very much appreciated.

amenezes commented 4 years ago

@agorina,

Did you set the environment variables propertly?

Can you run CURL with the c.url output as in the example below?

from config import ConfigClient

c = ConfigClient(app_name="simpleweb000")
c.url # For example: http://localhost:8888/master/simpleweb000-development.json
curl http://localhost:8888/master/simpleweb000-development.json

Is there any result from the command above with the values that you have set?

agorina commented 4 years ago

Thank you for the quick response: When I exec into k8s pod with my container running and run this from the python console:

import requests r=requests.get('http://configuration-service/qa/qti-scoring-engine-default.json')

The above work just fine.

However:

from config import spring config_client = spring.ConfigClient(app_name='qti-scoring-engine',address='http://configuration-service',branch='qa',profile='default',url='{address}/{branch}/{app_name}-{profile}.json') c = config_client.get_config() print(c) None

print(config_client)

ConfigClient(address='http://configuration-service', branch='qa', app_name='qti-scoring-engine', profile='default', url='http://configuration-service/qa/qti-scoring-engine-default.json', fail_fast=True)

As you could see the above fails. And the mistery gets even worse here:

print(config_client.url) http://configuration-service/qa/qti-scoring-engine-default.json R1= requests.get(config_client.url) print(R1) <Response [200]> c = config_client.get_config() print(c) None

Any help is very much appreciated

UPDATE: the issue is resolved; it was a dumb mistake on my part (hate to admit it) . Thank you for all the help!

amenezes commented 4 years ago

UPDATE: the issue is resolved; it was a dumb mistake on my part (hate to admit it) . Thank you for all the help!

Great @agorina.

I will try improve the documentation.