From c0f792782f53a1197c533f890b0a6ebccf8b9d4a Mon Sep 17 00:00:00 2001 From: Alex Lebens Date: Fri, 19 Dec 2025 21:18:09 -0600 Subject: [PATCH] add retry on apk repo --- .../qbittorrent/templates/config-map.yaml | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/clusters/cl01tl/helm/qbittorrent/templates/config-map.yaml b/clusters/cl01tl/helm/qbittorrent/templates/config-map.yaml index 7c146797b..4a8a41bff 100644 --- a/clusters/cl01tl/helm/qbittorrent/templates/config-map.yaml +++ b/clusters/cl01tl/helm/qbittorrent/templates/config-map.yaml @@ -9,6 +9,26 @@ metadata: app.kubernetes.io/part-of: {{ .Release.Name }} data: update.sh: | + API_ENDPOINT="http://localhost:8080/api/v2"; + MAX_RETRIES=5 + SUCCESS=false + + for ((i=1; i<=$MAX_RETRIES; i++)); do + if apk update --short &> /dev/null; then + echo ">> Attempt $i: Repositories are reachable" + SUCCESS=true + break + else + echo ">> Attempt $i: Connection failed, retrying in 5 seconds ..." + sleep 5 + fi + done + + if [ "$SUCCESS" = false ]; then + echo ">> ERROR: Could not connect to apk repositories after $MAX_RETRIES attempts, exiting ..." + exit 1 + fi + if ! command -v curl 2>&1 >/dev/null then echo "curl could not be found, installing"; @@ -33,8 +53,6 @@ data: fi fi; - API_ENDPOINT="http://localhost:8080/api/v2"; - # echo " "; # echo ">> Authentication ..."; # curl -i --silent --header 'Referer: http://localhost:8080' --output response_body_auth.json --data 'username=admin&password=adminadmin' "${API_ENDPOINT}/auth/login" -c cookie;