From ccd79ff137815e179ff57b8985ec25a718abdea4 Mon Sep 17 00:00:00 2001 From: Ryan O'Meara Date: Wed, 10 Nov 2021 23:15:31 -0500 Subject: [PATCH 1/3] Add basic retry mechanism to sig-repo jar download --- src/main/resources/detect-sh.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/detect-sh.sh b/src/main/resources/detect-sh.sh index da14287..606da01 100644 --- a/src/main/resources/detect-sh.sh +++ b/src/main/resources/detect-sh.sh @@ -156,7 +156,7 @@ get_detect() { if [ ${USE_REMOTE} -eq 1 ]; then echo "getting ${DETECT_SOURCE} from remote" TEMP_DETECT_DESTINATION="${DETECT_DESTINATION}-temp" - curlReturn=$(curl ${DETECT_CURL_OPTS} --silent -w "%{http_code}" -L -o "${TEMP_DETECT_DESTINATION}" --create-dirs "${DETECT_SOURCE}") + curlReturn=$(curl ${DETECT_CURL_OPTS} --retry --silent -w "%{http_code}" -L -o "${TEMP_DETECT_DESTINATION}" --create-dirs "${DETECT_SOURCE}") if [[ 200 -eq ${curlReturn} ]]; then mv "${TEMP_DETECT_DESTINATION}" "${DETECT_DESTINATION}" if [[ -f ${LOCAL_FILE} ]]; then From f97844fa55146ad8e7c2306fdbda53e4baa2c221 Mon Sep 17 00:00:00 2001 From: Ryan O'Meara Date: Thu, 11 Nov 2021 09:34:25 -0500 Subject: [PATCH 2/3] Add retry quantity to command --- src/main/resources/detect-sh.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/detect-sh.sh b/src/main/resources/detect-sh.sh index 606da01..f4ce9b7 100644 --- a/src/main/resources/detect-sh.sh +++ b/src/main/resources/detect-sh.sh @@ -156,7 +156,7 @@ get_detect() { if [ ${USE_REMOTE} -eq 1 ]; then echo "getting ${DETECT_SOURCE} from remote" TEMP_DETECT_DESTINATION="${DETECT_DESTINATION}-temp" - curlReturn=$(curl ${DETECT_CURL_OPTS} --retry --silent -w "%{http_code}" -L -o "${TEMP_DETECT_DESTINATION}" --create-dirs "${DETECT_SOURCE}") + curlReturn=$(curl ${DETECT_CURL_OPTS} --retry 3 --silent -w "%{http_code}" -L -o "${TEMP_DETECT_DESTINATION}" --create-dirs "${DETECT_SOURCE}") if [[ 200 -eq ${curlReturn} ]]; then mv "${TEMP_DETECT_DESTINATION}" "${DETECT_DESTINATION}" if [[ -f ${LOCAL_FILE} ]]; then From 7b0bb3d0562dbbf194fbbf83fd48e4881b514cb4 Mon Sep 17 00:00:00 2001 From: Ryan O'Meara Date: Fri, 12 Nov 2021 13:27:15 -0500 Subject: [PATCH 3/3] Contain retry opts in env var, add default timing Make it possible to override/disable retry behavior easily via environment variable, and add default backoff and maximum time values --- src/main/resources/detect-sh.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/resources/detect-sh.sh b/src/main/resources/detect-sh.sh index f4ce9b7..6d29439 100644 --- a/src/main/resources/detect-sh.sh +++ b/src/main/resources/detect-sh.sh @@ -61,6 +61,11 @@ DETECT_JAVA_PATH=${DETECT_JAVA_PATH:-} # heap size, you would set DETECT_JAVA_OPTS=-Xmx6G. DETECT_JAVA_OPTS=${DETECT_JAVA_OPTS:-} +# If you want to configure different curl-based retry behavior, +# specify DETECT_CURL_RETRY_OPTS in your environment. +# Setting this variable to blank will disable retrying entirely +DETECT_CURL_RETRY_OPTS=${DETECT_CURL_RETRY_OPTS:-"--retry 3 --retry-delay 5 --retry-max-time 30"} + # If you want to pass any additional options to # curl, specify DETECT_CURL_OPTS in your environment. # For example, to specify a proxy, you would set @@ -156,7 +161,7 @@ get_detect() { if [ ${USE_REMOTE} -eq 1 ]; then echo "getting ${DETECT_SOURCE} from remote" TEMP_DETECT_DESTINATION="${DETECT_DESTINATION}-temp" - curlReturn=$(curl ${DETECT_CURL_OPTS} --retry 3 --silent -w "%{http_code}" -L -o "${TEMP_DETECT_DESTINATION}" --create-dirs "${DETECT_SOURCE}") + curlReturn=$(curl ${DETECT_CURL_OPTS} ${DETECT_CURL_RETRY_OPTS} --silent -w "%{http_code}" -L -o "${TEMP_DETECT_DESTINATION}" --create-dirs "${DETECT_SOURCE}") if [[ 200 -eq ${curlReturn} ]]; then mv "${TEMP_DETECT_DESTINATION}" "${DETECT_DESTINATION}" if [[ -f ${LOCAL_FILE} ]]; then