Add support for image key/sig retries

This commit is contained in:
Jason Ertel
2021-01-29 11:18:06 -05:00
parent 194f480017
commit c055427e40
3 changed files with 16 additions and 9 deletions

View File

@@ -228,23 +228,23 @@ retry() {
attempt=0
while [[ $attempt -lt $maxAttempts ]]; do
attempt=$((attempt+1))
info "Executing command with retry support: $cmd"
echo "Executing command with retry support: $cmd"
output=$($cmd)
info "Results: $output"
exitcode=$?
echo "Results: $output ($exitcode)"
if [ -n "$expectedOutput" ]; then
if [[ "$output" =~ "$expectedOutput" ]]; then
return $exitCode
else
info "Expected '$expectedOutput' but got '$output'"
echo "Expected '$expectedOutput' but got '$output'"
fi
elif [[ $exitcode -eq 0 ]]; then
return $exitCode
fi
info "Command failed with exit code $exitcode; will retry in $sleepDelay seconds ($attempt / $maxAttempts)..."
echo "Command failed with exit code $exitcode; will retry in $sleepDelay seconds ($attempt / $maxAttempts)..."
sleep $sleepDelay
done
error "Command continues to fail; giving up."
echo "Command continues to fail; giving up."
return 1
}