Skip to content

Decouple /livez endpoint from the database#7722

Open
dkliban wants to merge 1 commit into
pulp:mainfrom
dkliban:decouple-livez-from-db
Open

Decouple /livez endpoint from the database#7722
dkliban wants to merge 1 commit into
pulp:mainfrom
dkliban:decouple-livez-from-db

Conversation

@dkliban
Copy link
Copy Markdown
Member

@dkliban dkliban commented May 15, 2026

Summary

  • Add skip_domain_middleware = True flag to LivezView
  • Teach DomainMiddleware.process_view() to skip Domain.objects.get() when the flag is set
  • The /livez probe now returns 200 even when the database is unavailable

Other middleware (SessionMiddleware, AuthenticationMiddleware) are lazy and don't hit the DB for /livez since authentication_classes and permission_classes are both empty and request.user/request.session are never accessed. DomainMiddleware was the only eager DB dependency.

Fixes #7721

Test plan

  • Existing /livez test passes (test_status.py)
  • /livez returns 200 when database is stopped (manual verification)

@dkliban dkliban force-pushed the decouple-livez-from-db branch from 9fd722d to 17db62d Compare May 15, 2026 02:01
Comment thread CHANGES/7721.bugfix Outdated
Comment on lines +1 to +3
Decoupled the ``/livez`` liveness probe from the database by skipping
``DomainMiddleware``'s ``Domain.objects.get()`` lookup, so the probe returns
200 even when the database is unavailable.
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.

Shorten this to one line and use single tick marks.

DomainMiddleware.process_view() runs Domain.objects.get() on every
request, including /livez/. This causes the liveness probe to fail
when the database is unavailable, triggering cascading pod restarts.

Add a skip_domain_middleware flag to LivezView and honour it in
DomainMiddleware so the probe depends only on the gunicorn worker
being alive.

Fixes pulp#7721

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dkliban dkliban force-pushed the decouple-livez-from-db branch from 17db62d to 51d503d Compare May 15, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decouple /livez endpoint from the database

2 participants