Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add health check endpoint #382

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pulsar/web/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from webob import exc

from pulsar import __version__ as pulsar_version
from pulsar.client.action_mapper import path_type
from pulsar.client.job_directory import verify_is_in_directory
from pulsar.manager_endpoint_util import (
Expand Down Expand Up @@ -224,6 +225,11 @@ def object_store_get_store_usage_percent(object_store):
return object_store.get_store_usage_percent()


@PulsarController(path="/healthz", method="GET", response_type='json')
def healthz():
return {'version': pulsar_version}


class PulsarDataset:
"""Intermediary between Pulsar and objectstore."""

Expand Down
7 changes: 7 additions & 0 deletions test/wsgi_app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import time
from urllib.parse import quote

from pulsar import __version__ as pulsar_version


def test_standard_requests():
""" Tests app controller methods. These tests should be
Expand Down Expand Up @@ -68,3 +70,8 @@ def test_upload(upload_type):
clean_response = app.delete("/jobs/%s" % job_id)
assert clean_response.body.decode("utf-8") == 'OK'
assert os.listdir(staging_directory) == []

# test healthz endpoint
healthz_response = app.get("/healthz")
healthz_data = json.loads(healthz_response.body.decode("utf-8"))
assert healthz_data["version"] == pulsar_version
Loading