Skip to content

FIX: fail the SQL Server readiness check when the container never starts - #722

Draft
Gaurav Sharma (bewithgaurav) wants to merge 1 commit into
mainfrom
bewithgaurav/fail-fast-sql-readiness-check
Draft

FIX: fail the SQL Server readiness check when the container never starts#722
Gaurav Sharma (bewithgaurav) wants to merge 1 commit into
mainfrom
bewithgaurav/fail-fast-sql-readiness-check

Conversation

@bewithgaurav

@bewithgaurav Gaurav Sharma (bewithgaurav) commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Work Item / Issue Reference

ADO Work Item: Fixed AB#47310


Summary

the macOS and code-coverage legs poll SQL Server for readiness in a loop whose exit status is the final sleep 2, so the step reports success even when every probe failed.

build 166760 hit this. the container died on startup, all 30 probes logged Error response from daemon: container ... is not running, the step still went green, and pytest then ran for 32.6 minutes against a database that did not exist, erroring on every db-backed test from the 1% mark while the non-db tests passed. the job was killed at the 60 minute default timeout. a dead container should fail in about a minute with a clear message, not surface as half an hour of test errors.

both loops now track readiness in a flag, re-probe once after the loop in case SQL came up during the final sleep, and exit 1 with docker logs --tail 200 when it never became ready.

the six linux legs use the same loop shape but end the step with CREATE DATABASE TestDB, so a dead container already fails them through that command's exit status. left alone.

verified against real containers locally: a dead container exits 1 where the old loop exits 0, a healthy container is unaffected, and a container that only becomes reachable after the loop is rescued by the re-probe. healthy macOS runs use 3 to 6 of the 30 attempts, so the gate keeps roughly 5x headroom.

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>
@github-actions github-actions Bot added the pr-size: small Minimal code update label Aug 14, 2026
# one last probe, in case it came up during the final sleep
docker exec sqlserver \
/opt/mssql-tools18/bin/sqlcmd \
-S localhost \
# one last probe, in case it came up during the final sleep
docker exec sqlserver \
/opt/mssql-tools18/bin/sqlcmd \
-S localhost \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: small Minimal code update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants