Add dedicated /ready endpoint#4445
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new /api/v1/ready readiness endpoint that checks database connectivity by querying the last used auction ID. However, the implementation incorrectly replaces the existing /api/v1/version endpoint in the E2E test setup. This causes the get_api_version helper to query the readiness endpoint instead, which will break tests expecting the version string. The reviewer recommends keeping both endpoint constants and restoring the version endpoint for the version helper.
| pub const AUCTION_ENDPOINT: &str = "/api/v1/auction"; | ||
| pub const TRADES_ENDPOINT: &str = "/api/v1/trades"; | ||
| pub const VERSION_ENDPOINT: &str = "/api/v1/version"; | ||
| pub const READY_ENDPOINT: &str = "/api/v1/ready"; |
There was a problem hiding this comment.
The /api/v1/version endpoint is still active in the router, so VERSION_ENDPOINT should not be replaced. Keep both VERSION_ENDPOINT and READY_ENDPOINT constants.
| pub const READY_ENDPOINT: &str = "/api/v1/ready"; | |
| pub const VERSION_ENDPOINT: &str = "/api/v1/version"; | |
| pub const READY_ENDPOINT: &str = "/api/v1/ready"; |
| let response = self | ||
| .http | ||
| .get(format!("{API_HOST}{VERSION_ENDPOINT}")) | ||
| .get(format!("{API_HOST}{READY_ENDPOINT}")) |
There was a problem hiding this comment.
The get_api_version helper is intended to retrieve the API version string from /api/v1/version. Changing this to READY_ENDPOINT will cause it to query /api/v1/ready (which returns an empty body), breaking the helper's functionality and any tests asserting on the version string.
| .get(format!("{API_HOST}{READY_ENDPOINT}")) | |
| .get(format!("{API_HOST}{VERSION_ENDPOINT}")) |
Description
Currently we are getting a few alerts complaining about high p95 latency on the
/auctionendpoint. This endpoint is quite heavy because it returns the full auction. Additionally we are currently using it for a readiness probe so it gets queried every 5s.It makes sense to phase out this endpoint entirely as it's no longer needed (driver forwards auctions fast enough, shadow competition can be updated to read the data from the DB directly).
Changes
As a first migration step this PR introduces a new
/readyendpoint which only fetches the most recently used auction id. To stay mostly consistent with the current/auctionendpoint while being a lot more lighweight.How to test
Adjusted the existing e2e test to use this new readiness probe in the setup step.