Skip to content

Commit

Permalink
fix: include PROXY health check in draining
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmoehl committed Dec 4, 2024
1 parent 266cc14 commit d581be2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jobs/haproxy/templates/drain.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ haproxy_master_pid=$(pgrep -P "$pid" -x haproxy)

<%- if p("ha_proxy.enable_health_check_http") -%>
echo "disable frontend health_check_http_url" | /usr/local/bin/socat stdio unix-connect:${sockfile}
<%- if p("ha_proxy.expect_proxy_cidrs", []).size > 0 -%>
echo "disable frontend health_check_http_url_proxy_protocol" | /usr/local/bin/socat stdio unix-connect:${sockfile}
<%- end -%>
echo "$(date): triggering grace period for process ${haproxy_master_pid}" >> ${logfile}
sleep <%= p("ha_proxy.drain_frontend_grace_time") %>
<%- end -%>
Expand Down
17 changes: 17 additions & 0 deletions spec/haproxy/templates/drain_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@
expect(drain).not_to include('drain is disabled')
expect(drain).to include('socat')
end

context 'when PROXY CIDRs are provided' do
it 'includes the PROXY frontend in drain logic' do
drain = template.render(
{
'ha_proxy' => {
'drain_enable' => true,
'enable_health_check_http' => true,
'expect_proxy_cidrs' => ['10.0.0.0/8']
}
}
)
expect(drain).not_to include('drain is disabled')
expect(drain).to include('socat')
expect(drain).to include('disable frontend health_check_http_url_proxy_protocol')
end
end
end

context 'when a custom ha_proxy.drain_timeout is provided' do
Expand Down

0 comments on commit d581be2

Please sign in to comment.