From 1c9c1a6cc4e2ba9e131863a86a1cd729a2c31ad8 Mon Sep 17 00:00:00 2001 From: groundnuty Date: Fri, 3 Sep 2021 16:43:42 +0200 Subject: [PATCH] fixed bad logic with TREAT_ERRORS_AS_READY var --- wait_for.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/wait_for.sh b/wait_for.sh index c266fe8..acd49a9 100755 --- a/wait_for.sh +++ b/wait_for.sh @@ -173,6 +173,11 @@ get_job_state() { # - pods are distributed between all 3 states with at least 1 pod running - then emit 1 # - or more then 1 pod have failed and some are completed - also emit 1 sed_reg='-e s/^[1-9][[:digit:]]*:[[:digit:]]+:[[:digit:]]+$/1/p -e s/^0:[[:digit:]]+:[1-9][[:digit:]]*$/1/p' + elif [ $TREAT_ERRORS_AS_READY -eq 1 ]; then + # When allowing for failed jobs + # - pods are distributed between all 3 states with at least 1 pod running- then emit 1 + # - all other options include all pods Completed or Failed - which are fine + sed_reg='-e s/^[1-9][[:digit:]]*:[[:digit:]]+:[[:digit:]]+$/1/p' elif [ $TREAT_ERRORS_AS_READY -eq 2 ]; then # When allowing for failed jobs but at least one pod have to Succeed # - pods are distributed between all 3 states with at least 1 pod running- then emit 1 @@ -180,12 +185,6 @@ get_job_state() { # - when no pod is running and at least one is completed - all is fine sed_reg='-e s/^[1-9][[:digit:]]*:[[:digit:]]+:[[:digit:]]+$/1/p -e s/^0:0:[[:digit:]]+$/1/p' fi - else - # When allowing for failed jobs - # - pods are distributed between all 3 states with at least 1 pod running- then emit 1 - # - all other options include all pods Completed or Failed - which are fine - sed_reg='-e s/^[1-9][[:digit:]]*:[[:digit:]]+:[[:digit:]]+$/1/p' - fi get_job_state_output2=$(printf "%s" "$get_job_state_output1" | sed -nr $sed_reg 2>&1) if [ $DEBUG -ge 1 ]; then