Skip to content

Commit

Permalink
fixed bad logic with TREAT_ERRORS_AS_READY var
Browse files Browse the repository at this point in the history
  • Loading branch information
groundnuty committed Sep 3, 2021
1 parent 30e860b commit 1c9c1a6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions wait_for.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,18 @@ 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
# - some pods are failed, but no pod is completed yet - then emit 1
# - 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
Expand Down

0 comments on commit 1c9c1a6

Please sign in to comment.