Skip to content

Commit

Permalink
Handle legacy HAPROXY_HEAD (daemon and expose-fd listeners)
Browse files Browse the repository at this point in the history
For users that have existing custom HAPROXY_HEAD settings, make
adjustments to meet the new zero downtime reload settings.

Specifically:
- remove (comment out) the 'daemon' keyword (in the 'global' block)
- add 'expose-fd listeners' to the stats socket

These corrections are rudimentary; ideally, customers should fix their
HAPROXY_HEAD settings.
  • Loading branch information
justinrlee committed Dec 29, 2017
1 parent 719f335 commit 5038c96
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions marathon_lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,28 @@ def config(apps, groups, bind_http_https, ssl_certs, templater,
https_frontends = templater.haproxy_https_frontend_head.format(
sslCerts=" ".join(map(lambda cert: "crt " + cert, _ssl_certs))
)
# This should handle situations where customers have a custom HAPROXY_HEAD
# that includes the 'daemon' flag:
if 'daemon' in config:
logger.debug("Commenting out daemon setting")
config = config.replace("daemon", "# daemon", 1)

# This should handle situations where customers have a custom HAPROXY_HEAD
# that does not yet expose the listeners file descriptor
if "expose-fd listeners" not in config:
if "stats socket /var/run/haproxy/socket" in config:
logger.debug("Appending 'expose-fd listeners' to stats socket")
config = config.replace("stats socket /var/run/haproxy/socket",
"stats socket /var/run/haproxy/socket expose-fd listeners")
else:
logger.debug(
("Adding '"
"stats socket /var/run/haproxy/socket expose-fd listeners"
"' after 'global' line"))
config = config.replace("global",
("global\n"
" stats socket /var/run/haproxy/socket expose-fd listeners"),
1)

userlists = str()
frontends = str()
Expand Down

0 comments on commit 5038c96

Please sign in to comment.