build: fix intermittent gen-rbac failure

The crds generation for the helm crds is intermittently hitting a build
error due to multiple builds generating the crds at the same time.
We avoid this race condition by first writing the crds to a temp file
then move the file to the helm crd resources file.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
(cherry picked from commit 7863d3161c)
This commit is contained in:
Travis Nielsen authored and Mergify committed 2022-09-15 16:14:15 +00:00
1 parent 370565ffa0
commit 03f065d1ba
1 file changed
+5 -2
+5 -2
View File
@@ -71,7 +71,8 @@ EOF
}
build_helm_resources() {
echo "Generating helm resources.yaml"
TMP_FILE=$(mktemp -q /tmp/resources.XXXXXX || exit 1)
echo "Generating helm resources.yaml to temp file: $TMP_FILE"
{
# add header
echo "{{- if .Values.crds.enabled }}"
@@ -83,7 +84,9 @@ build_helm_resources() {
# DO NOT REMOVE the empty line, it is necessary
echo ""
echo "{{- end }}"
} >>"$CEPH_HELM_CRDS_FILE_PATH"
} >>"$TMP_FILE"
echo "updating helm crds file $CEPH_HELM_CRDS_FILE_PATH from temp file"
mv "$TMP_FILE" "$CEPH_HELM_CRDS_FILE_PATH"
}
########