pulumi-django-azure 1.0.24__py3-none-any.whl → 1.0.25__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.

@@ -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
- settings.DATABASES["default"]["PASSWORD"] = get_db_password()
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
- redis_credentials = get_redis_credentials()
24
-
25
- # Re-authenticate the Redis connection
26
- redis_connection = get_redis_connection("default")
27
- redis_connection.execute_command("AUTH", redis_credentials.username, redis_credentials.password)
28
-
29
- settings.CACHES["default"]["OPTIONS"]["PASSWORD"] = redis_credentials.password
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pulumi-django-azure
3
- Version: 1.0.24
3
+ Version: 1.0.25
4
4
  Summary: Simply deployment of Django on Azure with Pulumi
5
5
  Author-email: Maarten Ureel <maarten@youreal.eu>
6
6
  License: MIT License
@@ -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=kOWtlY3kjmUgpTXjDhGIzNeJtBWjn8FRmGQRZqWsSG0,1589
4
+ pulumi_django_azure/middleware.py,sha256=aifo-Y8uksqNuIjTV9u_r4rMBczG-BNvOOGUx8j-v2E,2446
5
5
  pulumi_django_azure/settings.py,sha256=hC1to1sgKeA7Lw43PlCx4AJ1AOQLuXbAhDIprD3uKc8,5482
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.24.dist-info/licenses/LICENSE,sha256=NX2LN3U319Zaac8b7ZgfNOco_nTBbN531X_M_13niSg,1087
9
- pulumi_django_azure-1.0.24.dist-info/METADATA,sha256=yM_sCef90KAfykNnXKh0xdQ4LG64uYRk6AGBrHoYbNc,12537
10
- pulumi_django_azure-1.0.24.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
11
- pulumi_django_azure-1.0.24.dist-info/top_level.txt,sha256=MNPRJhq-_G8EMCHRkjdcb_xrqzOkmKogXUGV7Ysz3g0,20
12
- pulumi_django_azure-1.0.24.dist-info/RECORD,,
8
+ pulumi_django_azure-1.0.25.dist-info/licenses/LICENSE,sha256=NX2LN3U319Zaac8b7ZgfNOco_nTBbN531X_M_13niSg,1087
9
+ pulumi_django_azure-1.0.25.dist-info/METADATA,sha256=s6tFNR8gtweJKOzpO6sKkxLBoERTWIZFWWYS6YdlkY4,12537
10
+ pulumi_django_azure-1.0.25.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
11
+ pulumi_django_azure-1.0.25.dist-info/top_level.txt,sha256=MNPRJhq-_G8EMCHRkjdcb_xrqzOkmKogXUGV7Ysz3g0,20
12
+ pulumi_django_azure-1.0.25.dist-info/RECORD,,