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

Commit

Permalink
Merge pull request #209 from docker/staging
Browse files Browse the repository at this point in the history
v1.6.7
  • Loading branch information
Feng Honglin authored Jun 14, 2017
2 parents a124906 + 9eb0dbd commit 46c0922
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.4
FROM alpine:3.6
MAINTAINER Feng Honglin <[email protected]>

COPY . /haproxy-src
Expand Down
2 changes: 1 addition & 1 deletion haproxy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.6.6"
__version__ = "1.6.7"
1 change: 1 addition & 0 deletions haproxy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def parse_additional_backend_settings(envvars):
CACERT_DIR = "/cacerts/"
HAPROXY_CONFIG_FILE = "/haproxy.cfg"
HAPROXY_RUN_COMMAND = ['/usr/sbin/haproxy', '-f', HAPROXY_CONFIG_FILE, '-db', '-q']
HAPROXY_CONFIG_CHECK_COMMAND = ['/usr/sbin/haproxy', '-c', '-f', HAPROXY_CONFIG_FILE]
API_RETRY = 10 # seconds
PID_FILE = "/tmp/dockercloud-haproxy.pid"
SERVICE_PORTS_ENVVAR_NAME = "SERVICE_PORTS"
Expand Down
15 changes: 13 additions & 2 deletions haproxy/helper/update_helper.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import errno
import logging
import subprocess
import threading
import time

from haproxy.config import HAPROXY_RUN_COMMAND, RELOAD_TIMEOUT
from haproxy.config import HAPROXY_RUN_COMMAND, RELOAD_TIMEOUT, HAPROXY_CONFIG_CHECK_COMMAND

logger = logging.getLogger("haproxy")

Expand All @@ -21,7 +22,17 @@
#
def run_reload(old_process, timeout=int(RELOAD_TIMEOUT)):
if old_process:
# Reload haproxy
# Config check
p = subprocess.Popen(HAPROXY_CONFIG_CHECK_COMMAND, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output, err = p.communicate()
if p.returncode != 0:
logger.error("Config check failed. NOT reloading haproxy: %s - %s" % (err, output))
return old_process
else:
logger.info("Config check passed")

# Reload Haproxy
logger.info("Reloading HAProxy")
if timeout == -1:
flag = "-st"
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/helper/test_update_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ def poll(self):
def terminate(self):
self.terminated = True

def communicate(self):
return ("", "")

pass

class Object(object):
returncode = 0

def communicate(self):
return ("", "")

pass

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

0 comments on commit 46c0922

Please sign in to comment.