Repository navigation
docs: document API health and readiness endpoints - #10
Closed
JacobusTheOne wants to merge 12 commits into
Closed
JacobusTheOne wants to merge 12 commits into
JacobusTheOne wants to merge 12 commits into
Conversation
The deploy job ran `az containerapp update --image`, which only patches the image. Bicep also declared the image, so the next template deployment rolled it back, and configuration the template declares (probes, identity) was never applied. Deploy api.bicep instead, passing the tag just pushed, so the template is the single source of truth. The template lives in the deployment repo, checked out with DEPLOY_REPO_TOKEN. Add /ready, which runs SELECT 1 and returns 503 when the database is unreachable. /health answers as soon as the process is listening, which is what a liveness probe wants, but using it for readiness tells the ingress a replica can serve /albums before SQL is reachable. The two probes are wired to the matching endpoints in api.bicep, with failureThreshold allowing a 60s grace period for a database resume. Liveness deliberately stays off the database so a transient SQL failure cannot restart an otherwise healthy replica. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
albumdb is serverless with a 60 minute auto-pause, so a container starting after an idle period hits a database that refuses connections for a minute or more while it resumes. Alembic opened that connection with no retry, so startup failed before migrations or seeding could run. Retry the connection Alembic actually goes on to use, rather than probing availability and then opening a second connection. Only the connect is retried: a failure in the caller's own work propagates untouched, because replaying a partially applied migration is more dangerous than failing loudly. Catch InterfaceError as well as OperationalError. A failed TCP connect surfaces as the latter, but pyodbc reports a login rejected by a resuming database as the former, which would otherwise escape the retry. Replaces wait_for_database, which was never called from anywhere. Needs the startup probe added to api.bicep in the deployment repo: the retry budget of roughly 134s exceeds the liveness budget of roughly 70s, so without it the platform restarts the container mid-resume and loops. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Document the /health endpoint and its liveness purpose.
Document the /ready endpoint and its database connectivity check.
Explain the distinction between liveness and readiness checks.
Testing
Reviewed endpoint implementations in src/app/main.py.
Verified documented HTTP status codes and JSON responses against the implementation.
git diff --check passed.