Skip to content

CHORE: Flaky Setup - Fail SQL Server setup loudly and dump container logs on every CI leg - #722

Open
Gaurav Sharma (bewithgaurav) wants to merge 6 commits into
mainfrom
bewithgaurav/fail-fast-sql-readiness-check
Open

CHORE: Flaky Setup - Fail SQL Server setup loudly and dump container logs on every CI leg#722
Gaurav Sharma (bewithgaurav) wants to merge 6 commits 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

when SQL Server fails to come up in CI, the pipeline either does not fail at all or fails without saying why. this makes all eight readiness loops behave the same way.

two of the eight never failed. the macOS one and the CodeCoverageReport one polled in a loop whose exit status is the final sleep 2, so the step reported success even when every probe failed. build 166760 hit this on macOS: the container died on startup, all 30 probes logged container ... is not running, the step went green, and pytest then ran 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. #723 has since fixed the macOS half as part of the setup parallelization, so what is left here is CodeCoverageReport.

the other six linux distro legs do fail, through CREATE DATABASE TestDB right after the loop, but you only get a sqlcmd connect error. nothing anywhere in the pipeline captures docker logs, so when the container exits on its own (SA password policy, EULA, OOM, port already bound) the reason is never recorded. that is why 166760's root cause is still unknown.

every site now tracks readiness in a flag, probes once more after the loop, and on failure prints the attempt count followed by docker logs --tail 200 before exiting non-zero. the extra probe matters because the loop sleeps after its final attempt, so SQL can become reachable in that window and would otherwise be called a hard failure.

verified locally against real containers: a container that prints a startup error and exits now surfaces that error instead of only the connect failure, a healthy container is unaffected, and a container that becomes reachable only 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 and no green run changes behaviour.

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
Comment thread eng/pipelines/pr-validation-pipeline.yml Fixed
Comment thread eng/pipelines/pr-validation-pipeline.yml Fixed
@bewithgaurav Gaurav Sharma (bewithgaurav) changed the title FIX: fail the SQL Server readiness check when the container never starts CHORE: Flaky Setup - Fail job at the SQL Server readiness check on macOS Aug 17, 2026
@bewithgaurav
Gaurav Sharma (bewithgaurav) marked this pull request as ready for review August 17, 2026 06:43
Copilot AI lite review requested due to automatic review settings August 17, 2026 06:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a flaky SQL Server readiness gate in the Azure Pipelines validation workflow (macOS and code-coverage legs) where the step could incorrectly succeed even if all readiness probes failed, causing long-running pytest failures against a non-existent DB.

Changes:

  • Track SQL Server readiness via a sql_ready flag instead of relying on the loop’s final command exit status.
  • Add a final “one last probe” after the loop to handle the case where SQL becomes reachable during the last sleep interval.
  • Fail fast with a clear error and include docker logs --tail 200 output when SQL Server never becomes ready.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

82%


📈 Total Lines Covered: 7751 out of 9430
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

No lines with coverage information in this diff.


📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.pybind.ddbc_bindings.h: 61.5%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 75.5%
mssql_python.__init__.py: 77.6%
mssql_python.row.py: 77.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 81.4%
mssql_python.pybind.connection.connection.cpp: 84.3%
mssql_python.logging.py: 85.5%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

Copilot AI and others added 3 commits August 17, 2026 12:55
…t-sql-readiness-check

# Conflicts:
#	eng/pipelines/pr-validation-pipeline.yml
the macOS setup_sql readiness loop reports that SQL never came up but not why, because sqlcmd only tells you the client could not connect. when the container itself exited (password policy, EULA, OOM, port clash) the reason is only in the container's own log, so dump docker logs on the failure path. also probe once more after the loop: the loop sleeps after its final attempt, so SQL can become reachable in that window and would otherwise be reported as a hard failure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bewithgaurav Gaurav Sharma (bewithgaurav) changed the title CHORE: Flaky Setup - Fail job at the SQL Server readiness check on macOS FIX: surface container logs and re-probe once when macOS SQL setup fails Aug 17, 2026
Comment thread eng/pipelines/pr-validation-pipeline.yml Dismissed
extends the macOS change to the remaining seven readiness loops. the CodeCoverageReport loop had the same silent-success shape as macOS did: its exit status is the final sleep, so a dead container let the step pass. the six linux distro legs already failed through CREATE DATABASE, but only as an opaque sqlcmd error with no container log. all eight sites now share one shape: track readiness in a flag, probe once more after the loop, and on failure print the attempt count plus docker logs before exiting non-zero.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added pr-size: medium Moderate update size and removed pr-size: small Minimal code update labels Aug 17, 2026
@bewithgaurav Gaurav Sharma (bewithgaurav) changed the title FIX: surface container logs and re-probe once when macOS SQL setup fails FIX: fail SQL Server setup loudly and dump container logs on every CI leg Aug 17, 2026
Comment thread eng/pipelines/pr-validation-pipeline.yml Dismissed
Comment thread eng/pipelines/pr-validation-pipeline.yml Dismissed
Comment thread eng/pipelines/pr-validation-pipeline.yml Dismissed
Comment thread eng/pipelines/pr-validation-pipeline.yml Dismissed
Comment thread eng/pipelines/pr-validation-pipeline.yml Dismissed
Comment thread eng/pipelines/pr-validation-pipeline.yml Dismissed
Comment thread eng/pipelines/pr-validation-pipeline.yml Dismissed
@bewithgaurav Gaurav Sharma (bewithgaurav) changed the title FIX: fail SQL Server setup loudly and dump container logs on every CI leg CHORE: Flaky Setup - Fail SQL Server setup loudly and dump container logs on every CI leg Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: medium Moderate update size

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants