Skip to content

Commit d2d8b65

Browse files
authored
Add /livez endpoint (#24)
* Bump version in uv.lock Signed-off-by: Lukas Puehringer <lukas.puehringer@eclipse-foundation.org> * Add /livez endpoint Add endpoint for kubernetes liveness probe, following kubernetes naming and implementation common practice. Note that PIA is ready as soon as it is live, this means that there is currently no need for a dedicated /readyz endpoint. Fixes #18 Signed-off-by: Lukas Puehringer <lukas.puehringer@eclipse-foundation.org> --------- Signed-off-by: Lukas Puehringer <lukas.puehringer@eclipse-foundation.org>
1 parent 54671df commit d2d8b65

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

pia/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ def _401(msg: str) -> NoReturn:
5555
)
5656

5757

58+
@app.get("/livez")
59+
async def livez():
60+
"""Kubernetes liveness probe."""
61+
return {"status": "ok"}
62+
63+
5864
@app.post("/v1/upload/sbom", status_code=status.HTTP_200_OK)
5965
async def upload_sbom(
6066
payload: PiaUploadPayload,

tests/test_main.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,12 @@ def test_upload_dt_error(
228228

229229
assert response.status_code == 502
230230
assert b"Failed to upload to DependencyTrack" in response.content
231+
232+
233+
class TestHealthEndpoints:
234+
"""Tests for k8s health endpoints."""
235+
236+
def test_liveness(self, client):
237+
response = client.get("/livez")
238+
assert response.status_code == 200
239+
assert response.json() == {"status": "ok"}

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)