Prepare rollback-safe legacy migration data contract (#7)
Unraid autoredeploy / Deploy vacatureradar (push) Failing after 20s

This commit was merged in pull request #7.
This commit is contained in:
2026-09-09 21:42:41 +00:00
parent 2d1964106b
commit 38e87678e1
10 changed files with 289 additions and 2 deletions
+24
View File
@@ -9,6 +9,30 @@ from django.shortcuts import redirect
from django.urls import reverse
from django.utils.http import url_has_allowed_host_and_scheme
from scripts.migration_worker_gate import hold_active
class MigrationMaintenanceMiddleware:
"""Block candidate traffic before durable migration activation, including GET writes."""
def __init__(self, get_response: Callable[[HttpRequest], HttpResponse]) -> None:
self.get_response = get_response
def __call__(self, request: HttpRequest) -> HttpResponse:
try:
held = hold_active()
except (OSError, RuntimeError):
held = True
health = request.method in {"GET", "HEAD"} and request.path_info in {
"/health/ready/", "/health/live/",
}
if held and not health:
response = JsonResponse({"error": "migration_maintenance"}, status=503)
response["Retry-After"] = "30"
response["Cache-Control"] = "no-store"
return response
return self.get_response(request)
class DemoReadOnlyMiddleware:
"""Prevent a shared public demo account from mutating application data."""