From 0f4a4dad07fc48239e3f79bd9c867f54936b58e3 Mon Sep 17 00:00:00 2001 From: Looker_CI_CD Date: Mon, 6 Oct 2025 08:24:33 +0300 Subject: [PATCH 1/4] Update DNS resolve --- api-entrypoint.sh | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/api-entrypoint.sh b/api-entrypoint.sh index 8ac39a9..a63c9f3 100644 --- a/api-entrypoint.sh +++ b/api-entrypoint.sh @@ -40,14 +40,48 @@ then rm -rf /data/lost+found fi -#Checking DNS Resolve. +#Checking DNS Resolve with retry logic if test "${GIT_URL}"; then -until curl --output /dev/null --silent --head --fail ${GIT_URL}; do - printf "Waiting DNS ${GIT_URL} will be resolved!" - sleep 5 -done + echo "Checking DNS resolution for ${GIT_URL}..." + + # Configuration for retry logic (configurable via environment variables) + MAX_RETRIES=${DNS_RETRY_MAX_ATTEMPTS:-15} + RETRY_INTERVAL=${DNS_RETRY_INTERVAL:-30} + CONNECT_TIMEOUT=${DNS_CONNECT_TIMEOUT:-10} + MAX_TIMEOUT=${DNS_MAX_TIMEOUT:-30} + RETRY_COUNT=0 + + echo "DNS resolution configuration:" + echo " - Max retries: ${MAX_RETRIES}" + echo " - Retry interval: ${RETRY_INTERVAL} seconds" + echo " - Connect timeout: ${CONNECT_TIMEOUT} seconds" + echo " - Max timeout: ${MAX_TIMEOUT} seconds" + + while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do + if curl --output /dev/null --silent --head --fail --connect-timeout ${CONNECT_TIMEOUT} --max-time ${MAX_TIMEOUT} ${GIT_URL}; then + echo "DNS resolution successful for ${GIT_URL}" + break + else + RETRY_COUNT=$((RETRY_COUNT + 1)) + echo "DNS resolution attempt ${RETRY_COUNT}/${MAX_RETRIES} failed for ${GIT_URL}" + + if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then + echo "Retrying in ${RETRY_INTERVAL} seconds..." + sleep $RETRY_INTERVAL + fi + fi + done + + # Check if we exhausted all retries + if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then + log_error "Failed to resolve DNS for ${GIT_URL} after ${MAX_RETRIES} attempts" + log_error "Repository server is not accessible. Please check network connectivity and DNS configuration." + exit 1 + fi else echo "GIT address not described!" + log_error "GIT_URL environment variable is not set" + exit 1 fi #Creating a data directory && start working. From 7b0421ac5a4889a0044671ea526681ddbc9fe6cf Mon Sep 17 00:00:00 2001 From: Looker_CI_CD Date: Mon, 6 Oct 2025 08:29:30 +0300 Subject: [PATCH 2/4] Update DNS resolve log_error --- api-entrypoint.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api-entrypoint.sh b/api-entrypoint.sh index a63c9f3..763a46d 100644 --- a/api-entrypoint.sh +++ b/api-entrypoint.sh @@ -74,13 +74,16 @@ if test "${GIT_URL}"; then # Check if we exhausted all retries if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then - log_error "Failed to resolve DNS for ${GIT_URL} after ${MAX_RETRIES} attempts" - log_error "Repository server is not accessible. Please check network connectivity and DNS configuration." + echo "Failed to resolve DNS for ${GIT_URL} after ${MAX_RETRIES} attempts" >&2 + echo "Failed to resolve DNS for ${GIT_URL} after ${MAX_RETRIES} attempts" >> ${LOG_FILE} + echo "Repository server is not accessible. Please check network connectivity and DNS configuration." >&2 + echo "Repository server is not accessible. Please check network connectivity and DNS configuration." >> ${LOG_FILE} exit 1 fi else echo "GIT address not described!" - log_error "GIT_URL environment variable is not set" + echo "GIT_URL environment variable is not set" >&2 + echo "GIT_URL environment variable is not set" >> ${LOG_FILE} exit 1 fi From bf8401c6280b4919316f73ac3a34002a48174b78 Mon Sep 17 00:00:00 2001 From: Looker_CI_CD Date: Mon, 6 Oct 2025 10:26:54 +0300 Subject: [PATCH 3/4] Update DNS resolve log_error --- api-entrypoint.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/api-entrypoint.sh b/api-entrypoint.sh index 763a46d..1cb33da 100644 --- a/api-entrypoint.sh +++ b/api-entrypoint.sh @@ -57,33 +57,33 @@ if test "${GIT_URL}"; then echo " - Connect timeout: ${CONNECT_TIMEOUT} seconds" echo " - Max timeout: ${MAX_TIMEOUT} seconds" - while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do - if curl --output /dev/null --silent --head --fail --connect-timeout ${CONNECT_TIMEOUT} --max-time ${MAX_TIMEOUT} ${GIT_URL}; then + while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do + if curl --output /dev/null --silent --head --fail --connect-timeout "${CONNECT_TIMEOUT}" --max-time "${MAX_TIMEOUT}" "${GIT_URL}"; then echo "DNS resolution successful for ${GIT_URL}" break else RETRY_COUNT=$((RETRY_COUNT + 1)) echo "DNS resolution attempt ${RETRY_COUNT}/${MAX_RETRIES} failed for ${GIT_URL}" - if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then + if [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; then echo "Retrying in ${RETRY_INTERVAL} seconds..." - sleep $RETRY_INTERVAL + sleep "${RETRY_INTERVAL}" fi fi done # Check if we exhausted all retries - if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then + if [ "$RETRY_COUNT" -eq "$MAX_RETRIES" ]; then echo "Failed to resolve DNS for ${GIT_URL} after ${MAX_RETRIES} attempts" >&2 - echo "Failed to resolve DNS for ${GIT_URL} after ${MAX_RETRIES} attempts" >> ${LOG_FILE} + echo "Failed to resolve DNS for ${GIT_URL} after ${MAX_RETRIES} attempts" >> "${LOG_FILE}" echo "Repository server is not accessible. Please check network connectivity and DNS configuration." >&2 - echo "Repository server is not accessible. Please check network connectivity and DNS configuration." >> ${LOG_FILE} + echo "Repository server is not accessible. Please check network connectivity and DNS configuration." >> "${LOG_FILE}" exit 1 fi else echo "GIT address not described!" echo "GIT_URL environment variable is not set" >&2 - echo "GIT_URL environment variable is not set" >> ${LOG_FILE} + echo "GIT_URL environment variable is not set" >> "${LOG_FILE}" exit 1 fi From 5d14dbbd832b832c0ba7d3e7d1cd93936b04db37 Mon Sep 17 00:00:00 2001 From: Looker_CI_CD Date: Mon, 6 Oct 2025 11:21:59 +0300 Subject: [PATCH 4/4] Update DNS resolve log_error --- api-entrypoint.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api-entrypoint.sh b/api-entrypoint.sh index 1cb33da..b80be69 100644 --- a/api-entrypoint.sh +++ b/api-entrypoint.sh @@ -52,10 +52,10 @@ if test "${GIT_URL}"; then RETRY_COUNT=0 echo "DNS resolution configuration:" - echo " - Max retries: ${MAX_RETRIES}" - echo " - Retry interval: ${RETRY_INTERVAL} seconds" - echo " - Connect timeout: ${CONNECT_TIMEOUT} seconds" - echo " - Max timeout: ${MAX_TIMEOUT} seconds" + echo " - Max retries: ${MAX_RETRIES} (DNS_RETRY_MAX_ATTEMPTS)" + echo " - Retry interval: ${RETRY_INTERVAL} seconds (DNS_RETRY_INTERVAL)" + echo " - Connect timeout: ${CONNECT_TIMEOUT} seconds (DNS_CONNECT_TIMEOUT)" + echo " - Max timeout: ${MAX_TIMEOUT} seconds (DNS_MAX_TIMEOUT)" while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do if curl --output /dev/null --silent --head --fail --connect-timeout "${CONNECT_TIMEOUT}" --max-time "${MAX_TIMEOUT}" "${GIT_URL}"; then