multitenant: always return 200 on fake health.check tenant (#34773)

This commit is contained in:
Frédéric Péters 2019-07-11 23:02:59 +02:00
parent 02b1ef8c2e
commit 874130fde1
1 changed files with 6 additions and 1 deletions

View File

@ -5,7 +5,7 @@ import hashlib
from django.utils.encoding import smart_bytes
from django.conf import settings
from django.db import connection
from django.http import Http404, HttpResponseRedirect
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.contrib.contenttypes.models import ContentType
from tenant_schemas.utils import get_tenant_model, get_public_schema_name
@ -62,6 +62,11 @@ class TenantMiddleware(object):
connection.set_schema_to_public()
hostname_without_port = request.get_host().split(':')[0]
if hostname_without_port == 'health.check':
# allow for special health.check domain name for haproxy
# availability checks.
return HttpResponse('health ok', content_type='text/plain')
try:
request.tenant = self.get_tenant_by_hostname(hostname_without_port)
except TenantNotFound: