Fix/155 health check redis host - #384
Open
devikaviju wants to merge 7 commits into
Open
Conversation
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
The Redis probe read config fields that don't exist, so /health reported Redis as down even when it was fine. This points the probe at the field Settings actually defines.
Issue
Closes #155
Changes
api/routes/health.py: replacedredis.Redis(host=settings.redis_host, port=settings.redis_port, db=0, ...)withredis.Redis.from_url(settings.redis_url, decode_responses=True).Settingsdefinesredis_url, notredis_host/redis_port.tests/unit/test_health.py: new file, 4 unit tests for the Redis probe.Testing
make test-unit) — see note belowmake test-integration) — not runmake lint) — see note belowmake typecheck) — see note belowVerified manually against a running stack:
Before:
{"dependencies":{"postgres":"unhealthy","redis":"unhealthy","vector_db":"healthy"}}After:
{"dependencies":{"postgres":"unhealthy","redis":"healthy","vector_db":"healthy"}}The new tests fail 2/4 against the pre-fix code and pass 4/4 after.
Notes for Reviewers
Pre-existing failures.
make test-unitwas 53 failed / 375 passed before my changes and 53 failed / 379 passed after — the same 53 failures, plus my 4 new passes.make lintreports 182 pre-existing errors, all intests/unit/files I didn't touch.make typecheckfails on missing library stubs (PyPDF2, jose, passlib, rank_bm25) before reaching my code. My new test file passes ruff and black cleanly. None of these are affected by this change.Why the bug was invisible. The probe's broad
except Exceptioncaught theAttributeErrorand set Redis to "unhealthy," so a config bug looked like an outage. Captured during the test run:redis_health_check_failed error="'Settings' object has no attribute 'redis_host'"Out of scope. Postgres also reports unhealthy, from a different cause —
await db.execute("SELECT 1")needstext()under SQLAlchemy 2.0. Left alone to keep this scoped to #155.