feat: Add authenticated database readiness check based on driver session metadata - #2527
feat: Add authenticated database readiness check based on driver session metadata#2527erichare wants to merge 15 commits into
Conversation
Unit Test Coverage Report
|
Integration Test Coverage Report (dse69-it)
|
Integration Test Coverage Report (hcd-it)
|
amorton
left a comment
There was a problem hiding this comment.
-1 this only works in non-astra, uses blocking IO, and reads from a non replicated table so why the C* node will need to be marked as UP to respond it will not verify that its able to communicate with enough nodes to achieve quourm
need to rethink what we are trying to do here
|
this needs a rethink about what we are trying to do |
understood! i'll address the specific comments you made just for the practice, but yeah understood about rethinking the purpose |
|
Okay, @amorton , so here's what i did... First of all, renamed the endpoint to The endpoint executes Switched everything to async, response would look like I'll push shortly |
Add check when creating a new CqlSession that it has Metadata so we know what keyspaces/tables in the DB. See comments in CqlSessionFactory
f9b504e to
aa3031a
Compare
📈 Unit Test Coverage Delta vs Main Branch
|
📈 Integration Test Coverage Delta vs Main Branch (dse69-it)
|
📈 Integration Test Coverage Delta vs Main Branch (hcd-it)
|
Replace the datastax_sla.check canary query with a check of the driver session metadata: the pod is ready when the session obtained through the normal session cache reports at least one UP node. No query is issued and no canary table needs to be provisioned. Add stargate.jsonapi.operations.database-config.require-session-node-metadata (default false): when enabled, CqlSessionFactory rejects a newly built session whose metadata contains no nodes, closing it and failing creation with the standard FAILED_TO_CONNECT_TO_DATABASE error so an unusable session is never cached.
5be2ec1 to
e84e3c7
Compare
What this PR does:
Adds
GET /v1/health/ready, an authenticated readiness endpoint for both Astra and Cassandra.CQLSessionCacheusing the request's tenant, token, and User-Agent, and reportsUPwhen the session's driver metadata has anUPnode. No query is issued and no canary table is needed — a pod that cannot connect fails session creation and reportsDOWN.stargate.jsonapi.operations.sla-user-agent) so probe sessions get the shorter SLA cache TTL. Fails closed if it is unset.{"status":"UP"}, 401 invalid auth, 403 wrong User-Agent, 503{"status":"DOWN"}. Fully async with a 5s timeout. Readiness polling is excluded from tenant request metrics.This also means a probe token that authenticates but cannot read the schema makes the endpoint report
DOWNrather than an auth error.Which issue(s) this PR fixes:
Fixes #2526
Validation:
SessionEvictionIntegrationTestextended to assert readinessUP,DOWN,UPacross a container outage.Checklist