From 50048098035ea726c0b4ef9851bf57e1465381d5 Mon Sep 17 00:00:00 2001 From: Yoom Lam Date: Fri, 7 Jun 2024 20:03:20 -0500 Subject: [PATCH] fix attempt: retry deployments --- .github/workflows/push-image.yml | 16 +++++++++++----- 05-assistive-chatbot/chatbot_api.py | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/push-image.yml b/.github/workflows/push-image.yml index 51568b8..d242ce1 100644 --- a/.github/workflows/push-image.yml +++ b/.github/workflows/push-image.yml @@ -167,10 +167,16 @@ jobs: echo "$CONFIG_TEMPLATE" | BUILD_DATE=$(date +%Y-%m-%d-%T%z) envsubst > config.json cat config.json - echo "Creating new deployment" - aws lightsail create-container-service-deployment --cli-input-json file://config.json - - sleep 10 - ./.github/workflows/waitForLightsail.sh deployment + for ((i = 0 ; i < ${DEPLOY_RETRIES:=3} ; i++ )); do + echo "## Deploy attempt $((i+1)) of $DEPLOY_RETRIES" + echo "Creating new deployment" + aws lightsail create-container-service-deployment --cli-input-json file://config.json + + sleep 10 + if ./.github/workflows/waitForLightsail.sh deployment; then + echo "Success" + break; + fi + done # TODO: warm up vector DB on startup diff --git a/05-assistive-chatbot/chatbot_api.py b/05-assistive-chatbot/chatbot_api.py index 5117b6e..cbcab80 100755 --- a/05-assistive-chatbot/chatbot_api.py +++ b/05-assistive-chatbot/chatbot_api.py @@ -57,7 +57,7 @@ def healthcheck(request: Request): build_date = os.environ.get("BUILD_DATE", "") logger.info("Returning: Healthy %s %s", build_date, git_sha) - return HTMLResponse(f"Healthy {build_date} {git_sha}") + return HTMLResponse(f"Healthy {git_sha} built at {build_date}") if __name__ == "__main__":