Skip to content

Commit

Permalink
add circuit breaker
Browse files Browse the repository at this point in the history
  • Loading branch information
jweberst committed Apr 19, 2024
1 parent e893547 commit 122a70e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ inputs:
description: 'Prepare job container images to change in format of (containername:image) using folded block scalar.'
required: false
max_polling_iterations:
description: 'Max amount of iterations (15s increments) to wait for a service update'
description: 'Max amount of iterations (5s increments) to wait for a job update'
required: false
default: '60'
default: '240'
dry_run:
description: 'Whether to skip all Aliyun related write steps.'
required: false
Expand Down
11 changes: 9 additions & 2 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,26 @@ function waitOnJob() {
PARAM_JOB_NAME="$1"
retval_complete=1
retval_failed=1
while [[ $retval_complete -ne 0 ]] && [[ $retval_failed -ne 0 ]]; do
polling_iterations=0
while [[ $retval_complete -ne 0 ]] && [[ $retval_failed -ne 0 ]] && [[ $polling_iterations -lt $INPUT_MAX_POLLING_ITERATIONS ]]; do
sleep 5
output=$(kubectl wait --for=condition=Failed job.batch/$PARAM_JOB_NAME --timeout=0 2>&1)
retval_failed=$?
output=$(kubectl wait --for=condition=Complete job.batch/$PARAM_JOB_NAME --timeout=0 2>&1)
retval_complete=$?
((polling_iterations++))
done

if [ $retval_failed -eq 0 ]; then
echo "::error::Migration Job Failed"
kubectl logs --tail=1000 job.batch/$PARAM_JOB_NAME
exit 1
fi
if [[ $polling_iterations -eq $INPUT_MAX_POLLING_ITERATIONS ]]; then
echo "::error::Max Polling for Job reached, Job Failed"
kubectl logs --tail=1000 job.batch/$PARAM_JOB_NAME
exit 1
fi
}

echo -e "ACK Deploy Action for Aliyun on GitHub Actions.";
Expand All @@ -63,7 +70,7 @@ if [ -n "$INPUT_PREPARE_JOB_CONTAINER_IMAGE_CHANGES" ] && [ -z "$INPUT_PREPARE_T
exit 1;
fi

if [ -z "$INPUT_PREPARE_JOB_NAME" ]; then
if [ -n "$INPUT_PREPARE_JOB_CONTAINER_IMAGE_CHANGES" ] && [ -z "$INPUT_PREPARE_JOB_NAME" ]; then
echo "::error::Prepare container image changes was passed, but no Prepare Task Job Name. Ending job."
exit 1;
fi
Expand Down

0 comments on commit 122a70e

Please sign in to comment.