Skip to content

Commit

Permalink
add version api endpoint to gateway (#1279)
Browse files Browse the repository at this point in the history
* add version api endpoint to gateway

Signed-off-by: Akihiko Kuroda <[email protected]>
  • Loading branch information
akihikokuroda authored Apr 9, 2024
1 parent 8defc50 commit cc078f1
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/update-component-versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
sed -i "s/tag: \"${OLDNUM}\"/tag: \"${NEWNUM}\"/" charts/quantum-serverless/values.yaml
sed -i "s/tag: \"${OLDNUM}-py39\"/tag: \"${NEWNUM}-py39\"/" charts/quantum-serverless/values.yaml
sed -i "s/ray-node:${OLDNUM}/ray-node:${NEWNUM}/" charts/quantum-serverless/values.yaml
sed -i "s/version: ${OLDNUM}/version: ${NEWNUM}/" charts/quantum-serverless/values.yaml
cd charts/quantum-serverless
helm dependency update
cd -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ spec:
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: VERSION
value: {{ .Values.global.version | quote }}
- name: DEBUG
value: {{ .Values.application.debug | quote }}
- name: DJANGO_SECRET_KEY
Expand Down
6 changes: 6 additions & 0 deletions charts/quantum-serverless/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# ===================
# Quantum Serverless Info
# ===================
global:
version: 0.9.0

# ===================
# Quantum Serverless configs
# ===================
Expand Down
1 change: 1 addition & 0 deletions gateway/main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from pathlib import Path
from utils import sanitize_file_path

RELEASE_VERSION = os.environ.get("VERSION", "UNKNOWN")

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down
2 changes: 2 additions & 0 deletions gateway/main/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
import probes.views
import version.views

schema = get_schema_view( # pylint: disable=invalid-name
openapi.Info(
Expand All @@ -45,6 +46,7 @@
path("accounts/", include("allauth.urls")),
path("readiness/", probes.views.readiness, name="readiness"),
path("liveness/", probes.views.liveness, name="liveness"),
path("version/", version.views.version, name="version"),
path("", include("django_prometheus.urls")),
re_path(r"^api/v1/", include(("api.v1.urls", "api"), namespace="v1")),
# docs
Expand Down
14 changes: 14 additions & 0 deletions gateway/tests/version/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Test version."""

from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase


class TestProbes(APITestCase):
"""TestVersion."""

def test_version(self):
"""Tests version."""
jobs_response = self.client.get(reverse("version"))
self.assertEqual(jobs_response.status_code, status.HTTP_200_OK)
10 changes: 10 additions & 0 deletions gateway/version/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.http import HttpResponse
import json
import os
import requests
import main.settings


def version(request):
info = {"version": main.settings.RELEASE_VERSION}
return HttpResponse(json.dumps(info))

0 comments on commit cc078f1

Please sign in to comment.