pulumi-django-azure 1.0.24__py3-none-any.whl → 1.0.26__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pulumi-django-azure might be problematic. Click here for more details.
- pulumi_django_azure/middleware.py +25 -9
- pulumi_django_azure/settings.py +2 -0
- {pulumi_django_azure-1.0.24.dist-info → pulumi_django_azure-1.0.26.dist-info}/METADATA +1 -1
- {pulumi_django_azure-1.0.24.dist-info → pulumi_django_azure-1.0.26.dist-info}/RECORD +7 -7
- {pulumi_django_azure-1.0.24.dist-info → pulumi_django_azure-1.0.26.dist-info}/WHEEL +1 -1
- {pulumi_django_azure-1.0.24.dist-info → pulumi_django_azure-1.0.26.dist-info}/licenses/LICENSE +0 -0
- {pulumi_django_azure-1.0.24.dist-info → pulumi_django_azure-1.0.26.dist-info}/top_level.txt +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
1
3
|
from django.conf import settings
|
|
2
4
|
from django.core.cache import cache
|
|
3
5
|
from django.db import connection
|
|
@@ -7,6 +9,8 @@ from django_redis import get_redis_connection
|
|
|
7
9
|
|
|
8
10
|
from .azure_helper import get_db_password, get_redis_credentials
|
|
9
11
|
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
10
14
|
|
|
11
15
|
class HealthCheckMiddleware:
|
|
12
16
|
def __init__(self, get_response):
|
|
@@ -16,28 +20,40 @@ class HealthCheckMiddleware:
|
|
|
16
20
|
if request.path == settings.HEALTH_CHECK_PATH:
|
|
17
21
|
# Update the database credentials if needed
|
|
18
22
|
if settings.AZURE_DB_PASSWORD:
|
|
19
|
-
|
|
23
|
+
try:
|
|
24
|
+
settings.DATABASES["default"]["PASSWORD"] = get_db_password()
|
|
25
|
+
except Exception as e:
|
|
26
|
+
logger.error("Failed to update database credentials: %s", str(e))
|
|
27
|
+
return HttpResponse(status=503)
|
|
20
28
|
|
|
21
29
|
# Update the Redis credentials if needed
|
|
22
30
|
if settings.AZURE_REDIS_CREDENTIALS:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
try:
|
|
32
|
+
redis_credentials = get_redis_credentials()
|
|
33
|
+
# Re-authenticate the Redis connection
|
|
34
|
+
redis_connection = get_redis_connection("default")
|
|
35
|
+
redis_connection.execute_command("AUTH", redis_credentials.username, redis_credentials.password)
|
|
36
|
+
settings.CACHES["default"]["OPTIONS"]["PASSWORD"] = redis_credentials.password
|
|
37
|
+
except Exception as e:
|
|
38
|
+
logger.error("Failed to update Redis credentials: %s", str(e))
|
|
39
|
+
return HttpResponse(status=503)
|
|
30
40
|
|
|
31
41
|
try:
|
|
32
42
|
# Test the database connection
|
|
33
43
|
connection.ensure_connection()
|
|
44
|
+
logger.debug("Database connection check passed")
|
|
34
45
|
|
|
35
46
|
# Test the Redis connection
|
|
36
47
|
cache.set("health_check", "test")
|
|
48
|
+
logger.debug("Redis connection check passed")
|
|
37
49
|
|
|
38
50
|
return HttpResponse("OK")
|
|
39
51
|
|
|
40
|
-
except OperationalError:
|
|
52
|
+
except OperationalError as e:
|
|
53
|
+
logger.error("Database connection failed: %s", str(e))
|
|
54
|
+
return HttpResponse(status=503)
|
|
55
|
+
except Exception as e:
|
|
56
|
+
logger.error("Health check failed with unexpected error: %s", str(e))
|
|
41
57
|
return HttpResponse(status=503)
|
|
42
58
|
|
|
43
59
|
return self.get_response(request)
|
pulumi_django_azure/settings.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
pulumi_django_azure/__init__.py,sha256=WoTHLNGnqc3dQoJtzrAJY8OVA7ReP6XFkDb9BXZGfJ8,117
|
|
2
2
|
pulumi_django_azure/azure_helper.py,sha256=HU0cb85jTeh70qjv11foWuqgE-SNQ21bhMKsy1lB7MM,1903
|
|
3
3
|
pulumi_django_azure/django_deployment.py,sha256=VL9MTEq5rDLGdJPDQWHHCGbeC3Taw7vnpq_DGoMA6Ec,49705
|
|
4
|
-
pulumi_django_azure/middleware.py,sha256=
|
|
5
|
-
pulumi_django_azure/settings.py,sha256=
|
|
4
|
+
pulumi_django_azure/middleware.py,sha256=aifo-Y8uksqNuIjTV9u_r4rMBczG-BNvOOGUx8j-v2E,2446
|
|
5
|
+
pulumi_django_azure/settings.py,sha256=wGeUW0GWMTLv0c2h3UHPPLUWfgjp7znfcfY33A26YS8,5526
|
|
6
6
|
pulumi_django_azure/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
pulumi_django_azure/management/commands/purge_cdn.py,sha256=1lZI5liDIiOGyJRmo9gRn-BDLHaRuipaUmUAm06bRr0,2093
|
|
8
|
-
pulumi_django_azure-1.0.
|
|
9
|
-
pulumi_django_azure-1.0.
|
|
10
|
-
pulumi_django_azure-1.0.
|
|
11
|
-
pulumi_django_azure-1.0.
|
|
12
|
-
pulumi_django_azure-1.0.
|
|
8
|
+
pulumi_django_azure-1.0.26.dist-info/licenses/LICENSE,sha256=NX2LN3U319Zaac8b7ZgfNOco_nTBbN531X_M_13niSg,1087
|
|
9
|
+
pulumi_django_azure-1.0.26.dist-info/METADATA,sha256=3TJ5sx7l3I0CTYnaM5gfwxnEX0bHQ6PCEr6m-qP92sE,12537
|
|
10
|
+
pulumi_django_azure-1.0.26.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
11
|
+
pulumi_django_azure-1.0.26.dist-info/top_level.txt,sha256=MNPRJhq-_G8EMCHRkjdcb_xrqzOkmKogXUGV7Ysz3g0,20
|
|
12
|
+
pulumi_django_azure-1.0.26.dist-info/RECORD,,
|
{pulumi_django_azure-1.0.24.dist-info → pulumi_django_azure-1.0.26.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|