Merge ~hloeung/content-cache-charm:haproxy-config into content-cache-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: Jay Kuri
Approved revision: 5ad6f1c42aa974f083052f5c0a66b7a7ad86f8cb
Merged at revision: f640753c7c52a81131bb70b1c34774c20ff4d542
Proposed branch: ~hloeung/content-cache-charm:haproxy-config
Merge into: content-cache-charm:master
Diff against target: 434 lines (+58/-1)
11 files modified
lib/haproxy.py (+5/-1)
reactive/content_cache.py (+5/-0)
tests/unit/files/content_cache_rendered_haproxy_test_output.txt (+10/-0)
tests/unit/files/content_cache_rendered_haproxy_test_output2.txt (+2/-0)
tests/unit/files/content_cache_rendered_haproxy_test_output3.txt (+1/-0)
tests/unit/files/content_cache_rendered_haproxy_test_output_auto_maxconns.txt (+10/-0)
tests/unit/files/content_cache_rendered_haproxy_test_output_backup.txt (+2/-0)
tests/unit/files/content_cache_rendered_haproxy_test_output_load_balancing_algorithm.txt (+10/-0)
tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads.txt (+10/-0)
tests/unit/files/content_cache_rendered_haproxy_test_output_srv_template.txt (+1/-0)
tests/unit/test_content_cache.py (+2/-0)
Reviewer Review Type Date Requested Status
Canonical IS Reviewers Pending
Content Cache Charmers Pending
Review via email: mp+396208@code.launchpad.net

Commit message

Improve resiliency with HAProxy redispatch

This is as suggested by Jay in an internal ticket. Note that retries already defaults to 3.

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision f640753c7c52a81131bb70b1c34774c20ff4d542

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/haproxy.py b/lib/haproxy.py
index a68068b..14d0fc7 100644
--- a/lib/haproxy.py
+++ b/lib/haproxy.py
@@ -303,7 +303,11 @@ backend backend-{name}
303303
304 opts = []304 opts = []
305 for option in loc_conf.get('backend-options', []):305 for option in loc_conf.get('backend-options', []):
306 opts.append('{indent}option {opt}'.format(opt=option, indent=INDENT))306 prefix = ''
307 if option.split()[0] in ['allbackups', 'forceclose', 'forwardfor', 'redispatch']:
308 prefix = 'option '
309 opts.append('{indent}{prefix}{opt}'.format(opt=option, prefix=prefix, indent=INDENT))
310
307 options = ''311 options = ''
308 if opts:312 if opts:
309 options = '\n'.join(opts + [''])313 options = '\n'.join(opts + [''])
diff --git a/reactive/content_cache.py b/reactive/content_cache.py
index 42c0997..5d6ddee 100644
--- a/reactive/content_cache.py
+++ b/reactive/content_cache.py
@@ -298,9 +298,14 @@ def configure_haproxy(): # NOQA: C901 LP#1825084
298 if backend_check_path:298 if backend_check_path:
299 new_cached_loc_conf['backend-check-path'] = backend_check_path299 new_cached_loc_conf['backend-check-path'] = backend_check_path
300 new_loc_conf['backend-check-path'] = backend_check_path300 new_loc_conf['backend-check-path'] = backend_check_path
301 new_loc_conf['backend-options'] = []
301 backend_options = loc_conf.get('backend-options')302 backend_options = loc_conf.get('backend-options')
302 if backend_options:303 if backend_options:
303 new_loc_conf['backend-options'] = backend_options304 new_loc_conf['backend-options'] = backend_options
305
306 # Make it more resilient to failures and redispatch requests to different backends.
307 new_loc_conf['backend-options'].append('redispatch 1')
308
304 new_cached_loc_conf['signed-url-hmac-key'] = loc_conf.get('signed-url-hmac-key')309 new_cached_loc_conf['signed-url-hmac-key'] = loc_conf.get('signed-url-hmac-key')
305 # Pass through selected backend location configs, if defined.310 # Pass through selected backend location configs, if defined.
306 for key in ('site-name', 'backend-inter-time', 'backend-tls'):311 for key in ('site-name', 'backend-inter-time', 'backend-tls'):
diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output.txt
index bd1bd1e..6fa7004 100644
--- a/tests/unit/files/content_cache_rendered_haproxy_test_output.txt
+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output.txt
@@ -147,6 +147,7 @@ backend backend-cached-site1-local
147 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 2048147 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 2048
148148
149backend backend-site1-local149backend backend-site1-local
150 option redispatch 1
150 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache151 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
151 http-request set-header Host site1.local152 http-request set-header Host site1.local
152 balance leastconn153 balance leastconn
@@ -162,6 +163,7 @@ backend backend-cached-site2-local
162 server server_1 127.0.0.1:6081 check inter 2s rise 2 fall 60 maxconn 2048163 server server_1 127.0.0.1:6081 check inter 2s rise 2 fall 60 maxconn 2048
163164
164backend backend-site2-local165backend backend-site2-local
166 option redispatch 1
165 option httpchk GET /check/ HTTP/1.0\r\nHost:\ site2.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache167 option httpchk GET /check/ HTTP/1.0\r\nHost:\ site2.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
166 http-request set-header Host site2.local168 http-request set-header Host site2.local
167 balance leastconn169 balance leastconn
@@ -179,6 +181,7 @@ backend backend-cached-site3-local
179backend backend-site3-local181backend backend-site3-local
180 option forwardfor except 127.0.0.1182 option forwardfor except 127.0.0.1
181 option forceclose183 option forceclose
184 option redispatch 1
182 option httpchk HEAD / HTTP/1.0\r\nHost:\ site3.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache185 option httpchk HEAD / HTTP/1.0\r\nHost:\ site3.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
183 http-request set-header Host site3.local186 http-request set-header Host site3.local
184 balance leastconn187 balance leastconn
@@ -201,12 +204,14 @@ backend backend-cached-site5
201 server server_1 127.0.0.1:6084 check inter 2s rise 2 fall 60 maxconn 2048204 server server_1 127.0.0.1:6084 check inter 2s rise 2 fall 60 maxconn 2048
202205
203backend backend-site5206backend backend-site5
207 option redispatch 1
204 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache208 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
205 http-request set-header Host site5.local209 http-request set-header Host site5.local
206 balance leastconn210 balance leastconn
207 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048211 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048
208212
209backend backend-site5-2213backend backend-site5-2
214 option redispatch 1
210 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache215 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
211 http-request set-header Host site5.local216 http-request set-header Host site5.local
212 balance leastconn217 balance leastconn
@@ -220,6 +225,7 @@ backend backend-cached-site6-local
220 server server_1 127.0.0.1:6085 check inter 2s rise 2 fall 60 maxconn 2048225 server server_1 127.0.0.1:6085 check inter 2s rise 2 fall 60 maxconn 2048
221226
222backend backend-site6-local227backend backend-site6-local
228 option redispatch 1
223 option httpchk HEAD / HTTP/1.0\r\nHost:\ site6.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache229 option httpchk HEAD / HTTP/1.0\r\nHost:\ site6.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
224 http-request set-header Host site6.local230 http-request set-header Host site6.local
225 balance leastconn231 balance leastconn
@@ -233,6 +239,7 @@ backend backend-cached-site7-local
233 server server_1 127.0.0.1:6086 check inter 2s rise 2 fall 60 maxconn 2048239 server server_1 127.0.0.1:6086 check inter 2s rise 2 fall 60 maxconn 2048
234240
235backend backend-site7-local241backend backend-site7-local
242 option redispatch 1
236 option httpchk HEAD / HTTP/1.0\r\nHost:\ site7.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache243 option httpchk HEAD / HTTP/1.0\r\nHost:\ site7.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
237 http-request set-header Host site7.local244 http-request set-header Host site7.local
238 balance leastconn245 balance leastconn
@@ -246,12 +253,14 @@ backend backend-cached-site8-local
246 server server_1 127.0.0.1:6087 check inter 2s rise 2 fall 60 maxconn 2048253 server server_1 127.0.0.1:6087 check inter 2s rise 2 fall 60 maxconn 2048
247254
248backend backend-site8-local255backend backend-site8-local
256 option redispatch 1
249 option httpchk HEAD / HTTP/1.0\r\nHost:\ site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache257 option httpchk HEAD / HTTP/1.0\r\nHost:\ site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
250 http-request set-header Host site8.local258 http-request set-header Host site8.local
251 balance leastconn259 balance leastconn
252 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048260 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048
253261
254backend backend-site8-local-2262backend backend-site8-local-2
263 option redispatch 1
255 option httpchk HEAD / HTTP/1.0\r\nHost:\ auth.site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache264 option httpchk HEAD / HTTP/1.0\r\nHost:\ auth.site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
256 http-request set-header Host auth.site8.local265 http-request set-header Host auth.site8.local
257 balance leastconn266 balance leastconn
@@ -265,6 +274,7 @@ backend backend-cached-site9-local
265 server server_1 127.0.0.1:6088 check inter 2s rise 2 fall 60 maxconn 2048274 server server_1 127.0.0.1:6088 check inter 2s rise 2 fall 60 maxconn 2048
266275
267backend backend-site9-local276backend backend-site9-local
277 option redispatch 1
268 option httpchk HEAD / HTTP/1.0\r\nHost:\ site9.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache278 option httpchk HEAD / HTTP/1.0\r\nHost:\ site9.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
269 http-request set-header Host site9.local279 http-request set-header Host site9.local
270 balance leastconn280 balance leastconn
diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output2.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output2.txt
index ef8dfa0..fe8a37f 100644
--- a/tests/unit/files/content_cache_rendered_haproxy_test_output2.txt
+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output2.txt
@@ -93,6 +93,8 @@ backend backend-cached-site1-local
93 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 204893 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 2048
9494
95backend backend-site1-local95backend backend-site1-local
96 retries 3
97 option redispatch 1
96 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache98 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
97 http-request set-header Host site1.local99 http-request set-header Host site1.local
98 balance leastconn100 balance leastconn
diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output3.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output3.txt
index ad10667..0c134d3 100644
--- a/tests/unit/files/content_cache_rendered_haproxy_test_output3.txt
+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output3.txt
@@ -98,6 +98,7 @@ backend backend-cached-site1-local
98 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 204898 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 2048
9999
100backend backend-site1-local100backend backend-site1-local
101 option redispatch 1
101 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache102 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
102 http-request set-header Host site1.local103 http-request set-header Host site1.local
103 balance leastconn104 balance leastconn
diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output_auto_maxconns.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output_auto_maxconns.txt
index d7c2c0a..9bc7d2b 100644
--- a/tests/unit/files/content_cache_rendered_haproxy_test_output_auto_maxconns.txt
+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output_auto_maxconns.txt
@@ -147,6 +147,7 @@ backend backend-cached-site1-local
147 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 2048147 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 2048
148148
149backend backend-site1-local149backend backend-site1-local
150 option redispatch 1
150 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache151 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
151 http-request set-header Host site1.local152 http-request set-header Host site1.local
152 balance leastconn153 balance leastconn
@@ -162,6 +163,7 @@ backend backend-cached-site2-local
162 server server_1 127.0.0.1:6081 check inter 2s rise 2 fall 60 maxconn 2048163 server server_1 127.0.0.1:6081 check inter 2s rise 2 fall 60 maxconn 2048
163164
164backend backend-site2-local165backend backend-site2-local
166 option redispatch 1
165 option httpchk GET /check/ HTTP/1.0\r\nHost:\ site2.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache167 option httpchk GET /check/ HTTP/1.0\r\nHost:\ site2.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
166 http-request set-header Host site2.local168 http-request set-header Host site2.local
167 balance leastconn169 balance leastconn
@@ -179,6 +181,7 @@ backend backend-cached-site3-local
179backend backend-site3-local181backend backend-site3-local
180 option forwardfor except 127.0.0.1182 option forwardfor except 127.0.0.1
181 option forceclose183 option forceclose
184 option redispatch 1
182 option httpchk HEAD / HTTP/1.0\r\nHost:\ site3.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache185 option httpchk HEAD / HTTP/1.0\r\nHost:\ site3.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
183 http-request set-header Host site3.local186 http-request set-header Host site3.local
184 balance leastconn187 balance leastconn
@@ -201,12 +204,14 @@ backend backend-cached-site5
201 server server_1 127.0.0.1:6084 check inter 2s rise 2 fall 60 maxconn 2048204 server server_1 127.0.0.1:6084 check inter 2s rise 2 fall 60 maxconn 2048
202205
203backend backend-site5206backend backend-site5
207 option redispatch 1
204 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache208 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
205 http-request set-header Host site5.local209 http-request set-header Host site5.local
206 balance leastconn210 balance leastconn
207 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048211 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048
208212
209backend backend-site5-2213backend backend-site5-2
214 option redispatch 1
210 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache215 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
211 http-request set-header Host site5.local216 http-request set-header Host site5.local
212 balance leastconn217 balance leastconn
@@ -220,6 +225,7 @@ backend backend-cached-site6-local
220 server server_1 127.0.0.1:6085 check inter 2s rise 2 fall 60 maxconn 2048225 server server_1 127.0.0.1:6085 check inter 2s rise 2 fall 60 maxconn 2048
221226
222backend backend-site6-local227backend backend-site6-local
228 option redispatch 1
223 option httpchk HEAD / HTTP/1.0\r\nHost:\ site6.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache229 option httpchk HEAD / HTTP/1.0\r\nHost:\ site6.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
224 http-request set-header Host site6.local230 http-request set-header Host site6.local
225 balance leastconn231 balance leastconn
@@ -233,6 +239,7 @@ backend backend-cached-site7-local
233 server server_1 127.0.0.1:6086 check inter 2s rise 2 fall 60 maxconn 2048239 server server_1 127.0.0.1:6086 check inter 2s rise 2 fall 60 maxconn 2048
234240
235backend backend-site7-local241backend backend-site7-local
242 option redispatch 1
236 option httpchk HEAD / HTTP/1.0\r\nHost:\ site7.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache243 option httpchk HEAD / HTTP/1.0\r\nHost:\ site7.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
237 http-request set-header Host site7.local244 http-request set-header Host site7.local
238 balance leastconn245 balance leastconn
@@ -246,12 +253,14 @@ backend backend-cached-site8-local
246 server server_1 127.0.0.1:6087 check inter 2s rise 2 fall 60 maxconn 2048253 server server_1 127.0.0.1:6087 check inter 2s rise 2 fall 60 maxconn 2048
247254
248backend backend-site8-local255backend backend-site8-local
256 option redispatch 1
249 option httpchk HEAD / HTTP/1.0\r\nHost:\ site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache257 option httpchk HEAD / HTTP/1.0\r\nHost:\ site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
250 http-request set-header Host site8.local258 http-request set-header Host site8.local
251 balance leastconn259 balance leastconn
252 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048260 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048
253261
254backend backend-site8-local-2262backend backend-site8-local-2
263 option redispatch 1
255 option httpchk HEAD / HTTP/1.0\r\nHost:\ auth.site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache264 option httpchk HEAD / HTTP/1.0\r\nHost:\ auth.site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
256 http-request set-header Host auth.site8.local265 http-request set-header Host auth.site8.local
257 balance leastconn266 balance leastconn
@@ -265,6 +274,7 @@ backend backend-cached-site9-local
265 server server_1 127.0.0.1:6088 check inter 2s rise 2 fall 60 maxconn 2048274 server server_1 127.0.0.1:6088 check inter 2s rise 2 fall 60 maxconn 2048
266275
267backend backend-site9-local276backend backend-site9-local
277 option redispatch 1
268 option httpchk HEAD / HTTP/1.0\r\nHost:\ site9.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache278 option httpchk HEAD / HTTP/1.0\r\nHost:\ site9.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
269 http-request set-header Host site9.local279 http-request set-header Host site9.local
270 balance leastconn280 balance leastconn
diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output_backup.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output_backup.txt
index 06670cd..7f6ab4d 100644
--- a/tests/unit/files/content_cache_rendered_haproxy_test_output_backup.txt
+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output_backup.txt
@@ -98,6 +98,7 @@ backend backend-cached-site1-local
9898
99backend backend-site1-local99backend backend-site1-local
100 option allbackups100 option allbackups
101 option redispatch 1
101 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache102 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
102 http-request set-header Host site1.local103 http-request set-header Host site1.local
103 balance leastconn104 balance leastconn
@@ -105,6 +106,7 @@ backend backend-site1-local
105 server server_2 192.168.1.2:8080 backup check inter 5s rise 2 fall 5 maxconn 2048106 server server_2 192.168.1.2:8080 backup check inter 5s rise 2 fall 5 maxconn 2048
106107
107backend backend-site1-local-2108backend backend-site1-local-2
109 option redispatch 1
108 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache110 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
109 http-request set-header Host site1.local111 http-request set-header Host site1.local
110 balance leastconn112 balance leastconn
diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output_load_balancing_algorithm.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output_load_balancing_algorithm.txt
index 486f3a2..645b39c 100644
--- a/tests/unit/files/content_cache_rendered_haproxy_test_output_load_balancing_algorithm.txt
+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output_load_balancing_algorithm.txt
@@ -147,6 +147,7 @@ backend backend-cached-site1-local
147 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 2048147 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 2048
148148
149backend backend-site1-local149backend backend-site1-local
150 option redispatch 1
150 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache151 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
151 http-request set-header Host site1.local152 http-request set-header Host site1.local
152 balance roundrobin153 balance roundrobin
@@ -162,6 +163,7 @@ backend backend-cached-site2-local
162 server server_1 127.0.0.1:6081 check inter 2s rise 2 fall 60 maxconn 2048163 server server_1 127.0.0.1:6081 check inter 2s rise 2 fall 60 maxconn 2048
163164
164backend backend-site2-local165backend backend-site2-local
166 option redispatch 1
165 option httpchk GET /check/ HTTP/1.0\r\nHost:\ site2.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache167 option httpchk GET /check/ HTTP/1.0\r\nHost:\ site2.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
166 http-request set-header Host site2.local168 http-request set-header Host site2.local
167 balance roundrobin169 balance roundrobin
@@ -179,6 +181,7 @@ backend backend-cached-site3-local
179backend backend-site3-local181backend backend-site3-local
180 option forwardfor except 127.0.0.1182 option forwardfor except 127.0.0.1
181 option forceclose183 option forceclose
184 option redispatch 1
182 option httpchk HEAD / HTTP/1.0\r\nHost:\ site3.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache185 option httpchk HEAD / HTTP/1.0\r\nHost:\ site3.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
183 http-request set-header Host site3.local186 http-request set-header Host site3.local
184 balance roundrobin187 balance roundrobin
@@ -201,12 +204,14 @@ backend backend-cached-site5
201 server server_1 127.0.0.1:6084 check inter 2s rise 2 fall 60 maxconn 2048204 server server_1 127.0.0.1:6084 check inter 2s rise 2 fall 60 maxconn 2048
202205
203backend backend-site5206backend backend-site5
207 option redispatch 1
204 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache208 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
205 http-request set-header Host site5.local209 http-request set-header Host site5.local
206 balance roundrobin210 balance roundrobin
207 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048211 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048
208212
209backend backend-site5-2213backend backend-site5-2
214 option redispatch 1
210 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache215 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
211 http-request set-header Host site5.local216 http-request set-header Host site5.local
212 balance roundrobin217 balance roundrobin
@@ -220,6 +225,7 @@ backend backend-cached-site6-local
220 server server_1 127.0.0.1:6085 check inter 2s rise 2 fall 60 maxconn 2048225 server server_1 127.0.0.1:6085 check inter 2s rise 2 fall 60 maxconn 2048
221226
222backend backend-site6-local227backend backend-site6-local
228 option redispatch 1
223 option httpchk HEAD / HTTP/1.0\r\nHost:\ site6.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache229 option httpchk HEAD / HTTP/1.0\r\nHost:\ site6.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
224 http-request set-header Host site6.local230 http-request set-header Host site6.local
225 balance roundrobin231 balance roundrobin
@@ -233,6 +239,7 @@ backend backend-cached-site7-local
233 server server_1 127.0.0.1:6086 check inter 2s rise 2 fall 60 maxconn 2048239 server server_1 127.0.0.1:6086 check inter 2s rise 2 fall 60 maxconn 2048
234240
235backend backend-site7-local241backend backend-site7-local
242 option redispatch 1
236 option httpchk HEAD / HTTP/1.0\r\nHost:\ site7.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache243 option httpchk HEAD / HTTP/1.0\r\nHost:\ site7.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
237 http-request set-header Host site7.local244 http-request set-header Host site7.local
238 balance roundrobin245 balance roundrobin
@@ -246,12 +253,14 @@ backend backend-cached-site8-local
246 server server_1 127.0.0.1:6087 check inter 2s rise 2 fall 60 maxconn 2048253 server server_1 127.0.0.1:6087 check inter 2s rise 2 fall 60 maxconn 2048
247254
248backend backend-site8-local255backend backend-site8-local
256 option redispatch 1
249 option httpchk HEAD / HTTP/1.0\r\nHost:\ site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache257 option httpchk HEAD / HTTP/1.0\r\nHost:\ site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
250 http-request set-header Host site8.local258 http-request set-header Host site8.local
251 balance roundrobin259 balance roundrobin
252 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048260 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048
253261
254backend backend-site8-local-2262backend backend-site8-local-2
263 option redispatch 1
255 option httpchk HEAD / HTTP/1.0\r\nHost:\ auth.site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache264 option httpchk HEAD / HTTP/1.0\r\nHost:\ auth.site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
256 http-request set-header Host auth.site8.local265 http-request set-header Host auth.site8.local
257 balance roundrobin266 balance roundrobin
@@ -265,6 +274,7 @@ backend backend-cached-site9-local
265 server server_1 127.0.0.1:6088 check inter 2s rise 2 fall 60 maxconn 2048274 server server_1 127.0.0.1:6088 check inter 2s rise 2 fall 60 maxconn 2048
266275
267backend backend-site9-local276backend backend-site9-local
277 option redispatch 1
268 option httpchk HEAD / HTTP/1.0\r\nHost:\ site9.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache278 option httpchk HEAD / HTTP/1.0\r\nHost:\ site9.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
269 http-request set-header Host site9.local279 http-request set-header Host site9.local
270 balance roundrobin280 balance roundrobin
diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads.txt
index 4e64b08..8e65dbc 100644
--- a/tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads.txt
+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads.txt
@@ -148,6 +148,7 @@ backend backend-cached-site1-local
148 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 2048148 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 2048
149149
150backend backend-site1-local150backend backend-site1-local
151 option redispatch 1
151 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache152 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
152 http-request set-header Host site1.local153 http-request set-header Host site1.local
153 balance leastconn154 balance leastconn
@@ -163,6 +164,7 @@ backend backend-cached-site2-local
163 server server_1 127.0.0.1:6081 check inter 2s rise 2 fall 60 maxconn 2048164 server server_1 127.0.0.1:6081 check inter 2s rise 2 fall 60 maxconn 2048
164165
165backend backend-site2-local166backend backend-site2-local
167 option redispatch 1
166 option httpchk GET /check/ HTTP/1.0\r\nHost:\ site2.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache168 option httpchk GET /check/ HTTP/1.0\r\nHost:\ site2.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
167 http-request set-header Host site2.local169 http-request set-header Host site2.local
168 balance leastconn170 balance leastconn
@@ -180,6 +182,7 @@ backend backend-cached-site3-local
180backend backend-site3-local182backend backend-site3-local
181 option forwardfor except 127.0.0.1183 option forwardfor except 127.0.0.1
182 option forceclose184 option forceclose
185 option redispatch 1
183 option httpchk HEAD / HTTP/1.0\r\nHost:\ site3.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache186 option httpchk HEAD / HTTP/1.0\r\nHost:\ site3.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
184 http-request set-header Host site3.local187 http-request set-header Host site3.local
185 balance leastconn188 balance leastconn
@@ -202,12 +205,14 @@ backend backend-cached-site5
202 server server_1 127.0.0.1:6084 check inter 2s rise 2 fall 60 maxconn 2048205 server server_1 127.0.0.1:6084 check inter 2s rise 2 fall 60 maxconn 2048
203206
204backend backend-site5207backend backend-site5
208 option redispatch 1
205 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache209 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
206 http-request set-header Host site5.local210 http-request set-header Host site5.local
207 balance leastconn211 balance leastconn
208 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048212 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048
209213
210backend backend-site5-2214backend backend-site5-2
215 option redispatch 1
211 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache216 option httpchk HEAD / HTTP/1.0\r\nHost:\ site5.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
212 http-request set-header Host site5.local217 http-request set-header Host site5.local
213 balance leastconn218 balance leastconn
@@ -221,6 +226,7 @@ backend backend-cached-site6-local
221 server server_1 127.0.0.1:6085 check inter 2s rise 2 fall 60 maxconn 2048226 server server_1 127.0.0.1:6085 check inter 2s rise 2 fall 60 maxconn 2048
222227
223backend backend-site6-local228backend backend-site6-local
229 option redispatch 1
224 option httpchk HEAD / HTTP/1.0\r\nHost:\ site6.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache230 option httpchk HEAD / HTTP/1.0\r\nHost:\ site6.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
225 http-request set-header Host site6.local231 http-request set-header Host site6.local
226 balance leastconn232 balance leastconn
@@ -234,6 +240,7 @@ backend backend-cached-site7-local
234 server server_1 127.0.0.1:6086 check inter 2s rise 2 fall 60 maxconn 2048240 server server_1 127.0.0.1:6086 check inter 2s rise 2 fall 60 maxconn 2048
235241
236backend backend-site7-local242backend backend-site7-local
243 option redispatch 1
237 option httpchk HEAD / HTTP/1.0\r\nHost:\ site7.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache244 option httpchk HEAD / HTTP/1.0\r\nHost:\ site7.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
238 http-request set-header Host site7.local245 http-request set-header Host site7.local
239 balance leastconn246 balance leastconn
@@ -247,12 +254,14 @@ backend backend-cached-site8-local
247 server server_1 127.0.0.1:6087 check inter 2s rise 2 fall 60 maxconn 2048254 server server_1 127.0.0.1:6087 check inter 2s rise 2 fall 60 maxconn 2048
248255
249backend backend-site8-local256backend backend-site8-local
257 option redispatch 1
250 option httpchk HEAD / HTTP/1.0\r\nHost:\ site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache258 option httpchk HEAD / HTTP/1.0\r\nHost:\ site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
251 http-request set-header Host site8.local259 http-request set-header Host site8.local
252 balance leastconn260 balance leastconn
253 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048261 server server_1 127.0.1.10:80 check inter 5s rise 2 fall 5 maxconn 2048
254262
255backend backend-site8-local-2263backend backend-site8-local-2
264 option redispatch 1
256 option httpchk HEAD / HTTP/1.0\r\nHost:\ auth.site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache265 option httpchk HEAD / HTTP/1.0\r\nHost:\ auth.site8.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
257 http-request set-header Host auth.site8.local266 http-request set-header Host auth.site8.local
258 balance leastconn267 balance leastconn
@@ -266,6 +275,7 @@ backend backend-cached-site9-local
266 server server_1 127.0.0.1:6088 check inter 2s rise 2 fall 60 maxconn 2048275 server server_1 127.0.0.1:6088 check inter 2s rise 2 fall 60 maxconn 2048
267276
268backend backend-site9-local277backend backend-site9-local
278 option redispatch 1
269 option httpchk HEAD / HTTP/1.0\r\nHost:\ site9.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache279 option httpchk HEAD / HTTP/1.0\r\nHost:\ site9.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
270 http-request set-header Host site9.local280 http-request set-header Host site9.local
271 balance leastconn281 balance leastconn
diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output_srv_template.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output_srv_template.txt
index 5391a03..9c3ead5 100644
--- a/tests/unit/files/content_cache_rendered_haproxy_test_output_srv_template.txt
+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output_srv_template.txt
@@ -93,6 +93,7 @@ backend backend-cached-site1-local
93 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 204893 server server_1 127.0.0.1:6080 check inter 2s rise 2 fall 60 maxconn 2048
9494
95backend backend-site1-local95backend backend-site1-local
96 option redispatch 1
96 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache97 option httpchk HEAD / HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk\r\nCache-Control:\ no-cache
97 http-request set-header Host site1.local98 http-request set-header Host site1.local
98 balance leastconn99 balance leastconn
diff --git a/tests/unit/test_content_cache.py b/tests/unit/test_content_cache.py
index 1c11a30..ef464aa 100644
--- a/tests/unit/test_content_cache.py
+++ b/tests/unit/test_content_cache.py
@@ -421,6 +421,8 @@ site1.local:
421 /:421 /:
422 backend-tls: false422 backend-tls: false
423 backends: ['192.168.1.1:8080']423 backends: ['192.168.1.1:8080']
424 backend-options:
425 - retries 3
424 tls-cert-bundle-path: /var/lib/haproxy/certs426 tls-cert-bundle-path: /var/lib/haproxy/certs
425'''427'''
426 self.mock_config.return_value = {'haproxy_hard_stop_after': '15m', 'max_connections': 8192, 'sites': config}428 self.mock_config.return_value = {'haproxy_hard_stop_after': '15m', 'max_connections': 8192, 'sites': config}

Subscribers

People subscribed via source and target branches