From 15cd9b40b8ebc3882de64f8d8092af0c505febc0 Mon Sep 17 00:00:00 2001 From: Thomas Manson Date: Wed, 25 Sep 2024 14:36:48 +1000 Subject: [PATCH] Adding retries to the enclave to get config --- scripts/aws/eks-pod/entrypoint.sh | 3 +++ scripts/aws/entrypoint.sh | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/scripts/aws/eks-pod/entrypoint.sh b/scripts/aws/eks-pod/entrypoint.sh index a72a92f22..c506d6cbf 100644 --- a/scripts/aws/eks-pod/entrypoint.sh +++ b/scripts/aws/eks-pod/entrypoint.sh @@ -112,9 +112,12 @@ update_config run_enclave sleep 60s +set +x ENCLAVE_ID=$(nitro-cli describe-enclaves | jq -r ".[0].EnclaveID") while [ "$ENCLAVE_ID" != "null" ]; do ENCLAVE_ID=$(nitro-cli describe-enclaves | jq -r ".[0].EnclaveID") sleep 10s done; + +echo "No running enclave, so shutting down the pod" diff --git a/scripts/aws/entrypoint.sh b/scripts/aws/entrypoint.sh index 44e2f5b95..73193b4b9 100755 --- a/scripts/aws/entrypoint.sh +++ b/scripts/aws/entrypoint.sh @@ -22,6 +22,27 @@ echo "Starting syslog-ng..." # -- load config from identity service echo "Loading config from identity service via proxy..." +set +e +#wait for config service +RETRY_COUNT=0 +MAX_RETRY=10 +while true; do + RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -x socks5h://127.0.0.1:3305 http://127.0.0.1:27015/getConfig) + if [ "$RESPONSE" -eq "200" ]; then + echo "Config server running" + break; + else + echo "Config server still starting..." + fi + RETRY_COUNT=$(( RETRY_COUNT + 1)) + if [ $RETRY_COUNT -gt $MAX_RETRY ]; then + echo "Config Server did not return a response. Exiting" + exit 1 + fi + sleep 5 + +done + { set +x; } 2>/dev/null; { IDENTITY_SERVICE_CONFIG=$(curl -s -x socks5h://127.0.0.1:3305 http://127.0.0.1:27015/getConfig); set -x; } if jq -e . >/dev/null 2>&1 <<<"${IDENTITY_SERVICE_CONFIG}"; then echo "Identity service returned valid config" @@ -29,6 +50,7 @@ else echo "Failed to get a valid config from identity service" exit 1 fi +set -e export OVERRIDES_CONFIG="/app/conf/config-overrides.json" { set +x; } 2>/dev/null; { echo "${IDENTITY_SERVICE_CONFIG}" > "${OVERRIDES_CONFIG}"; set -x; }