From 24bf99f31cf6e1111e0789ca8f91daa3d0f1d5b7 Mon Sep 17 00:00:00 2001 From: Blaine Gardner Date: Wed, 29 Sep 2021 17:17:51 -0600 Subject: [PATCH] build: use intermediate tmp for offline image gen Reading from a file, processing the file in a pipe, and outputting the piped content to the same file can have undefined results, often leading to an empty file. Use an intermediate temp file for generating the offline image list. Signed-off-by: Blaine Gardner --- .github/workflows/build.yml | 4 ++++ images/ceph/Makefile | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a42af3c6..13a568b79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,6 +28,10 @@ jobs: run: | GOPATH=$(go env GOPATH) make clean && make -j$nproc IMAGES='ceph' BUILD_CONTAINER_IMAGE=false build + - name: validate build + working-directory: /Users/runner/go/src/github.com/rook/rook + run: tests/scripts/validate_modified_files.sh build + - name: run codegen working-directory: /Users/runner/go/src/github.com/rook/rook run: GOPATH=$(go env GOPATH) make codegen diff --git a/images/ceph/Makefile b/images/ceph/Makefile index 7de4a98e7..ae0784dfc 100755 --- a/images/ceph/Makefile +++ b/images/ceph/Makefile @@ -124,15 +124,15 @@ csv: $(OPERATOR_SDK) $(YQ) ## Generate a CSV file for OLM. csv-clean: $(OPERATOR_SDK) $(YQ) ## Remove existing OLM files. @rm -fr ../../cluster/olm/ceph/deploy/* ../../cluster/olm/ceph/templates/* -# list-image creates list of images for offline installation -list-image: - @echo "producing list of images for offline installation";\ - # remove the file if already exists - rm -f $(MANIFESTS_DIR)/images.txt;\ +# reading from a file and outputting to the same file can have undefined results, so use this intermediate +IMAGE_TMP="/tmp/rook-ceph-image-list" +list-image: ## Create a list of images for offline installation + @echo "producing list of images for offline installation" + rm -f $(IMAGE_TMP) awk '/image:/ {print $2}' $(MANIFESTS_DIR)/operator.yaml $(MANIFESTS_DIR)/cluster.yaml | \ - cut -d: -f2- |\ - tee $(MANIFESTS_DIR)/images.txt; \ + cut -d: -f2- | tee $(IMAGE_TMP) awk '/quay.io/ || /k8s.gcr.io/ {print $3}' ../../pkg/operator/ceph/csi/spec.go | \ - cut -d= -f2- |\ - tr -d '"' | tee -a $(MANIFESTS_DIR)/images.txt;\ - cat $(MANIFESTS_DIR)/images.txt|sort -h|uniq|tee $(MANIFESTS_DIR)/images.txt + cut -d= -f2- | tr -d '"' | tee -a $(IMAGE_TMP) + rm -f $(MANIFESTS_DIR)/images.txt + cat $(IMAGE_TMP) | sort -h | uniq | tee $(MANIFESTS_DIR)/images.txt + rm -f $(IMAGE_TMP)