Skip to content

Commit 2f6c9b8

Browse files
Add basic health check route for kubernetes (#89)
* Add basic k8s health check --------- Co-authored-by: Oliver Silvester <[email protected]>
1 parent fc4a119 commit 2f6c9b8

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/daq_config_server/app.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,13 @@ def get_configuration(
102102
return Response(content=content, media_type=ValidAcceptHeaders.RAW_BYTES)
103103

104104

105+
@app.get("/healthz")
106+
def health_check():
107+
"""
108+
Kubernetes health check
109+
"""
110+
return Response()
111+
112+
105113
def main():
106114
uvicorn.run(app="daq_config_server.app:app", host="0.0.0.0", port=8555)

src/daq_config_server/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
@dataclass(frozen=True)
55
class ENDPOINTS:
66
CONFIG = "/config"
7+
HEALTH = "/healthz"

tests/unit_tests/test_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,9 @@ async def test_get_configuration_warns_and_uses_raw_bytes_on_failed_utf_8_encodi
125125
accept_header={"Accept": ValidAcceptHeaders.PLAIN_TEXT},
126126
)
127127
mock_warn.assert_called_once()
128+
129+
130+
async def test_health_check_returns_code_200(
131+
mock_app: TestClient,
132+
):
133+
assert mock_app.get(ENDPOINTS.HEALTH).status_code == status.HTTP_200_OK

0 commit comments

Comments
 (0)