Skip to content

Commit 9d264d1

Browse files
vulturmvalentinab25
authored andcommitted
Fix some typos that led to incorrect generation of backend code (#17)
* [configure.py] Fix BACKENDS_MODE typo, not reading the correct env var. * [docker-entrypoint] Only enable /track_hosts cron when BACKENDS env var is not present. Otherwise /track_hosts cron script will overwrite and mess up our backends * [backends] Only add http check option when backend is of type http, otherwise will break tcp.
1 parent f24d705 commit 9d264d1

3 files changed

Lines changed: 19 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 2019-11-15 (1.8-1.4)
4+
5+
- Fix BACKENDS_MODE typo, not reading the correct env var.
6+
- Only enable /track_hosts cron when BACKENDS env var is not present. Otherwise /track_hosts cron script will overwrite and mess up our backends
7+
- Only add http check option when backend is of type http, otherwise will break tcp backends.
8+
39
## 2018-11-21 (1.8-1.3)
410

511
- Upgrade to haproxy 1.8.14

haproxy/docker-entrypoint.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ if ! test -e /etc/haproxy/haproxy.cfg; then
2020
# Find backend within /etc/hosts
2121
touch /etc/haproxy/hosts.backends
2222
python3 /configure.py hosts
23+
echo "*/${DNS_TTL:-1} * * * * /track_hosts | logger " > /var/crontab.txt
2324
fi
2425

25-
echo "*/${DNS_TTL:-1} * * * * /track_hosts | logger " > /var/crontab.txt
26-
2726
fi
2827

2928
#add crontab

haproxy/src/configure.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
STATS_AUTH = os.environ.get('STATS_AUTH', 'admin:admin')
2121
BACKENDS = os.environ.get('BACKENDS', '').split(' ')
2222
BACKENDS_PORT = os.environ.get('BACKENDS_PORT', '80')
23-
BACKENDS_MODE = os.environ.get('BACKEND_MODE', 'http')
23+
BACKENDS_MODE = os.environ.get('BACKENDS_MODE', 'http')
2424
LOGGING = os.environ.get('LOGGING', '127.0.0.1')
2525
LOG_LEVEL = os.environ.get('LOG_LEVEL', 'notice')
2626
TIMEOUT_CONNECT = os.environ.get('TIMEOUT_CONNECT', '5000')
@@ -59,10 +59,6 @@
5959
backend $backend
6060
mode $mode
6161
balance $balance
62-
option forwardfor
63-
http-request set-header X-Forwarded-Port %[dst_port]
64-
http-request add-header X-Forwarded-Proto https if { ssl_fc }
65-
option httpchk $httpchk HTTP/1.1\\r\\nHost:localhost
6662
default-server inter $inter fastinter $fastinter downinter $downinter fall $fall rise $rise
6763
cookie SRV_ID insert
6864
""")
@@ -75,14 +71,18 @@
7571
backend $backend
7672
mode $mode
7773
balance $balance
74+
default-server inter $inter fastinter $fastinter downinter $downinter fall $fall rise $rise
75+
cookie SRV_ID prefix
76+
""")
77+
cookies = ""
78+
79+
80+
backend_type_http = Template("""
7881
option forwardfor
7982
http-request set-header X-Forwarded-Port %[dst_port]
8083
http-request add-header X-Forwarded-Proto https if { ssl_fc }
8184
option httpchk $httpchk HTTP/1.1\\r\\nHost:localhost
82-
default-server inter $inter fastinter $fastinter downinter $downinter fall $fall rise $rise
83-
cookie SRV_ID prefix
8485
""")
85-
cookies = ""
8686

8787
backend_conf_plus = Template("""
8888
server $name-$index $host:$port $cookies check
@@ -97,14 +97,17 @@
9797
backend=BACKEND_NAME,
9898
mode=BACKENDS_MODE,
9999
balance=BALANCE,
100-
httpchk=HTTPCHK,
101100
inter=INTER,
102101
fastinter=FAST_INTER,
103102
downinter=DOWN_INTER,
104103
fall=FALL,
105104
rise=RISE
106105
)
107106

107+
if BACKENDS_MODE == 'http':
108+
backend_conf += backend_type_http.substitute(
109+
httpchk=HTTPCHK
110+
)
108111

109112
################################################################################
110113
# Backends are resolved using internal or external DNS service

0 commit comments

Comments
 (0)