From 733f26b971fdca0ad233ef4c2d53b15fb6d161b7 Mon Sep 17 00:00:00 2001 From: chrischristiansen-glitch Date: Wed, 10 Jun 2026 11:22:56 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20smoke-test=20henter=20fersk=20token=20pe?= =?UTF-8?q?r=20fors=C3=B8k,=20robustere=20health-poll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cloudbuild.yaml | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index b8ed39d..15fba5b 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -68,14 +68,19 @@ steps: echo "=== Smoke Test ===" BASE_URL="https://${_CLOUD_RUN_URL}" - TOKEN=$$(gcloud auth print-identity-token \ - --impersonate-service-account=${_AGENT_SA} \ - --audiences="$$BASE_URL") \ - || { echo "❌ Kunne ikke hente identity token"; exit 1; } - - # Vent på at Cloud Run-instansen er klar (cold start kan ta opptil 60s) + # Vent på at Cloud Run-instansen er klar (cold start kan ta opptil 90s) + # Henter fersk token per forsøk siden token kan utløpe under lang cold start echo "Venter på /health ..." - for i in $$(seq 1 12); do + STATUS="000" + for i in $$(seq 1 18); do + TOKEN=$$(gcloud auth print-identity-token \ + --impersonate-service-account=${_AGENT_SA} \ + --audiences="$$BASE_URL" 2>/dev/null) + if [ -z "$$TOKEN" ]; then + echo " /health forsøk $$i: kunne ikke hente token, venter..." + sleep 10 + continue + fi STATUS=$$(curl -s -o /dev/null -w "%{http_code}" \ -H "Authorization: Bearer $$TOKEN" \ "$$BASE_URL/health") @@ -85,11 +90,14 @@ steps: done if [ "$$STATUS" != "200" ]; then - echo "❌ /health svarte ikke 200 etter 120s (siste: $$STATUS)" + echo "❌ /health svarte ikke 200 etter 180s (siste: $$STATUS)" exit 1 fi - # Kjør /run + # Kjør /run med fersk token + TOKEN=$$(gcloud auth print-identity-token \ + --impersonate-service-account=${_AGENT_SA} \ + --audiences="$$BASE_URL") RESPONSE=$$(curl -s -w "\nHTTP_STATUS:%{http_code}" \ -H "Authorization: Bearer $$TOKEN" \ -H "Content-Type: application/json" \