From 1a8f4e034d3a96cb4e0f0535ada211d51d812bea Mon Sep 17 00:00:00 2001 From: Christian Sunesson <52162652+chsukivra@users.noreply.github.com> Date: Thu, 23 May 2024 21:38:19 +0200 Subject: [PATCH 1/2] fix: Write os-var replaced .src file to temp file, and rename The replace_os_vars function is called for any command, not only those that boot the release. If you invoke status in a readiness check, that will write the file again. This might lead to race conditions, where the release starts up, but the health check will re-render the sys.config and write it halfway while the boot gets around to read it. --- priv/templates/extended_bin | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index 39652373b..e5896b69a 100644 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -445,6 +445,7 @@ make_out_file_path() { # Replace environment variables replace_os_vars() { + TEMP_OUT=$(mktemp "$2".XXXXX) awk '{ while(match($0,"[$]{[^}]*}")) { var=substr($0,RSTART+2,RLENGTH -3) @@ -460,7 +461,8 @@ replace_os_vars() { gsub("[$]{"var"}",e) } } - }1' < "$1" > "$2" + }1' < "$1" >> "$TEMP_OUT" + mv "$TEMP_OUT" "$2" } add_path() { From be1fd379143aaa325ed58e4c2a9b1a812e3c18f7 Mon Sep 17 00:00:00 2001 From: Christian Sunesson <52162652+chsukivra@users.noreply.github.com> Date: Thu, 23 May 2024 21:54:48 +0200 Subject: [PATCH 2/2] fix: use pattern with 6 X, busybox mktemp (alpine) requires it --- priv/templates/extended_bin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index e5896b69a..0f52eed70 100644 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -445,7 +445,7 @@ make_out_file_path() { # Replace environment variables replace_os_vars() { - TEMP_OUT=$(mktemp "$2".XXXXX) + TEMP_OUT=$(mktemp "$2".XXXXXX) awk '{ while(match($0,"[$]{[^}]*}")) { var=substr($0,RSTART+2,RLENGTH -3)