From 9e846f8fecbde8d924ea196357f09057860df65a Mon Sep 17 00:00:00 2001 From: Gaurav Sharma <223556219+Copilot@users.noreply.github.com> Date: Fri, 14 Aug 2026 17:33:00 +0530 Subject: [PATCH] FIX: fail the SQL Server readiness check when the container never starts the macOS and code-coverage legs poll SQL Server in a loop whose exit status is the final sleep, so the step reported success even when every probe failed. a dead container then surfaced as 30+ minutes of pytest errors instead of an infra failure. both loops now track readiness in a flag, re-probe once after the loop, and exit 1 with container logs when SQL never came up. the six linux legs end their step with CREATE DATABASE, whose exit status already fails them, so they are left alone. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- eng/pipelines/pr-validation-pipeline.yml | 42 +++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/eng/pipelines/pr-validation-pipeline.yml b/eng/pipelines/pr-validation-pipeline.yml index f0323fb0..59ab1922 100644 --- a/eng/pipelines/pr-validation-pipeline.yml +++ b/eng/pipelines/pr-validation-pipeline.yml @@ -516,15 +516,32 @@ jobs: -d $(sqlServerImage) # Starting SQL Server container… + sql_ready=false for i in {1..30}; do - docker exec sqlserver \ + if docker exec sqlserver \ /opt/mssql-tools18/bin/sqlcmd \ -S localhost \ -U SA \ -P "$DB_PASSWORD" \ - -C -Q "SELECT 1" && break + -C -Q "SELECT 1"; then + sql_ready=true + break + fi sleep 2 done + if [ "$sql_ready" != true ]; then + # one last probe, in case it came up during the final sleep + docker exec sqlserver \ + /opt/mssql-tools18/bin/sqlcmd \ + -S localhost \ + -U SA \ + -P "$DB_PASSWORD" \ + -C -Q "SELECT 1" || { + echo "SQL Server did not become ready after 30 attempts" + docker logs --tail 200 sqlserver || true + exit 1 + } + fi displayName: 'Pull & start SQL Server (Docker)' env: DB_PASSWORD: $(DB_PASSWORD) @@ -2454,15 +2471,32 @@ jobs: -d mcr.microsoft.com/mssql/server:2022-latest # Wait until SQL Server is ready + sql_ready=false for i in {1..30}; do - docker exec sqlserver \ + if docker exec sqlserver \ /opt/mssql-tools18/bin/sqlcmd \ -S localhost \ -U SA \ -P "$(DB_PASSWORD)" \ - -C -Q "SELECT 1" && break + -C -Q "SELECT 1"; then + sql_ready=true + break + fi sleep 2 done + if [ "$sql_ready" != true ]; then + # one last probe, in case it came up during the final sleep + docker exec sqlserver \ + /opt/mssql-tools18/bin/sqlcmd \ + -S localhost \ + -U SA \ + -P "$(DB_PASSWORD)" \ + -C -Q "SELECT 1" || { + echo "SQL Server did not become ready after 30 attempts" + docker logs --tail 200 sqlserver || true + exit 1 + } + fi displayName: 'Start SQL Server container' env: DB_PASSWORD: $(DB_PASSWORD)