diff --git a/compositions/cloudflare-worker-turbo/jobs/cloudflare-worker-turbo-verify-deploy.yaml b/compositions/cloudflare-worker-turbo/jobs/cloudflare-worker-turbo-verify-deploy.yaml index 9a30ef9..08e7720 100644 --- a/compositions/cloudflare-worker-turbo/jobs/cloudflare-worker-turbo-verify-deploy.yaml +++ b/compositions/cloudflare-worker-turbo/jobs/cloudflare-worker-turbo-verify-deploy.yaml @@ -158,7 +158,25 @@ spec: run: | : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required}" : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required}" - pnpm exec wrangler deploy --config {{ .parameters.wranglerConfig }} --env {{ .orun.environment.name }} + # A first deploy of a brand-new worker can lose a race inside + # Cloudflare: the upload lands and the follow-up read answers + # "This Worker does not exist on your account" (code 10007). The + # deploy is idempotent, so retry it a few times with a short wait + # instead of parking the whole convergence on a resume. + attempts=3 + for i in $(seq 1 "$attempts"); do + if pnpm exec wrangler deploy --config {{ .parameters.wranglerConfig }} --env {{ .orun.environment.name }}; then + [ "$i" -gt 1 ] && echo "deploy passed on attempt $i/$attempts" + exit 0 + fi + if [ "$i" -lt "$attempts" ]; then + wait=$(( i * 10 )) + echo "deploy attempt $i/$attempts failed — retrying in ${wait}s" + sleep "$wait" + fi + done + echo "deploy failed after $attempts attempts" + exit 1 onFailure: stop - id: secrets-live diff --git a/compositions/cloudflare-workers-assets-turbo/jobs/cloudflare-workers-assets-turbo-verify-deploy.yaml b/compositions/cloudflare-workers-assets-turbo/jobs/cloudflare-workers-assets-turbo-verify-deploy.yaml index 1047074..5158722 100644 --- a/compositions/cloudflare-workers-assets-turbo/jobs/cloudflare-workers-assets-turbo-verify-deploy.yaml +++ b/compositions/cloudflare-workers-assets-turbo/jobs/cloudflare-workers-assets-turbo-verify-deploy.yaml @@ -104,9 +104,24 @@ spec: EFFECTIVE_WORKER_NAME="{{ .parameters.workerName }}" {{- end }} - pnpm exec wrangler deploy \ - --config "{{ .parameters.wranglerConfig }}" \ - --name "${EFFECTIVE_WORKER_NAME}" + # Same first-deploy race as cloudflare-worker-turbo (Cloudflare code + # 10007 right after the upload); the deploy is idempotent, so retry. + attempts=3 + for i in $(seq 1 "$attempts"); do + if pnpm exec wrangler deploy \ + --config "{{ .parameters.wranglerConfig }}" \ + --name "${EFFECTIVE_WORKER_NAME}"; then + [ "$i" -gt 1 ] && echo "deploy passed on attempt $i/$attempts" + exit 0 + fi + if [ "$i" -lt "$attempts" ]; then + wait=$(( i * 10 )) + echo "deploy attempt $i/$attempts failed — retrying in ${wait}s" + sleep "$wait" + fi + done + echo "deploy failed after $attempts attempts" + exit 1 onFailure: stop - id: smoke diff --git a/stack.yaml b/stack.yaml index 059120e..1f204fc 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,7 +3,7 @@ kind: Stack metadata: name: stack-tectonic title: Stack Tectonic - version: 0.18.2 + version: 0.19.0 description: Versioned OCI-hosted catalog of Cloudflare, Terraform and monorepo compositions for Sourceplane repositories. owner: sourceplane tags: