Skip to content

Commit bc282c4

Browse files
committed
fix: allow HAProxy to start with unresolved inactive backend
1 parent f0b6a18 commit bc282c4

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

deploy/ansible/roles/app/templates/haproxy.cfg.j2

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,20 @@ frontend https_in
6565
backend global_rate_tracking
6666
stick-table type string len 6 size 1 expire 10m store http_req_rate(1s)
6767

68+
resolvers docker_dns
69+
nameserver dns1 127.0.0.11:53
70+
resolve_retries 3
71+
timeout resolve 1s
72+
timeout retry 1s
73+
hold valid 10s
74+
hold nx 5s
75+
6876
backend app
6977
balance roundrobin
7078
option httpchk GET /health
7179
http-check expect status 200
7280

7381
# Blue-green backends: only the active color is enabled
74-
server blue app-blue:3000 check inter 2s fall 3 rise 2 {{ 'disabled' if active_color == 'green' else '' }}
75-
server green app-green:3000 check inter 2s fall 3 rise 2 {{ 'disabled' if active_color == 'blue' else '' }}
82+
# init-addr none allows HAProxy to start when the inactive container does not exist
83+
server blue app-blue:3000 resolvers docker_dns check inter 2s fall 3 rise 2 init-addr none {{ 'disabled' if active_color == 'green' else '' }}
84+
server green app-green:3000 resolvers docker_dns check inter 2s fall 3 rise 2 init-addr none {{ 'disabled' if active_color == 'blue' else '' }}

0 commit comments

Comments
 (0)