graphite-project / docker-graphite-statsd

Official Docker image for Graphite
MIT License
479 stars 174 forks source link

[BUG] GRAPHITE_CLUSTER_SERVERS env var not setting hosts in local_settings.py #139

Closed cwillhelm closed 4 years ago

cwillhelm commented 4 years ago

Whenever I set this environment variable, I can see that it is set within the container:

/opt/graphite/webapp/graphite # env
HOSTNAME=417962db1d35
SHLVL=1
HOME=/root
OLDPWD=/opt/graphite/webapp
GOCARBON=1
STATSD_INTERFACE=udp
RELAY=1
TERM=xterm
GRAPHITE_CLUSTER_SERVERS=graphite001,graphite002,graphite003

But when I check local_settings.py, I don't see the hosts in the array:

/opt/graphite/webapp/graphite # grep -i "cluster_servers" local_settings.py
#CLUSTER_SERVERS = ["10.0.2.2:80", "10.0.2.3:80"]
CLUSTER_SERVERS = [x for x in [host.strip() for host in os.environ.get('GRAPHITE_CLUSTER_SERVERS', '').split(",")] if x]

Shouldn't this variable be set? When I do:

/# python3
>>> import os 
>>>   [x for x in [host.strip() for host in os.environ.get('GRAPHITE_CLUSTER_SERVERS', '').split(",")] if x]
>>>['graphite001', 'graphite002', 'graphite003']

I can see that they are set correctly, so either I'm misunderstanding how the env var works, or there is some type of issue with the injection of it.

I was mainly under the impression that I would see the array of hosts in that parameter.

This is running on Ubuntu 16 with the latest master version of the container.

deniszh commented 4 years ago

Hello @cwillhelm ,

Not sure which issue do you have. local_settings.py is a python file, which Graphite runs during start, so, in current configuration it's taking environment variable GRAPHITE_CLUSTER_SERVERS, which contain one or more comma separated servers and put it content in proper form in CLUSTER_SERVERS python array - that's exactly what current code in local_settings.py doing.

deniszh commented 4 years ago

We have no such luxury for example with carbon.conf, which is simple config file, so, that's why issues like https://github.com/graphite-project/docker-graphite-statsd/issues/132 exists

cwillhelm commented 4 years ago

Ah, I see what you mean. Thanks for the clarification -- makes perfect sense!