Skip to content

Commit fad2f61

Browse files
Copilotdata-douser
andauthored
[UPDATE PRIMITIVE] Fix transient HTTP 503 failures in install-packs.sh via exponential backoff retry (#121)
* Initial plan * fix: add retry logic with exponential backoff to install-packs.sh The GitHub Actions integration test was failing on windows-latest with HTTP 503 "Egress is over the account limit" when downloading CodeQL packs from GHCR.io. Add a run_with_retry() helper function that retries a command up to 3 times with exponential backoff (10s, 20s, 40s). Both codeql pack install calls in install_packs() now use run_with_retry to handle transient network errors gracefully. Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
1 parent 29da2f5 commit fad2f61

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

server/scripts/install-packs.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,35 @@ REPO_ROOT_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)"
6363
## Explicitly set the cwd to the REPO_ROOT_DIR.
6464
cd "${REPO_ROOT_DIR}"
6565

66+
## Define a helper to run a command with exponential-backoff retry.
67+
## Usage: run_with_retry <max_attempts> <initial_delay_seconds> <command> [args...]
68+
run_with_retry() {
69+
local _max_attempts="$1"
70+
local _delay="$2"
71+
shift 2
72+
local _attempt=1
73+
while true; do
74+
if "$@"; then
75+
return 0
76+
fi
77+
if [ "${_attempt}" -ge "${_max_attempts}" ]; then
78+
echo "ERROR: Command failed after ${_max_attempts} attempt(s): $*" >&2
79+
return 1
80+
fi
81+
echo "WARNING: Command failed (attempt ${_attempt}/${_max_attempts}). Retrying in ${_delay}s..." >&2
82+
sleep "${_delay}"
83+
_attempt=$((_attempt + 1))
84+
_delay=$((_delay * 2))
85+
done
86+
}
87+
6688
## Define a function to install the src and test packs for a given parent directory.
6789
install_packs() {
6890
local _parent_dir="$1"
6991
echo "INFO: Running 'codeql pack install' for '${_parent_dir}/src' directory..."
70-
codeql pack install --no-strict-mode --additional-packs="${_parent_dir}" -- "${_parent_dir}/src"
92+
run_with_retry 3 10 codeql pack install --no-strict-mode --additional-packs="${_parent_dir}" -- "${_parent_dir}/src"
7193
echo "INFO: Running 'codeql pack install' for '${_parent_dir}/test' directory..."
72-
codeql pack install --no-strict-mode --additional-packs="${_parent_dir}" -- "${_parent_dir}/test"
94+
run_with_retry 3 10 codeql pack install --no-strict-mode --additional-packs="${_parent_dir}" -- "${_parent_dir}/test"
7395
}
7496

7597
## Install codeql packs needed for integration tests.

0 commit comments

Comments
 (0)