Skip to content

Commit 2c04868

Browse files
committed
Merge pull request #678 from kmala/healthz
fix(readinessprobe): container shouldn't be restarted if the database is unavailable
2 parents 4854e5e + bb09ceb commit 2c04868

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

rootfs/api/views.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
logger = logging.getLogger(__name__)
2727

2828

29-
class HealthCheckView(View):
29+
class ReadinessCheckView(View):
3030
"""
31-
Simple health check view to determine if the server
32-
is responding to HTTP requests and DB connection / query.
31+
Simple readiness check view to determine DB connection / query.
3332
"""
3433

3534
def get(self, request):
@@ -51,6 +50,17 @@ def get(self, request):
5150
head = get
5251

5352

53+
class LivenessCheckView(View):
54+
"""
55+
Simple liveness check view to determine if the server
56+
is responding to HTTP requests.
57+
"""
58+
59+
def get(self, request):
60+
return HttpResponse("OK")
61+
head = get
62+
63+
5464
class UserRegistrationViewSet(GenericViewSet,
5565
mixins.CreateModelMixin):
5666
"""ViewSet to handle registering new users. The logic is in the serializer."""

rootfs/deis/urls.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88

99
from django.conf.urls import include, url
10-
from api.views import HealthCheckView
10+
from api.views import LivenessCheckView
11+
from api.views import ReadinessCheckView
1112

1213
urlpatterns = [
13-
url(r'^healthz$', HealthCheckView.as_view()),
14+
url(r'^healthz$', LivenessCheckView.as_view()),
15+
url(r'^readiness$', ReadinessCheckView.as_view()),
1416
url(r'^v2/', include('api.urls')),
1517
]

0 commit comments

Comments
 (0)