From 14febda1e39e62b82dcdf7291cb8ff3baaa1db58 Mon Sep 17 00:00:00 2001 From: Chris Wedgwood Date: Tue, 23 Jun 2020 13:26:37 -0500 Subject: [PATCH] [haproxy] anchor; make sure configuration is flushed before rename The pattern: create, write, close, rename is *not* robust in many circumstances. The data blocks from the write are not always flushed/persisted before the rename (metadata) changes meaning you can end up where the replacement file is corrupted (usually has 0 bytes at the end). Change-Id: Icdd2bb6f20330e5e94b3081f0d0b8a74417f60d4 --- charts/haproxy/templates/bin/_anchor.tpl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charts/haproxy/templates/bin/_anchor.tpl b/charts/haproxy/templates/bin/_anchor.tpl index f8457e62..74686dbe 100644 --- a/charts/haproxy/templates/bin/_anchor.tpl +++ b/charts/haproxy/templates/bin/_anchor.tpl @@ -134,6 +134,8 @@ install_config() { echo Replacing HAProxy config file "$HAPROXY_CONF" with: cat "$NEXT_HAPROXY_CONF" echo + # ensure data blocks are flushed before rename + sync mv "$NEXT_HAPROXY_CONF" "$HAPROXY_CONF" else echo "New config failed validation, refusing to replace."