fix(kestra-init): add API readiness wait loop before importing flows
All checks were successful
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 36s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 1m11s
Build and Push Docker Images / Build Integrator (push) Successful in 58s
Build and Push Docker Images / Build Kestra Init (push) Successful in 32s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 1s
All checks were successful
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 36s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 1m11s
Build and Push Docker Images / Build Integrator (push) Successful in 58s
Build and Push Docker Images / Build Kestra Init (push) Successful in 32s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 1s
Waits up to 120s for /api/v1/flows/search to respond before attempting imports, giving a clearer error if the URL is wrong or kestra isn't up. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,8 +2,21 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
KESTRA_URL="${KESTRA_URL:-http://kestra:8080}"
|
KESTRA_URL="${KESTRA_URL:-http://kestra:8080}"
|
||||||
|
MAX_WAIT=120
|
||||||
|
|
||||||
echo "Importing flows into Kestra at ${KESTRA_URL}..."
|
echo "Waiting for Kestra API at ${KESTRA_URL}..."
|
||||||
|
elapsed=0
|
||||||
|
until curl -sf "${KESTRA_URL}/api/v1/flows/search" > /dev/null 2>&1; do
|
||||||
|
if [ "$elapsed" -ge "$MAX_WAIT" ]; then
|
||||||
|
echo "ERROR: Kestra API not reachable after ${MAX_WAIT}s"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 5
|
||||||
|
elapsed=$((elapsed + 5))
|
||||||
|
done
|
||||||
|
echo "Kestra API is ready."
|
||||||
|
|
||||||
|
echo "Importing flows..."
|
||||||
|
|
||||||
for f in /flows/*.yml; do
|
for f in /flows/*.yml; do
|
||||||
name="$(basename "$f")"
|
name="$(basename "$f")"
|
||||||
@@ -17,7 +30,6 @@ for f in /flows/*.yml; do
|
|||||||
if [ "$http_code" = "200" ] || [ "$http_code" = "201" ]; then
|
if [ "$http_code" = "200" ] || [ "$http_code" = "201" ]; then
|
||||||
echo " created"
|
echo " created"
|
||||||
elif [ "$http_code" = "409" ]; then
|
elif [ "$http_code" = "409" ]; then
|
||||||
# Flow already exists — update it via PUT /api/v1/flows/{namespace}/{id}
|
|
||||||
ns=$(grep '^namespace:' "$f" | awk '{print $2}')
|
ns=$(grep '^namespace:' "$f" | awk '{print $2}')
|
||||||
id=$(grep '^id:' "$f" | awk '{print $2}')
|
id=$(grep '^id:' "$f" | awk '{print $2}')
|
||||||
http_code2=$(curl -s -o /tmp/kestra_resp -w "%{http_code}" \
|
http_code2=$(curl -s -o /tmp/kestra_resp -w "%{http_code}" \
|
||||||
|
|||||||
Reference in New Issue
Block a user