pulumi-django-azure 1.0.24__tar.gz → 1.0.25__tar.gz

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.

Files changed (18) hide show
  1. {pulumi_django_azure-1.0.24/src/pulumi_django_azure.egg-info → pulumi_django_azure-1.0.25}/PKG-INFO +1 -1
  2. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/pyproject.toml +2 -2
  3. pulumi_django_azure-1.0.25/src/pulumi_django_azure/middleware.py +59 -0
  4. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25/src/pulumi_django_azure.egg-info}/PKG-INFO +1 -1
  5. pulumi_django_azure-1.0.24/src/pulumi_django_azure/middleware.py +0 -43
  6. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/LICENSE +0 -0
  7. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/README.md +0 -0
  8. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/setup.cfg +0 -0
  9. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/src/pulumi_django_azure/__init__.py +0 -0
  10. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/src/pulumi_django_azure/azure_helper.py +0 -0
  11. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/src/pulumi_django_azure/django_deployment.py +0 -0
  12. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/src/pulumi_django_azure/management/commands/__init__.py +0 -0
  13. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/src/pulumi_django_azure/management/commands/purge_cdn.py +0 -0
  14. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/src/pulumi_django_azure/settings.py +0 -0
  15. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/src/pulumi_django_azure.egg-info/SOURCES.txt +0 -0
  16. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/src/pulumi_django_azure.egg-info/dependency_links.txt +0 -0
  17. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/src/pulumi_django_azure.egg-info/requires.txt +0 -0
  18. {pulumi_django_azure-1.0.24 → pulumi_django_azure-1.0.25}/src/pulumi_django_azure.egg-info/top_level.txt +0 -0
@@ -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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pulumi-django-azure"
7
- version = "1.0.24"
7
+ version = "1.0.25"
8
8
  description = "Simply deployment of Django on Azure with Pulumi"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Maarten Ureel", email = "maarten@youreal.eu" }]
@@ -37,7 +37,7 @@ Homepage = "https://gitlab.com/MaartenUreel/pulumi-django-azure"
37
37
 
38
38
  [tool.poetry]
39
39
  name = "pulumi-django-azure"
40
- version = "1.0.24"
40
+ version = "1.0.25"
41
41
  description = "Simply deployment of Django on Azure with Pulumi"
42
42
  authors = ["Maarten Ureel <maarten@youreal.eu>"]
43
43
 
@@ -0,0 +1,59 @@
1
+ import logging
2
+
3
+ from django.conf import settings
4
+ from django.core.cache import cache
5
+ from django.db import connection
6
+ from django.db.utils import OperationalError
7
+ from django.http import HttpResponse
8
+ from django_redis import get_redis_connection
9
+
10
+ from .azure_helper import get_db_password, get_redis_credentials
11
+
12
+ logger = logging.getLogger(__name__)
13
+
14
+
15
+ class HealthCheckMiddleware:
16
+ def __init__(self, get_response):
17
+ self.get_response = get_response
18
+
19
+ def __call__(self, request):
20
+ if request.path == settings.HEALTH_CHECK_PATH:
21
+ # Update the database credentials if needed
22
+ if settings.AZURE_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)
28
+
29
+ # Update the Redis credentials if needed
30
+ if settings.AZURE_REDIS_CREDENTIALS:
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)
40
+
41
+ try:
42
+ # Test the database connection
43
+ connection.ensure_connection()
44
+ logger.debug("Database connection check passed")
45
+
46
+ # Test the Redis connection
47
+ cache.set("health_check", "test")
48
+ logger.debug("Redis connection check passed")
49
+
50
+ return HttpResponse("OK")
51
+
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))
57
+ return HttpResponse(status=503)
58
+
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,43 +0,0 @@
1
- from django.conf import settings
2
- from django.core.cache import cache
3
- from django.db import connection
4
- from django.db.utils import OperationalError
5
- from django.http import HttpResponse
6
- from django_redis import get_redis_connection
7
-
8
- from .azure_helper import get_db_password, get_redis_credentials
9
-
10
-
11
- class HealthCheckMiddleware:
12
- def __init__(self, get_response):
13
- self.get_response = get_response
14
-
15
- def __call__(self, request):
16
- if request.path == settings.HEALTH_CHECK_PATH:
17
- # Update the database credentials if needed
18
- if settings.AZURE_DB_PASSWORD:
19
- settings.DATABASES["default"]["PASSWORD"] = get_db_password()
20
-
21
- # Update the Redis credentials if needed
22
- 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
30
-
31
- try:
32
- # Test the database connection
33
- connection.ensure_connection()
34
-
35
- # Test the Redis connection
36
- cache.set("health_check", "test")
37
-
38
- return HttpResponse("OK")
39
-
40
- except OperationalError:
41
- return HttpResponse(status=503)
42
-
43
- return self.get_response(request)