From 695b7b8ab6b7fd6afbe240c2879cdde9f4ba8c4c Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Wed, 18 Feb 2026 21:26:50 +0000 Subject: [PATCH 01/12] added retries --- run-samples.sh | 3 ++- .../python/scripts/get-web-app-url.sh | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/run-samples.sh b/run-samples.sh index ea418e9..b5a5080 100644 --- a/run-samples.sh +++ b/run-samples.sh @@ -103,7 +103,8 @@ BICEP_SAMPLES=( # 4. Calculate Shard # Combine script-based, Terraform, and Bicep samples into one array -ALL_SAMPLES=("${SAMPLES[@]}" "${TERRAFORM_SAMPLES[@]}" "${BICEP_SAMPLES[@]}") +#ALL_SAMPLES=("${SAMPLES[@]}" "${TERRAFORM_SAMPLES[@]}" "${BICEP_SAMPLES[@]}") +ALL_SAMPLES=("${SAMPLES[@]}") TOTAL=${#ALL_SAMPLES[@]} SHARD=${1:-1} SPLITS=${2:-1} diff --git a/samples/web-app-sql-database/python/scripts/get-web-app-url.sh b/samples/web-app-sql-database/python/scripts/get-web-app-url.sh index 735555f..1f1e896 100644 --- a/samples/web-app-sql-database/python/scripts/get-web-app-url.sh +++ b/samples/web-app-sql-database/python/scripts/get-web-app-url.sh @@ -103,14 +103,24 @@ call_web_app() { exit 1 fi - # Get the Docker container name + # Get the Docker container name (with retries, as the container may take time to start after deployment) echo "Finding container name with prefix [ls-$web_app_name]..." - container_name=$(get_docker_container_name_by_prefix "ls-$web_app_name") + MAX_RETRIES=30 + RETRY_INTERVAL=10 + container_name="" + for ((attempt=1; attempt<=MAX_RETRIES; attempt++)); do + container_name=$(get_docker_container_name_by_prefix "ls-$web_app_name") && break + container_name="" + if [ "$attempt" -lt "$MAX_RETRIES" ]; then + echo "Attempt $attempt/$MAX_RETRIES: Container not found yet. Waiting ${RETRY_INTERVAL}s..." + sleep "$RETRY_INTERVAL" + fi + done - if [ $? -eq 0 ] && [ -n "$container_name" ]; then + if [ -n "$container_name" ]; then echo "Container [$container_name] found successfully" else - echo "Failed to get container name" + echo "Failed to get container name after $MAX_RETRIES attempts" exit 1 fi From 7e95f4628c229cbb2910ba2f395ef1fb1dc4c98c Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Wed, 18 Feb 2026 22:05:11 +0000 Subject: [PATCH 02/12] added logging --- .github/workflows/run-samples.yml | 31 ++++++++++++++ .../python/scripts/deploy.sh | 42 +++++++++++++++++++ .../python/scripts/get-web-app-url.sh | 39 ++++++++++++++++- 3 files changed, 111 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-samples.yml b/.github/workflows/run-samples.yml index c34b45e..3f3ae85 100644 --- a/.github/workflows/run-samples.yml +++ b/.github/workflows/run-samples.yml @@ -128,7 +128,38 @@ jobs: env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.TEST_LOCALSTACK_AUTH_TOKEN }} + - name: Docker state snapshot + # Capture the full Docker state on failure to diagnose missing web app containers. + if: failure() + run: | + echo "=== All Docker containers (running + stopped) ===" + docker ps -a --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}" 2>&1 + echo "" + echo "=== Docker images ===" + docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}\t{{.ID}}" 2>&1 + echo "" + echo "=== Exited container logs ===" + for c in $(docker ps -a --filter "status=exited" --format "{{.Names}}" 2>/dev/null); do + echo "--- [$c] (last 50 lines) ---" + docker logs "$c" --tail 50 2>&1 + done + - name: Get LocalStack Logs # Captured on failure or success to provide a detailed audit trail of the emulator's activity. if: always() run: make logs + + - name: Get LocalStack Logs (webapp filtered) + # Filtered view of LocalStack logs to surface web app container creation issues. + if: failure() + run: | + LS_CONTAINER=$(docker ps --format "{{.Names}}" | grep -i "localstack" | head -1) + if [ -n "$LS_CONTAINER" ]; then + echo "=== LocalStack logs filtered for web app / container issues ===" + docker logs "$LS_CONTAINER" 2>&1 | grep -iE "(ls-local-webapp|webapp.*deploy|container.*create|container.*start|pip.*install|requirements\.txt|cryptography|certificates|import.*error|module.*not.*found|build.*fail|gunicorn|flask|startup.*command|oryx|ModuleNotFoundError|Traceback)" | tail -200 || echo "(no matching lines)" + echo "" + echo "=== LocalStack logs filtered for ERROR/EXCEPTION ===" + docker logs "$LS_CONTAINER" 2>&1 | grep -iE "(ERROR|EXCEPTION|FATAL|CRITICAL)" | tail -100 || echo "(no errors found)" + else + echo "No LocalStack container found" + fi diff --git a/samples/web-app-sql-database/python/scripts/deploy.sh b/samples/web-app-sql-database/python/scripts/deploy.sh index e73c8ee..3c43664 100755 --- a/samples/web-app-sql-database/python/scripts/deploy.sh +++ b/samples/web-app-sql-database/python/scripts/deploy.sh @@ -479,6 +479,48 @@ else exit 1 fi +# ============================================================ +# DEBUG: Post-deployment diagnostics +# ============================================================ +echo "=== DEBUG: Post-deployment container state ===" + +echo "--- All running Docker containers ---" +docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}" 2>&1 + +echo "--- All Docker containers (including stopped/exited) ---" +docker ps -a --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}" 2>&1 + +echo "--- Docker images ---" +docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" 2>&1 + +# Find the LocalStack main container and show relevant logs +LS_CONTAINER=$(docker ps --format "{{.Names}}" | grep -i "localstack" | head -1) +if [ -n "$LS_CONTAINER" ]; then + echo "--- LocalStack container [$LS_CONTAINER] logs (last 100 lines, filtered for webapp/container/deploy) ---" + docker logs "$LS_CONTAINER" --tail 100 2>&1 | grep -iE "(webapp|container|deploy|error|exception|pip|install|cryptography|certificates|failed|build)" || echo "(no matching log lines found)" + + echo "--- LocalStack container [$LS_CONTAINER] logs (last 50 lines, unfiltered) ---" + docker logs "$LS_CONTAINER" --tail 50 2>&1 +else + echo "WARNING: No LocalStack container found" +fi + +# Check for any recently exited containers +EXITED_CONTAINERS=$(docker ps -a --filter "status=exited" --format "{{.Names}}\t{{.Image}}\t{{.Status}}" 2>&1) +if [ -n "$EXITED_CONTAINERS" ]; then + echo "--- Recently exited containers ---" + echo "$EXITED_CONTAINERS" + # Show logs from any exited container that might be the web app + docker ps -a --filter "status=exited" --format "{{.Names}}" | while read -r c; do + echo "--- Logs from exited container [$c] (last 30 lines) ---" + docker logs "$c" --tail 30 2>&1 + done +else + echo "--- No exited containers found ---" +fi + +echo "=== END DEBUG: Post-deployment diagnostics ===" + # Get web app URL WEB_APP_URL=$($AZ webapp show \ --name "$WEB_APP_NAME" \ diff --git a/samples/web-app-sql-database/python/scripts/get-web-app-url.sh b/samples/web-app-sql-database/python/scripts/get-web-app-url.sh index 1f1e896..e6417d9 100644 --- a/samples/web-app-sql-database/python/scripts/get-web-app-url.sh +++ b/samples/web-app-sql-database/python/scripts/get-web-app-url.sh @@ -105,12 +105,49 @@ call_web_app() { # Get the Docker container name (with retries, as the container may take time to start after deployment) echo "Finding container name with prefix [ls-$web_app_name]..." - MAX_RETRIES=30 + MAX_RETRIES=18 RETRY_INTERVAL=10 container_name="" for ((attempt=1; attempt<=MAX_RETRIES; attempt++)); do container_name=$(get_docker_container_name_by_prefix "ls-$web_app_name") && break container_name="" + + # Print full diagnostics on first, every 6th, and last attempt + if [ "$attempt" -eq 1 ] || [ "$((attempt % 6))" -eq 0 ] || [ "$attempt" -eq "$MAX_RETRIES" ]; then + echo "=== DEBUG (attempt $attempt/$MAX_RETRIES): Container diagnostics ===" + + echo "--- All running containers ---" + docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}" 2>&1 + + echo "--- All containers (including stopped/exited) ---" + docker ps -a --format "table {{.Names}}\t{{.Image}}\t{{.Status}}" 2>&1 + + echo "--- Docker images ---" + docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}" 2>&1 + + # Check LocalStack logs for web app container creation errors + LS_CONTAINER=$(docker ps --format "{{.Names}}" | grep -i "localstack" | head -1) + if [ -n "$LS_CONTAINER" ]; then + echo "--- LocalStack logs (last 50 lines, filtered for webapp/container/error) ---" + docker logs "$LS_CONTAINER" --tail 200 2>&1 | grep -iE "(ls-${web_app_name}|webapp.*container|container.*webapp|pip.*install|requirements|cryptography|certificates|import.*error|module.*not.*found|build.*fail|error.*build|startup|gunicorn|flask)" | tail -50 || echo "(no matching log lines)" + + echo "--- LocalStack logs (last 30 lines, unfiltered) ---" + docker logs "$LS_CONTAINER" --tail 30 2>&1 + fi + + # Show logs from any exited containers + EXITED=$(docker ps -a --filter "status=exited" --format "{{.Names}}" 2>/dev/null) + if [ -n "$EXITED" ]; then + echo "--- Exited container logs ---" + echo "$EXITED" | while read -r c; do + echo " [$c] logs (last 20 lines):" + docker logs "$c" --tail 20 2>&1 | sed 's/^/ /' + done + fi + + echo "=== END DEBUG ===" + fi + if [ "$attempt" -lt "$MAX_RETRIES" ]; then echo "Attempt $attempt/$MAX_RETRIES: Container not found yet. Waiting ${RETRY_INTERVAL}s..." sleep "$RETRY_INTERVAL" From 66d9dba50fcc041e580b4262b7c7314e29b16caf Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Wed, 18 Feb 2026 22:43:33 +0000 Subject: [PATCH 03/12] added all exceptions --- samples/web-app-sql-database/python/src/app.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/web-app-sql-database/python/src/app.py b/samples/web-app-sql-database/python/src/app.py index 46c762f..e3f90fd 100644 --- a/samples/web-app-sql-database/python/src/app.py +++ b/samples/web-app-sql-database/python/src/app.py @@ -52,7 +52,7 @@ def read_activities_from_db(username: str | None = None) -> List[Tuple[str, str] activity_list = activities_helper.read_activities(username) for activity in activity_list: result.append((activity["id"], activity["activity"])) - except (ConnectionError, ValueError, KeyError) as e: + except Exception as e: logger.error("Error reading activities: %s", e) return result @@ -88,7 +88,7 @@ def index(): # Append the activity to the in-memory list activities.append((inserted_activity["id"], inserted_activity["activity"])) logger.info(f"Activity created: {inserted_activity['id']}") - except (ConnectionError, ValueError) as e: + except Exception as e: logger.error("Error creating/updating activity: %s", e) return redirect(url_for('index')) @@ -117,7 +117,7 @@ def delete(activity_id: int): logger.info(f"Activity deleted: {db_activity_id}") else: logger.warning(f"No activity found with ID: {db_activity_id}") - except (ConnectionError, ValueError) as e: + except Exception as e: logger.error("Error deleting activity: %s", e) return redirect(url_for('index')) From 7dc1965d20c8be55553e46d08d0ef7168f98ff8b Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Wed, 18 Feb 2026 23:05:52 +0000 Subject: [PATCH 04/12] refacotred --- .github/workflows/run-samples.yml | 16 +----- run-samples.sh | 3 +- .../python/scripts/deploy.sh | 42 -------------- .../python/scripts/get-web-app-url.sh | 55 ++----------------- 4 files changed, 6 insertions(+), 110 deletions(-) diff --git a/.github/workflows/run-samples.yml b/.github/workflows/run-samples.yml index 3f3ae85..d34ea4f 100644 --- a/.github/workflows/run-samples.yml +++ b/.github/workflows/run-samples.yml @@ -129,7 +129,7 @@ jobs: LOCALSTACK_AUTH_TOKEN: ${{ secrets.TEST_LOCALSTACK_AUTH_TOKEN }} - name: Docker state snapshot - # Capture the full Docker state on failure to diagnose missing web app containers. + # Capture the full Docker state on failure if: failure() run: | echo "=== All Docker containers (running + stopped) ===" @@ -149,17 +149,3 @@ jobs: if: always() run: make logs - - name: Get LocalStack Logs (webapp filtered) - # Filtered view of LocalStack logs to surface web app container creation issues. - if: failure() - run: | - LS_CONTAINER=$(docker ps --format "{{.Names}}" | grep -i "localstack" | head -1) - if [ -n "$LS_CONTAINER" ]; then - echo "=== LocalStack logs filtered for web app / container issues ===" - docker logs "$LS_CONTAINER" 2>&1 | grep -iE "(ls-local-webapp|webapp.*deploy|container.*create|container.*start|pip.*install|requirements\.txt|cryptography|certificates|import.*error|module.*not.*found|build.*fail|gunicorn|flask|startup.*command|oryx|ModuleNotFoundError|Traceback)" | tail -200 || echo "(no matching lines)" - echo "" - echo "=== LocalStack logs filtered for ERROR/EXCEPTION ===" - docker logs "$LS_CONTAINER" 2>&1 | grep -iE "(ERROR|EXCEPTION|FATAL|CRITICAL)" | tail -100 || echo "(no errors found)" - else - echo "No LocalStack container found" - fi diff --git a/run-samples.sh b/run-samples.sh index b5a5080..ea418e9 100644 --- a/run-samples.sh +++ b/run-samples.sh @@ -103,8 +103,7 @@ BICEP_SAMPLES=( # 4. Calculate Shard # Combine script-based, Terraform, and Bicep samples into one array -#ALL_SAMPLES=("${SAMPLES[@]}" "${TERRAFORM_SAMPLES[@]}" "${BICEP_SAMPLES[@]}") -ALL_SAMPLES=("${SAMPLES[@]}") +ALL_SAMPLES=("${SAMPLES[@]}" "${TERRAFORM_SAMPLES[@]}" "${BICEP_SAMPLES[@]}") TOTAL=${#ALL_SAMPLES[@]} SHARD=${1:-1} SPLITS=${2:-1} diff --git a/samples/web-app-sql-database/python/scripts/deploy.sh b/samples/web-app-sql-database/python/scripts/deploy.sh index 3c43664..e73c8ee 100755 --- a/samples/web-app-sql-database/python/scripts/deploy.sh +++ b/samples/web-app-sql-database/python/scripts/deploy.sh @@ -479,48 +479,6 @@ else exit 1 fi -# ============================================================ -# DEBUG: Post-deployment diagnostics -# ============================================================ -echo "=== DEBUG: Post-deployment container state ===" - -echo "--- All running Docker containers ---" -docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}" 2>&1 - -echo "--- All Docker containers (including stopped/exited) ---" -docker ps -a --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}" 2>&1 - -echo "--- Docker images ---" -docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" 2>&1 - -# Find the LocalStack main container and show relevant logs -LS_CONTAINER=$(docker ps --format "{{.Names}}" | grep -i "localstack" | head -1) -if [ -n "$LS_CONTAINER" ]; then - echo "--- LocalStack container [$LS_CONTAINER] logs (last 100 lines, filtered for webapp/container/deploy) ---" - docker logs "$LS_CONTAINER" --tail 100 2>&1 | grep -iE "(webapp|container|deploy|error|exception|pip|install|cryptography|certificates|failed|build)" || echo "(no matching log lines found)" - - echo "--- LocalStack container [$LS_CONTAINER] logs (last 50 lines, unfiltered) ---" - docker logs "$LS_CONTAINER" --tail 50 2>&1 -else - echo "WARNING: No LocalStack container found" -fi - -# Check for any recently exited containers -EXITED_CONTAINERS=$(docker ps -a --filter "status=exited" --format "{{.Names}}\t{{.Image}}\t{{.Status}}" 2>&1) -if [ -n "$EXITED_CONTAINERS" ]; then - echo "--- Recently exited containers ---" - echo "$EXITED_CONTAINERS" - # Show logs from any exited container that might be the web app - docker ps -a --filter "status=exited" --format "{{.Names}}" | while read -r c; do - echo "--- Logs from exited container [$c] (last 30 lines) ---" - docker logs "$c" --tail 30 2>&1 - done -else - echo "--- No exited containers found ---" -fi - -echo "=== END DEBUG: Post-deployment diagnostics ===" - # Get web app URL WEB_APP_URL=$($AZ webapp show \ --name "$WEB_APP_NAME" \ diff --git a/samples/web-app-sql-database/python/scripts/get-web-app-url.sh b/samples/web-app-sql-database/python/scripts/get-web-app-url.sh index e6417d9..735555f 100644 --- a/samples/web-app-sql-database/python/scripts/get-web-app-url.sh +++ b/samples/web-app-sql-database/python/scripts/get-web-app-url.sh @@ -103,61 +103,14 @@ call_web_app() { exit 1 fi - # Get the Docker container name (with retries, as the container may take time to start after deployment) + # Get the Docker container name echo "Finding container name with prefix [ls-$web_app_name]..." - MAX_RETRIES=18 - RETRY_INTERVAL=10 - container_name="" - for ((attempt=1; attempt<=MAX_RETRIES; attempt++)); do - container_name=$(get_docker_container_name_by_prefix "ls-$web_app_name") && break - container_name="" - - # Print full diagnostics on first, every 6th, and last attempt - if [ "$attempt" -eq 1 ] || [ "$((attempt % 6))" -eq 0 ] || [ "$attempt" -eq "$MAX_RETRIES" ]; then - echo "=== DEBUG (attempt $attempt/$MAX_RETRIES): Container diagnostics ===" - - echo "--- All running containers ---" - docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}" 2>&1 - - echo "--- All containers (including stopped/exited) ---" - docker ps -a --format "table {{.Names}}\t{{.Image}}\t{{.Status}}" 2>&1 - - echo "--- Docker images ---" - docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}" 2>&1 - - # Check LocalStack logs for web app container creation errors - LS_CONTAINER=$(docker ps --format "{{.Names}}" | grep -i "localstack" | head -1) - if [ -n "$LS_CONTAINER" ]; then - echo "--- LocalStack logs (last 50 lines, filtered for webapp/container/error) ---" - docker logs "$LS_CONTAINER" --tail 200 2>&1 | grep -iE "(ls-${web_app_name}|webapp.*container|container.*webapp|pip.*install|requirements|cryptography|certificates|import.*error|module.*not.*found|build.*fail|error.*build|startup|gunicorn|flask)" | tail -50 || echo "(no matching log lines)" - - echo "--- LocalStack logs (last 30 lines, unfiltered) ---" - docker logs "$LS_CONTAINER" --tail 30 2>&1 - fi - - # Show logs from any exited containers - EXITED=$(docker ps -a --filter "status=exited" --format "{{.Names}}" 2>/dev/null) - if [ -n "$EXITED" ]; then - echo "--- Exited container logs ---" - echo "$EXITED" | while read -r c; do - echo " [$c] logs (last 20 lines):" - docker logs "$c" --tail 20 2>&1 | sed 's/^/ /' - done - fi - - echo "=== END DEBUG ===" - fi - - if [ "$attempt" -lt "$MAX_RETRIES" ]; then - echo "Attempt $attempt/$MAX_RETRIES: Container not found yet. Waiting ${RETRY_INTERVAL}s..." - sleep "$RETRY_INTERVAL" - fi - done + container_name=$(get_docker_container_name_by_prefix "ls-$web_app_name") - if [ -n "$container_name" ]; then + if [ $? -eq 0 ] && [ -n "$container_name" ]; then echo "Container [$container_name] found successfully" else - echo "Failed to get container name after $MAX_RETRIES attempts" + echo "Failed to get container name" exit 1 fi From 9969c8ea62550ef4509cabcd7c1c39b04ec92735 Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Thu, 19 Feb 2026 09:57:41 +0000 Subject: [PATCH 05/12] updated error catching --- samples/web-app-sql-database/python/src/app.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/samples/web-app-sql-database/python/src/app.py b/samples/web-app-sql-database/python/src/app.py index e3f90fd..d4de538 100644 --- a/samples/web-app-sql-database/python/src/app.py +++ b/samples/web-app-sql-database/python/src/app.py @@ -52,8 +52,10 @@ def read_activities_from_db(username: str | None = None) -> List[Tuple[str, str] activity_list = activities_helper.read_activities(username) for activity in activity_list: result.append((activity["id"], activity["activity"])) + except (ConnectionError, ValueError, KeyError) as e: + logger.error("Expected error reading activities: %s", e) except Exception as e: - logger.error("Error reading activities: %s", e) + logger.error("Unexpected system error reading activities: %s", e) return result @app.route('/', methods=['GET', 'POST']) @@ -88,8 +90,10 @@ def index(): # Append the activity to the in-memory list activities.append((inserted_activity["id"], inserted_activity["activity"])) logger.info(f"Activity created: {inserted_activity['id']}") + except (ConnectionError, ValueError) as e: + logger.error("Expected error creating/updating activity: %s", e) except Exception as e: - logger.error("Error creating/updating activity: %s", e) + logger.error("Unexpected system error creating/updating activity: %s", e) return redirect(url_for('index')) @@ -117,8 +121,10 @@ def delete(activity_id: int): logger.info(f"Activity deleted: {db_activity_id}") else: logger.warning(f"No activity found with ID: {db_activity_id}") + except (ConnectionError, ValueError) as e: + logger.error("Expected error deleting activity: %s", e) except Exception as e: - logger.error("Error deleting activity: %s", e) + logger.error("Unexpected system error deleting activity: %s", e) return redirect(url_for('index')) @@ -132,7 +138,9 @@ def update(activity_id: int): # Redirect to index with edit parameters return redirect(url_for('index', edit_id=db_activity_id, edit_activity=activity_text)) except (ConnectionError, ValueError) as e: - logger.error("Error preparing activity for update: %s", e) + logger.error("Expected error preparing activity for update: %s", e) + except Exception as e: + logger.error("Unexpected system error preparing activity for update: %s", e) return redirect(url_for('index')) From 3f91c7556652f0bb5f65d1d737458c5ed3b1f72e Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Thu, 19 Feb 2026 13:47:19 +0000 Subject: [PATCH 06/12] revert exception changes --- samples/web-app-sql-database/python/src/app.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/samples/web-app-sql-database/python/src/app.py b/samples/web-app-sql-database/python/src/app.py index d4de538..46c762f 100644 --- a/samples/web-app-sql-database/python/src/app.py +++ b/samples/web-app-sql-database/python/src/app.py @@ -53,9 +53,7 @@ def read_activities_from_db(username: str | None = None) -> List[Tuple[str, str] for activity in activity_list: result.append((activity["id"], activity["activity"])) except (ConnectionError, ValueError, KeyError) as e: - logger.error("Expected error reading activities: %s", e) - except Exception as e: - logger.error("Unexpected system error reading activities: %s", e) + logger.error("Error reading activities: %s", e) return result @app.route('/', methods=['GET', 'POST']) @@ -91,9 +89,7 @@ def index(): activities.append((inserted_activity["id"], inserted_activity["activity"])) logger.info(f"Activity created: {inserted_activity['id']}") except (ConnectionError, ValueError) as e: - logger.error("Expected error creating/updating activity: %s", e) - except Exception as e: - logger.error("Unexpected system error creating/updating activity: %s", e) + logger.error("Error creating/updating activity: %s", e) return redirect(url_for('index')) @@ -122,9 +118,7 @@ def delete(activity_id: int): else: logger.warning(f"No activity found with ID: {db_activity_id}") except (ConnectionError, ValueError) as e: - logger.error("Expected error deleting activity: %s", e) - except Exception as e: - logger.error("Unexpected system error deleting activity: %s", e) + logger.error("Error deleting activity: %s", e) return redirect(url_for('index')) @@ -138,9 +132,7 @@ def update(activity_id: int): # Redirect to index with edit parameters return redirect(url_for('index', edit_id=db_activity_id, edit_activity=activity_text)) except (ConnectionError, ValueError) as e: - logger.error("Expected error preparing activity for update: %s", e) - except Exception as e: - logger.error("Unexpected system error preparing activity for update: %s", e) + logger.error("Error preparing activity for update: %s", e) return redirect(url_for('index')) From 7badf480ca1f87e2bacb491de8f709ecda2b0024 Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Thu, 19 Feb 2026 13:52:17 +0000 Subject: [PATCH 07/12] . --- run-samples.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run-samples.sh b/run-samples.sh index ea418e9..b5a5080 100644 --- a/run-samples.sh +++ b/run-samples.sh @@ -103,7 +103,8 @@ BICEP_SAMPLES=( # 4. Calculate Shard # Combine script-based, Terraform, and Bicep samples into one array -ALL_SAMPLES=("${SAMPLES[@]}" "${TERRAFORM_SAMPLES[@]}" "${BICEP_SAMPLES[@]}") +#ALL_SAMPLES=("${SAMPLES[@]}" "${TERRAFORM_SAMPLES[@]}" "${BICEP_SAMPLES[@]}") +ALL_SAMPLES=("${SAMPLES[@]}") TOTAL=${#ALL_SAMPLES[@]} SHARD=${1:-1} SPLITS=${2:-1} From f97aa79763e0b2116a947e3cef3adcb0742434f0 Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Thu, 19 Feb 2026 13:57:21 +0000 Subject: [PATCH 08/12] added terraform_local --- requirements-runtime.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-runtime.txt b/requirements-runtime.txt index 6ede92c..573e0d0 100644 --- a/requirements-runtime.txt +++ b/requirements-runtime.txt @@ -9,3 +9,4 @@ azure-core python-dotenv localstack azlocal +terraform-local From 779c2e41aa3ada2021986d05a74052fb15585bb1 Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Fri, 20 Feb 2026 09:58:37 +0000 Subject: [PATCH 09/12] delete rg inbetween all sample app runs --- .github/workflows/run-samples.yml | 17 ------------ requirements-runtime.txt | 1 - run-samples.sh | 43 ++++++++++++++----------------- 3 files changed, 19 insertions(+), 42 deletions(-) diff --git a/.github/workflows/run-samples.yml b/.github/workflows/run-samples.yml index d34ea4f..c34b45e 100644 --- a/.github/workflows/run-samples.yml +++ b/.github/workflows/run-samples.yml @@ -128,24 +128,7 @@ jobs: env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.TEST_LOCALSTACK_AUTH_TOKEN }} - - name: Docker state snapshot - # Capture the full Docker state on failure - if: failure() - run: | - echo "=== All Docker containers (running + stopped) ===" - docker ps -a --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}" 2>&1 - echo "" - echo "=== Docker images ===" - docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}\t{{.ID}}" 2>&1 - echo "" - echo "=== Exited container logs ===" - for c in $(docker ps -a --filter "status=exited" --format "{{.Names}}" 2>/dev/null); do - echo "--- [$c] (last 50 lines) ---" - docker logs "$c" --tail 50 2>&1 - done - - name: Get LocalStack Logs # Captured on failure or success to provide a detailed audit trail of the emulator's activity. if: always() run: make logs - diff --git a/requirements-runtime.txt b/requirements-runtime.txt index 573e0d0..6ede92c 100644 --- a/requirements-runtime.txt +++ b/requirements-runtime.txt @@ -9,4 +9,3 @@ azure-core python-dotenv localstack azlocal -terraform-local diff --git a/run-samples.sh b/run-samples.sh index b5a5080..9503839 100644 --- a/run-samples.sh +++ b/run-samples.sh @@ -94,7 +94,7 @@ TERRAFORM_SAMPLES=( # 3b. Define Bicep Samples BICEP_SAMPLES=( - #"samples/web-app-sql-database/python/bicep|bash deploy.sh" + "samples/web-app-sql-database/python/bicep|bash deploy.sh" "samples/function-app-managed-identity/python/bicep|bash deploy.sh" "samples/function-app-storage-http/dotnet/bicep|bash deploy.sh" "samples/web-app-cosmosdb-mongodb-api/python/bicep|bash deploy.sh" @@ -103,8 +103,7 @@ BICEP_SAMPLES=( # 4. Calculate Shard # Combine script-based, Terraform, and Bicep samples into one array -#ALL_SAMPLES=("${SAMPLES[@]}" "${TERRAFORM_SAMPLES[@]}" "${BICEP_SAMPLES[@]}") -ALL_SAMPLES=("${SAMPLES[@]}") +ALL_SAMPLES=("${SAMPLES[@]}" "${TERRAFORM_SAMPLES[@]}" "${BICEP_SAMPLES[@]}") TOTAL=${#ALL_SAMPLES[@]} SHARD=${1:-1} SPLITS=${2:-1} @@ -146,33 +145,29 @@ for (( i=START; i/dev/null 2>&1; then - echo "Deleting all resource groups..." - # List and delete all resource groups - RG_LIST=$(azlocal group list --query "[].name" -o tsv 2>/dev/null || echo "") - if [[ -n "$RG_LIST" ]]; then - echo "$RG_LIST" | while read -r rg; do - if [[ -n "$rg" ]]; then - echo " - Deleting resource group: $rg" - azlocal group delete --name "$rg" --yes --no-wait 2>/dev/null || true - fi - done - # Wait a bit for deletions to process - sleep 2 - else - echo " No resource groups to clean up" - fi - fi fi popd > /dev/null echo "Completed: $path" + # Clean up Azure resources to prevent state pollution between tests + echo "Cleaning up Azure resources in LocalStack..." + if command -v azlocal >/dev/null 2>&1; then + RG_LIST=$(azlocal group list --query "[].name" -o tsv 2>/dev/null || echo "") + if [[ -n "$RG_LIST" ]]; then + echo "$RG_LIST" | while read -r rg; do + if [[ -n "$rg" ]]; then + echo " - Deleting resource group: $rg" + azlocal group delete --name "$rg" --yes --no-wait 2>/dev/null || true + fi + doneclear + sleep 2 + else + echo " No resource groups to clean up" + fi + fi + # Cleanup Docker resources after each test to free up disk space echo "Cleaning up Docker resources..." docker system prune -af --volumes || true From e2e274ce20f81a7d121f1c12a643d551595a8646 Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Fri, 20 Feb 2026 10:09:25 +0000 Subject: [PATCH 10/12] remove terraform-local check --- run-samples.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-samples.sh b/run-samples.sh index 9503839..8c2b77f 100644 --- a/run-samples.sh +++ b/run-samples.sh @@ -32,7 +32,7 @@ command -v localstack >/dev/null 2>&1 || { echo >&2 "localstack CLI is required command -v az >/dev/null 2>&1 || { echo >&2 "az CLI is required but not installed. Aborting."; exit 1; } command -v azlocal >/dev/null 2>&1 || { echo >&2 "azlocal is required but not installed. Run 'pip install azlocal'. Aborting."; exit 1; } command -v funclocal >/dev/null 2>&1 || { echo >&2 "funclocal is required but not installed. Run 'pip install azlocal'. Aborting."; exit 1; } -command -v tflocal >/dev/null 2>&1 || { echo >&2 "tflocal is required but not installed. Run 'pip install terraform-local'. Aborting."; exit 1; } +#command -v tflocal >/dev/null 2>&1 || { echo >&2 "tflocal is required but not installed. Run 'pip install terraform-local'. Aborting."; exit 1; } command -v terraform >/dev/null 2>&1 || { echo >&2 "terraform CLI is required but not installed. Aborting."; exit 1; } command -v func >/dev/null 2>&1 || { echo >&2 "Azure Functions Core Tools (func) is required but not installed. Aborting."; exit 1; } From d66d1ac77fa58e902ccec9535462305b64fae4f0 Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Fri, 20 Feb 2026 10:14:58 +0000 Subject: [PATCH 11/12] syntax fix --- run-samples.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-samples.sh b/run-samples.sh index 8c2b77f..56cddce 100644 --- a/run-samples.sh +++ b/run-samples.sh @@ -161,7 +161,7 @@ for (( i=START; i/dev/null || true fi - doneclear + done sleep 2 else echo " No resource groups to clean up" From 99b52e2eec04cd4922881ccafdcc063edd3ae00a Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Fri, 20 Feb 2026 13:39:49 +0000 Subject: [PATCH 12/12] restore commented line --- run-samples.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-samples.sh b/run-samples.sh index 56cddce..08e33cb 100644 --- a/run-samples.sh +++ b/run-samples.sh @@ -94,7 +94,7 @@ TERRAFORM_SAMPLES=( # 3b. Define Bicep Samples BICEP_SAMPLES=( - "samples/web-app-sql-database/python/bicep|bash deploy.sh" + #"samples/web-app-sql-database/python/bicep|bash deploy.sh" "samples/function-app-managed-identity/python/bicep|bash deploy.sh" "samples/function-app-storage-http/dotnet/bicep|bash deploy.sh" "samples/web-app-cosmosdb-mongodb-api/python/bicep|bash deploy.sh"