docker-archive / dockercloud-haproxy

HAproxy image that autoreconfigures itself when used in Docker Cloud
https://cloud.docker.com/
651 stars 187 forks source link

DNS resolution of loggers at startup #230

Open markvr opened 6 years ago

markvr commented 6 years ago

In Docker swarm, we currently set the value for haproxy: RSYSLOG_DESTINATION="local-traffic-logger len 65535" \

Where "local-traffic-logger" is another swarm service that saves the traffic logs to storage.

If haproxy starts before the "local-traffic-logger" service does, it fails to start with error:

[ALERT] 283/162105 (87) : parsing [/haproxy.cfg:3] : 'log': invalid address: 'local-traffic-logger' in 'local-traffic-logger'

If local-traffic-logger crashes when haproxy is running, haproxy keeps going:

ERROR:haproxy:Config check failed. NOT reloading haproxy: [ALERT] 283/162105 (87) : parsing [/haproxy.cfg:2] : 'log': invalid address: 'local-traffic-logger' in 'local-traffic-logger'

However this is quite an unstable state.

How about checking the value of "RSYSLOG_DESTINATION" in the Python scripts, and only inserting it into the config if it resolves?

I've tried using the HAProxy setting "init-addr" as:

defaults
    default-server init-addr libc,none

But it still fails to start - I guess this setting doesn't apply to the logging name resolution.

I'm happy to send a PR for this if you think it is a sensible suggestion?