Skip to content

Commit e26ff93

Browse files
nicobavcharn
authored andcommitted
feat: use django-helsinki-health-endpoints for readiness and healthz
django-health-check is replaced by django-helsinki-health-endpoints. Refs: KEH-242
1 parent baf998e commit e26ff93

11 files changed

Lines changed: 11 additions & 240 deletions

File tree

custom_health_checks/README.md

Lines changed: 0 additions & 64 deletions
This file was deleted.

custom_health_checks/__init__.py

Whitespace-only changes.

custom_health_checks/apps.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

custom_health_checks/backends.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

custom_health_checks/tests/test_backends.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

custom_health_checks/tests/test_healthz.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

custom_health_checks/views.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

palvelutarjotin/settings.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@
177177
COMMIT_HASH = env("OPENSHIFT_BUILD_COMMIT")
178178
VERSION = __version__
179179

180+
# Django helsinki health endpoints
181+
SENTRY_RELEASE = env("SENTRY_RELEASE")
182+
180183
SENTRY_TRACES_SAMPLE_RATE = env("SENTRY_TRACES_SAMPLE_RATE")
181184
SENTRY_TRACES_IGNORE_PATHS = env.list("SENTRY_TRACES_IGNORE_PATHS")
182185

@@ -199,7 +202,7 @@ def sentry_traces_sampler(sampling_context: SamplingContext) -> float:
199202
sentry_sdk.init(
200203
dsn=env("SENTRY_DSN"),
201204
environment=env("SENTRY_ENVIRONMENT"),
202-
release=env("SENTRY_RELEASE"),
205+
release=SENTRY_RELEASE,
203206
integrations=[DjangoIntegration()],
204207
traces_sampler=sentry_traces_sampler,
205208
profile_session_sample_rate=env("SENTRY_PROFILE_SESSION_SAMPLE_RATE"),
@@ -249,9 +252,8 @@ def sentry_traces_sampler(sampling_context: SamplingContext) -> float:
249252
"auditlog",
250253
"auditlog_extra",
251254
"resilient_logger",
252-
"health_check",
255+
"helsinki_health_endpoints",
253256
# local apps under this line
254-
"custom_health_checks",
255257
"utils",
256258
"organisations",
257259
"occurrences",

palvelutarjotin/urls.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@
22
from csp.decorators import csp_update
33
from django.conf import settings
44
from django.conf.urls.static import static
5-
from django.http import JsonResponse
65
from django.urls import include, path, re_path
76
from django.utils.translation import gettext
87
from django.views.decorators.csrf import csrf_exempt
9-
from django.views.decorators.http import require_http_methods
108
from drf_spectacular.views import (
119
SpectacularAPIView,
1210
SpectacularRedocView,
1311
)
1412
from helusers.admin_site import admin
1513

1614
from common.utils import get_api_version
17-
from custom_health_checks.views import HealthCheckJSONView
18-
from palvelutarjotin import __version__
1915
from palvelutarjotin.views import SentryGraphQLView
2016

2117
admin.site.index_title = " ".join([gettext("Kultus API"), get_api_version()])
@@ -57,25 +53,8 @@ def graphql_view(request, *args, **kwargs):
5753
]
5854

5955

60-
#
6156
# Kubernetes liveness & readiness probes
62-
#
63-
@require_http_methods(["GET", "HEAD"])
64-
def readiness(*args, **kwargs):
65-
response_json = {
66-
"status": "ok",
67-
"release": settings.APP_RELEASE,
68-
"packageVersion": __version__,
69-
"commitHash": settings.COMMIT_HASH,
70-
"buildTime": settings.APP_BUILD_TIME.strftime("%Y-%m-%dT%H:%M:%S.000Z"),
71-
}
72-
return JsonResponse(response_json, status=200)
73-
74-
75-
urlpatterns += [
76-
path(r"healthz", HealthCheckJSONView.as_view(), name="healthz"),
77-
path("readiness", readiness),
78-
]
57+
urlpatterns += [path("", include("helsinki_health_endpoints.urls"))]
7958

8059

8160
if settings.DEBUG:

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ django-csp
99
django-environ
1010
django-filter
1111
django-graphql-jwt
12-
django-health-check
1312
django-helusers
13+
django-helsinki-health-endpoints
1414
django-ilmoitin
1515
django-ipware
1616
django-logger-extra

0 commit comments

Comments
 (0)