Skip to content

Commit

Permalink
fix: Fixed broken retry support by replacing with a simple approach
Browse files Browse the repository at this point in the history
Signed-off-by: Saptarshi Sarkar <[email protected]>
  • Loading branch information
SaptarshiSarkar12 committed Oct 18, 2024
1 parent 4bd7bd3 commit 95afc53
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ timeout=$4
connection_format=$5
format=$6
output_file=$7
retry_on_timeout=$8
max_retries=$9
max_retries=$8

# parse image into image name
image_no_tag=$(echo "$image" | cut -d':' -f1)
Expand Down Expand Up @@ -42,32 +41,34 @@ case "$connection_format" in
esac

# run copa to patch image
OUTPUT_MESSAGE=$(copa patch -i "$image" -r ./data/"$report" -t "$patched_tag" $connection --timeout $timeout $output)
if [ $? -eq 0 ]
if [ "$max_retries" -eq 0 ]
then
patched_image="$image_no_tag:$patched_tag"
echo "patched-image=$patched_image" >> "$GITHUB_OUTPUT"
elif echo "$OUTPUT_MESSAGE" | grep -q "exceeded timeout"
then
if [ "$retry_on_timeout" = "false" ]
if copa patch -i "$image" -r ./data/"$report" -t "$patched_tag" "$connection" --timeout "$timeout" "$output"
then
patched_image="$image_no_tag:$patched_tag"
echo "patched-image=$patched_image" >> "$GITHUB_OUTPUT"
else
echo "Error patching image $image with copa"
exit 1
else
retries=0
while [ $retries -lt $max_retries ]
do
if copa patch -i "$image" -r ./data/"$report" -t "$patched_tag" $connection --timeout $timeout $output;
fi
else
retries=0
while [ "$retries" -lt "$max_retries" ]
do
if copa patch -i "$image" -r "./data/$report" -t "$patched_tag" "$connection" --timeout "$timeout" "$output"
then
patched_image="$image_no_tag:$patched_tag"
echo "patched-image=$patched_image" >> "$GITHUB_OUTPUT"
break
else
retries=$((retries+1))
if [ "$retries" -eq "$max_retries" ]
then
patched_image="$image_no_tag:$patched_tag"
echo "patched-image=$patched_image" >> "$GITHUB_OUTPUT"
break
echo "Error patching image $image with copa"
exit 1
else
retries=$((retries + 1))
echo "WARNING: Attempt $retries failed. Retrying..."
fi
done
fi
else
echo "Error patching image $image with copa"
exit 1
fi
fi
done
fi

0 comments on commit 95afc53

Please sign in to comment.