Skip to content

Commit be8293f

Browse files
committed
Randomise temporary file name used in provisioner script
To avoid potential conflicts when multiple instances run simultaneously, the temporary file created in the provisioner script is now assigned a random name using the mktemp command. This ensures that each instance operates with its own unique temporary file, preventing any overlap or interference between them. Signed-off-by: darox <maderdario@gmail.com>
1 parent 9e6129e commit be8293f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

scripts/provisioner.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ fi
113113
helm repo update
114114

115115
# Substitute environment variables into the Cilium Helm values file.
116-
envsubst < "${CILIUM_HELM_VALUES_FILE}" > tmp1
116+
CILIUM_VALUES_TMP_FILE=$(mktemp)
117+
envsubst < "${CILIUM_HELM_VALUES_FILE}" > "${CILIUM_VALUES_TMP_FILE}"
117118
# Just try to wait a bit to avoid this https://github.com/isovalent/terraform-k8s-cilium/issues/42 issue. If the file is still not available in 5 seconds, we will let helm install to throw out the error.
118119
sleep 5
119120

@@ -122,13 +123,13 @@ then
122123
# Substitute environment variables into the Cilium Helm values override file.
123124
envsubst < "${CILIUM_HELM_VALUES_OVERRIDE_FILE}" | \
124125
helm upgrade --install "${CILIUM_HELM_RELEASE_NAME}" "${CILIUM_HELM_CHART}" \
125-
--version "${CILIUM_HELM_VERSION}" -n "${CILIUM_NAMESPACE}" -f tmp1 -f /dev/stdin ${CILIUM_HELM_EXTRA_ARGS}
126-
rm -f tmp1
126+
--version "${CILIUM_HELM_VERSION}" -n "${CILIUM_NAMESPACE}" -f "${CILIUM_VALUES_TMP_FILE}" -f /dev/stdin ${CILIUM_HELM_EXTRA_ARGS}
127+
rm -f "${CILIUM_VALUES_TMP_FILE}"
127128
else
128-
envsubst < tmp1 | \
129+
envsubst < "${CILIUM_VALUES_TMP_FILE}" | \
129130
helm upgrade --install "${CILIUM_HELM_RELEASE_NAME}" "${CILIUM_HELM_CHART}" \
130131
--version "${CILIUM_HELM_VERSION}" -n "${CILIUM_NAMESPACE}" -f /dev/stdin ${CILIUM_HELM_EXTRA_ARGS}
131-
rm -f tmp1
132+
rm -f "${CILIUM_VALUES_TMP_FILE}"
132133
fi
133134

134135

0 commit comments

Comments
 (0)