Skip to content

Commit 57df31e

Browse files
maxmoehlpeanball
authored andcommitted
fix: include PROXY health check in draining
1 parent 266cc14 commit 57df31e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

jobs/haproxy/templates/drain.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ haproxy_master_pid=$(pgrep -P "$pid" -x haproxy)
4646

4747
<%- if p("ha_proxy.enable_health_check_http") -%>
4848
echo "disable frontend health_check_http_url" | /usr/local/bin/socat stdio unix-connect:${sockfile}
49+
<%- if p("ha_proxy.expect_proxy_cidrs", []).size > 0 -%>
50+
echo "disable frontend health_check_http_url_proxy_protocol" | /usr/local/bin/socat stdio unix-connect:${sockfile}
51+
<%- end -%>
4952
echo "$(date): triggering grace period for process ${haproxy_master_pid}" >> ${logfile}
5053
sleep <%= p("ha_proxy.drain_frontend_grace_time") %>
5154
<%- end -%>

spec/haproxy/templates/drain_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@
3131
expect(drain).not_to include('drain is disabled')
3232
expect(drain).to include('socat')
3333
end
34+
35+
context 'when PROXY CIDRs are provided' do
36+
it 'includes the PROXY frontend in drain logic' do
37+
drain = template.render(
38+
{
39+
'ha_proxy' => {
40+
'drain_enable' => true,
41+
'enable_health_check_http' => true,
42+
'expect_proxy_cidrs' => ['10.0.0.0/8']
43+
}
44+
}
45+
)
46+
expect(drain).not_to include('drain is disabled')
47+
expect(drain).to include('socat')
48+
expect(drain).to include('disable frontend health_check_http_url_proxy_protocol')
49+
end
50+
end
3451
end
3552

3653
context 'when a custom ha_proxy.drain_timeout is provided' do

0 commit comments

Comments
 (0)