From 12020af89545e0701f118f318fa088b8982ceca7 Mon Sep 17 00:00:00 2001 From: Chad Roberts Date: Wed, 16 Aug 2023 13:01:18 -0400 Subject: [PATCH] Give the job pod a chance to come up before tailing the log --- cleanup/ad-guid-unmigration.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cleanup/ad-guid-unmigration.sh b/cleanup/ad-guid-unmigration.sh index 8caa35b1044..39922e7cd46 100755 --- a/cleanup/ad-guid-unmigration.sh +++ b/cleanup/ad-guid-unmigration.sh @@ -229,7 +229,19 @@ fi echo "$yaml" | kubectl apply -f - # Get the pod ID to tail the logs -pod_id=$(kubectl --namespace=cattle-system get pod -l job-name=cattle-cleanup-job -o jsonpath="{.items[0].metadata.name}") +retry_interval=1 +max_retries=10 +retry_count=0 +pod_id="" +while [ $retry_count -lt $max_retries ]; do + pod_id=$(kubectl --namespace=cattle-system get pod -l job-name=cattle-cleanup-job -o jsonpath="{.items[0].metadata.name}") + if [ -n "$pod_id" ]; then + break + else + sleep $retry_interval + ((retry_count++)) + fi +done # 600 is equal to 5 minutes, because the sleep interval is 0.5 seconds job_start_timeout=600