Skip to content

Commit aed5d99

Browse files
Merge pull request #558 from hjensas/OSPRH-17012
Fix race condition - envsubst $file | tee $file
2 parents 4d0ee77 + b403426 commit aed5d99

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

templates/ironicinspector/bin/inspector-pxe-init.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,19 @@ sed -e "/BLOCK_PODINDEX_${PODINDEX}_BEGIN/,/BLOCK_PODINDEX_${PODINDEX}_END/p" \
3333
sed -e "/BLOCK_PODINDEX_${PODINDEX}_BEGIN/d" \
3434
-e "/BLOCK_PODINDEX_${PODINDEX}_END/d" \
3535
-i ${DNSMASQ_CFG}
36-
envsubst < ${DNSMASQ_CFG} | tee ${DNSMASQ_CFG}
36+
37+
# OSPCIX-870: Copy the config to tempdir to avoid race condition where pipe to
38+
# tee may wipe the file.
39+
export TMP_DNSMASQ_CFG=/var/tmp/dnsmasq.conf
40+
cp ${DNSMASQ_CFG} ${TMP_DNSMASQ_CFG}
41+
envsubst < ${TMP_DNSMASQ_CFG} | tee ${DNSMASQ_CFG}
3742

3843
export INSPECTOR_IPXE=/var/lib/ironic/inspector.ipxe
39-
envsubst < ${INSPECTOR_IPXE} | tee ${INSPECTOR_IPXE}
44+
# OSPCIX-870: Copy the config to tempdir to avoid race condition where pipe to
45+
# tee may wipe the file.
46+
export TMP_INSPECTOR_IPXE=/var/tmp/inspector.ipxe
47+
cp ${INSPECTOR_IPXE} ${TMP_INSPECTOR_IPXE}
48+
envsubst < ${TMP_INSPECTOR_IPXE} | tee ${INSPECTOR_IPXE}
4049

4150
# run common pxe-init script
4251
/usr/local/bin/container-scripts/pxe-init.sh

0 commit comments

Comments
 (0)