Skip to content

Commit fb66193

Browse files
committed
fix(deploy): replace SIGHUP reload with container recreate to fix bind mount staleness
Docker file-level bind mounts track inodes, not paths. Ansible template writes create new inodes, leaving the container reading orphaned files. Replacing SIGHUP with force-recreate ensures fresh mounts every time, eliminating the admin socket dependency entirely.
1 parent bd71dae commit fb66193

3 files changed

Lines changed: 5 additions & 40 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
- name: Reload haproxy
33
ansible.builtin.shell: |
4-
docker kill -s HUP rustyip-haproxy
4+
docker compose -f /opt/rustyip/docker-compose.yml up -d --force-recreate haproxy
55
failed_when: false

deploy/ansible/roles/app/tasks/main.yml

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@
136136
owner: root
137137
group: root
138138
mode: "0644"
139-
unsafe_writes: yes
140139
vars:
141140
active_color: "{{ deploy_target }}"
142141
when: is_first_deploy
@@ -210,28 +209,12 @@
210209
owner: root
211210
group: root
212211
mode: "0644"
213-
unsafe_writes: yes
214212
vars:
215213
active_color: "{{ deploy_target }}"
216214

217-
- name: Reload HAProxy in-place to switch traffic
215+
- name: Recreate HAProxy container to switch traffic
218216
ansible.builtin.shell: |
219-
docker kill -s HUP rustyip-haproxy
220-
changed_when: true
221-
222-
- name: Force new backend out of maintenance via admin socket
223-
ansible.builtin.shell: |
224-
for i in $(seq 1 10); do
225-
if docker exec rustyip-haproxy sh -c \
226-
'echo "set server app/{{ deploy_target }} state ready" | socat stdio unix:/tmp/admin.sock' 2>/dev/null; then
227-
echo "admin socket command succeeded on attempt $i"
228-
exit 0
229-
fi
230-
echo "attempt $i: admin socket not ready, retrying in 1s..."
231-
sleep 1
232-
done
233-
echo "admin socket unavailable after 10 attempts"
234-
exit 1
217+
docker compose -f /opt/rustyip/docker-compose.yml up -d --force-recreate haproxy
235218
changed_when: true
236219

237220
- name: Wait for new backend to be UP in HAProxy
@@ -282,29 +265,12 @@
282265
owner: root
283266
group: root
284267
mode: "0644"
285-
unsafe_writes: yes
286268
vars:
287269
active_color: "{{ current_active }}"
288270

289-
- name: Reload HAProxy to restore original backend
271+
- name: Recreate HAProxy container to restore original backend
290272
ansible.builtin.shell: |
291-
docker kill -s HUP rustyip-haproxy
292-
changed_when: true
293-
failed_when: false
294-
295-
- name: Force original backend out of maintenance via admin socket
296-
ansible.builtin.shell: |
297-
for i in $(seq 1 10); do
298-
if docker exec rustyip-haproxy sh -c \
299-
'echo "set server app/{{ current_active }} state ready" | socat stdio unix:/tmp/admin.sock' 2>/dev/null; then
300-
echo "admin socket command succeeded on attempt $i"
301-
exit 0
302-
fi
303-
echo "attempt $i: admin socket not ready, retrying in 1s..."
304-
sleep 1
305-
done
306-
echo "admin socket unavailable after 10 attempts"
307-
exit 1
273+
docker compose -f /opt/rustyip/docker-compose.yml up -d --force-recreate haproxy
308274
changed_when: true
309275
failed_when: false
310276

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
global
22
log stderr local0 err
33
maxconn 10000
4-
stats socket /tmp/admin.sock mode 660 level admin expose-fd listeners
54
# Performance tuning for high-throughput
65
tune.bufsize 16384
76
tune.maxrewrite 1024

0 commit comments

Comments
 (0)