From b89091cc7d441361e571f31d1dd723606088ebb7 Mon Sep 17 00:00:00 2001 From: William Wernert Date: Mon, 17 May 2021 15:58:25 -0400 Subject: [PATCH] Try retrying in curl instead of shell function --- salt/common/tools/sbin/so-common | 10 ++++++++-- salt/common/tools/sbin/so-image-common | 10 ++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/salt/common/tools/sbin/so-common b/salt/common/tools/sbin/so-common index 2b2bbf944..d5450f096 100755 --- a/salt/common/tools/sbin/so-common +++ b/salt/common/tools/sbin/so-common @@ -328,10 +328,16 @@ retry() { run_check_net_err() { local cmd=$1 local err_msg=${2:-"Unknown error occured, please check /root/$WHATWOULDYOUSAYYAHDOHERE.log for details."} # Really need to rename that variable + local no_retry=$3 local exit_code - retry 50 10 "$cmd" - exit_code=$? + if [[ -z $no_retry ]]; then + retry 50 10 "$cmd" + exit_code=$? + else + eval "$cmd" + exit_code=$? + fi if [[ $exit_code -ne 0 ]]; then echo "Command failed with error $exit_code" diff --git a/salt/common/tools/sbin/so-image-common b/salt/common/tools/sbin/so-image-common index c855abd15..fa1d6c6dd 100755 --- a/salt/common/tools/sbin/so-image-common +++ b/salt/common/tools/sbin/so-image-common @@ -130,8 +130,9 @@ update_docker_containers() { # Let's make sure we have the public key run_check_net_err \ - "curl -sSL https://raw.githubusercontent.com/Security-Onion-Solutions/securityonion/master/KEYS -o $SIGNPATH/KEYS" \ - "Could not pull signature key file, please ensure connectivity to https://raw.gihubusercontent.com" >> "$LOG_FILE" 2>&1 + "curl --retry 20 --retry-delay 30 -sSL https://raw.githubusercontent.com/Security-Onion-Solutions/securityonion/master/KEYS -o $SIGNPATH/KEYS" \ + "Could not pull signature key file, please ensure connectivity to https://raw.gihubusercontent.com" \ + noretry >> "$LOG_FILE" 2>&1 result=$? if [[ $result -eq 0 ]]; then cat $SIGNPATH/KEYS | gpg --import - >> "$LOG_FILE" 2>&1 @@ -157,8 +158,9 @@ update_docker_containers() { # Get signature run_check_net_err \ - "curl -A '$CURLTYPE/$CURRENTVERSION/$OS/$(uname -r)' https://sigs.securityonion.net/$VERSION/$i:$VERSION$IMAGE_TAG_SUFFIX.sig --output $SIGNPATH/$image.sig" \ - "Could not pull signature file, please ensure connectivity to https://sigs.securityonion.net " >> "$LOG_FILE" 2>&1 + "curl --retry 20 --retry-delay 30 -A '$CURLTYPE/$CURRENTVERSION/$OS/$(uname -r)' https://sigs.securityonion.net/$VERSION/$i:$VERSION$IMAGE_TAG_SUFFIX.sig --output $SIGNPATH/$image.sig" \ + "Could not pull signature file, please ensure connectivity to https://sigs.securityonion.net " \ + noretry >> "$LOG_FILE" 2>&1 if [[ $? -ne 0 ]]; then echo "Unable to pull signature file for $image" >> "$LOG_FILE" 2>&1 exit 1