Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit 46c0922

Browse files
author
Feng Honglin
authored
Merge pull request #209 from docker/staging
v1.6.7
2 parents a124906 + 9eb0dbd commit 46c0922

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.4
1+
FROM alpine:3.6
22
MAINTAINER Feng Honglin <hfeng@tutum.co>
33

44
COPY . /haproxy-src

haproxy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.6.6"
1+
__version__ = "1.6.7"

haproxy/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def parse_additional_backend_settings(envvars):
129129
CACERT_DIR = "/cacerts/"
130130
HAPROXY_CONFIG_FILE = "/haproxy.cfg"
131131
HAPROXY_RUN_COMMAND = ['/usr/sbin/haproxy', '-f', HAPROXY_CONFIG_FILE, '-db', '-q']
132+
HAPROXY_CONFIG_CHECK_COMMAND = ['/usr/sbin/haproxy', '-c', '-f', HAPROXY_CONFIG_FILE]
132133
API_RETRY = 10 # seconds
133134
PID_FILE = "/tmp/dockercloud-haproxy.pid"
134135
SERVICE_PORTS_ENVVAR_NAME = "SERVICE_PORTS"

haproxy/helper/update_helper.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import errno
12
import logging
23
import subprocess
34
import threading
45
import time
56

6-
from haproxy.config import HAPROXY_RUN_COMMAND, RELOAD_TIMEOUT
7+
from haproxy.config import HAPROXY_RUN_COMMAND, RELOAD_TIMEOUT, HAPROXY_CONFIG_CHECK_COMMAND
78

89
logger = logging.getLogger("haproxy")
910

@@ -21,7 +22,17 @@
2122
#
2223
def run_reload(old_process, timeout=int(RELOAD_TIMEOUT)):
2324
if old_process:
24-
# Reload haproxy
25+
# Config check
26+
p = subprocess.Popen(HAPROXY_CONFIG_CHECK_COMMAND, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
27+
stderr=subprocess.PIPE)
28+
output, err = p.communicate()
29+
if p.returncode != 0:
30+
logger.error("Config check failed. NOT reloading haproxy: %s - %s" % (err, output))
31+
return old_process
32+
else:
33+
logger.info("Config check passed")
34+
35+
# Reload Haproxy
2536
logger.info("Reloading HAProxy")
2637
if timeout == -1:
2738
flag = "-st"

tests/unit/helper/test_update_helper.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ def poll(self):
2525
def terminate(self):
2626
self.terminated = True
2727

28+
def communicate(self):
29+
return ("", "")
30+
2831
pass
2932

3033
class Object(object):
34+
returncode = 0
35+
36+
def communicate(self):
37+
return ("", "")
38+
3139
pass
3240

3341
@mock.patch("haproxy.helper.update_helper.subprocess.Popen")

0 commit comments

Comments
 (0)