Skip to content

Commit

Permalink
Add liveness & readiness probe for zero downtime deployments (#1148)
Browse files Browse the repository at this point in the history
* add liveness probe

* Add health endpoint and update path

* Add readinessProbe

* remove health path in probes

* remove health view and url path

* remove health path from auth bypass
  • Loading branch information
mitchdawson1982 authored Dec 6, 2024
1 parent d3298df commit fba5fb2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
4 changes: 1 addition & 3 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@
"REDIRECT_URI": os.environ.get("AZURE_REDIRECT_URI"),
"SCOPES": ["User.Read"],
"AUTHORITY": os.environ.get("AZURE_AUTHORITY"),
"PUBLIC_PATHS": [
"/metrics",
],
"PUBLIC_PATHS": ["/metrics"],
"USERNAME_ATTRIBUTE": "mail",
"USER_MAPPING_FN": "users.helper.user_mapping_fn",
}
Expand Down
20 changes: 20 additions & 0 deletions deployments/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ spec:
- name: http
containerPort: 8000
protocol: TCP
readinessProbe:
httpGet:
httpGet:
path: /
port: 8000
httpHeaders:
- name: Host
value: .service.justice.gov.uk
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 10
livenessProbe:
httpGet:
path: /
port: 8000
httpHeaders:
- name: Host
value: .service.justice.gov.uk
initialDelaySeconds: 40
periodSeconds: 60
env:
- name: ENV
value: "${ENV}"
Expand Down
5 changes: 3 additions & 2 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from urllib.parse import urlparse

from data_platform_catalogue.client.exceptions import EntityDoesNotExist
from data_platform_catalogue.entities import EntityTypes
from data_platform_catalogue.search_types import DomainOption
from django.conf import settings
from django.http import Http404, HttpResponse, HttpResponseBadRequest
from django.shortcuts import render
from django.utils.translation import gettext as _
from django.views.decorators.cache import cache_control

from data_platform_catalogue.entities import EntityTypes
from home.forms.search import SearchForm
from home.service.details import (
ChartDetailsService,
Expand All @@ -36,7 +36,7 @@
EntityTypes.CHART.url_formatted: ChartDetailsService,
EntityTypes.DASHBOARD.url_formatted: DashboardDetailsService,
EntityTypes.PUBLICATION_COLLECTION.url_formatted: PublicationCollectionDetailsService,
EntityTypes.PUBLICATION_DATASET.url_formatted: PublicationDatasetDetailsService
EntityTypes.PUBLICATION_DATASET.url_formatted: PublicationDatasetDetailsService,
}


Expand All @@ -63,6 +63,7 @@ def details_view(request, result_type, urn):

return render(request, service.template, service.context)


@cache_control(max_age=300, private=True)
def details_view_csv(request, result_type, urn) -> HttpResponse:
match result_type:
Expand Down

0 comments on commit fba5fb2

Please sign in to comment.