From 2d5a674574606b1bdcf005f793cb458ef35cf2ee Mon Sep 17 00:00:00 2001 From: jcullina Date: Fri, 24 Jan 2025 11:43:17 +0000 Subject: [PATCH] add wait condition for port-for Signed-off-by: jcullina --- .tekton/rapidast-scan.yaml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.tekton/rapidast-scan.yaml b/.tekton/rapidast-scan.yaml index e19e28bc..53f712f4 100644 --- a/.tekton/rapidast-scan.yaml +++ b/.tekton/rapidast-scan.yaml @@ -128,8 +128,16 @@ spec: cat <<< "$KUBECONFIG_VALUE" > /tmp/cfg export KUBECONFIG=/tmp/cfg + timeout 5m bash -c 'while ! curl -k https://:8083/healthcheck; do sleep 5; done' + echo "Starting port-forward for service/trex on port 8000..." - oc port-forward --address=0.0.0.0 --kubeconfig /tmp/cfg svc/trex 8000:8000 + oc port-forward --address=0.0.0.0 --kubeconfig /tmp/cfg svc/trex 8000:8000 + + # Wait until port-forward is active + timeout 5m bash -c 'until echo > /dev/tcp/127.0.0.1/8000; do sleep 2s; done' || { + echo "[ERROR] Port-forward is not ready. Exiting." + exit 1 + } steps: - name: get-url image: registry.redhat.io/openshift4/ose-cli:latest @@ -149,18 +157,16 @@ spec: exit 1 } - BASE_URL="http://127.0.0.1:8000" + BASE_URL="https://127.0.0.1:8000" CONFIG_PATH="/workspace/config.yaml" wget -O /tmp/ocm https://github.com/openshift-online/ocm-cli/releases/download/v1.0.3/ocm-linux-amd64 chmod +x /tmp/ocm export PATH=$PATH:/tmp - dnf install -y jq - /tmp/ocm login --token=${OCM_TOKEN} --url=${BASE_URL} - AUTH_RESPONSE=$(/tmp/ocm get /api/rh-trex/v1/dinosaurs) + AUTH_RESPONSE=$(/tmp/ocm get /api/rh-trex/v1/dinosaurs -k) # Print the response to the logs echo "${AUTH_RESPONSE}" | jq '.items[]' || echo "No dinosaurs found or failed to parse the response."