From 03f065d1bafe2dfef2077db433b426f57fa77a4e Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Wed, 14 Sep 2022 14:32:24 -0600 Subject: [PATCH] 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 (cherry picked from commit 7863d3161c80e96f0370f0908f2ca657394078b9) --- build/crds/build-crds.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build/crds/build-crds.sh b/build/crds/build-crds.sh index ffa9b8ecf..3cc5f3e97 100755 --- a/build/crds/build-crds.sh +++ b/build/crds/build-crds.sh @@ -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" } ########