Skip to content

Commit

Permalink
Adding retries to the enclave to get config
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasm-ttd committed Sep 25, 2024
1 parent bcde82e commit 15cd9b4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/aws/eks-pod/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
22 changes: 22 additions & 0 deletions scripts/aws/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,35 @@ 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"
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; }
Expand Down

0 comments on commit 15cd9b4

Please sign in to comment.