From e371578b4ce4ad0770d6632a1002d9ecdd6acb44 Mon Sep 17 00:00:00 2001 From: Alexander Indenbaum Date: Thu, 12 Dec 2024 14:50:19 +0000 Subject: [PATCH] makefile: improve build, retry for Shaman URL Signed-off-by: Alexander Indenbaum --- Makefile | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8afae3e1..0b44bdda 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,28 @@ build: export SPDK_GIT_BRANCH != git -C spdk name-rev --name-only HEAD build: export SPDK_GIT_COMMIT != git rev-parse HEAD:spdk build: export BUILD_DATE != date -u +"%Y-%m-%d %H:%M:%S %Z" build: export NVMEOF_GIT_MODIFIED_FILES != git status -s | grep -e "^ *M" | sed 's/^ *M //' | xargs -build: export CEPH_CLUSTER_CEPH_REPO_BASEURL != curl -s https://shaman.ceph.com/api/repos/ceph/$(CEPH_BRANCH)/$(CEPH_SHA)/centos/9/ | jq -r '.[] | select(.status == "ready" and .archs[] == "$(ceph_repo_arch)") | .url' + +# Variables +SHAMAN_FETCH_ATTEMPTS := 3 + +# Fetch and export CEPH_CLUSTER_CEPH_REPO_BASEURL with retries +build: export CEPH_CLUSTER_CEPH_REPO_BASEURL != \ + for i in $$(seq 1 $(SHAMAN_FETCH_ATTEMPTS)); do \ + >&2 echo "Attempt ($$i): Fetching URL for arch=$(ceph_repo_arch), branch=$(CEPH_BRANCH), sha=$(CEPH_SHA)..."; \ + url=$$(curl -s https://shaman.ceph.com/api/repos/ceph/$(CEPH_BRANCH)/$(CEPH_SHA)/centos/9/ | jq -r '.[] | select(.status == "ready" and .archs[] == "$(ceph_repo_arch)") | .url'); \ + if [ -n "$$url" ]; then \ + >&2 echo "Success: Retrieved URL for arch=$(ceph_repo_arch), branch=$(CEPH_BRANCH), sha=$(CEPH_SHA): $$url"; \ + echo "$$url"; \ + break; \ + fi; \ + >&2 echo "Retrying... Failed attempt ($$i) for arch=$(ceph_repo_arch), branch=$(CEPH_BRANCH), sha=$(CEPH_SHA)"; \ + sleep 2; \ + done; \ + if [ -z "$$url" ]; then \ + >&2 echo "Failure: Unable to retrieve a valid URL for arch=$(ceph_repo_arch), branch=$(CEPH_BRANCH), sha=$(CEPH_SHA) after $(SHAMAN_FETCH_ATTEMPTS) attempts"; \ + exit 1; \ + fi + build: export TARGET_PLATFORM := $(TARGET_PLATFORM) build: export SPDK_TARGET_ARCH := $(SPDK_TARGET_ARCH) build: export SPDK_MAKEFLAGS := $(SPDK_MAKEFLAGS)