Skip to content

Commit fb43642

Browse files
committed
feat(server): implement GET /api/health platform health/version route
Unauthenticated probe route per the addon-contract §4.8 interim spec (work item W7): 200 {"status": "ok", "platform_version": "<release>"}. platform_version is read from the root VERSION file (bumped to v0.5.0, served without the v prefix); consumers are examonctl plan/qualify. Both images bake VERSION in: the standalone image next to server.py, the compose image at EXAMON_HOME so the dev bind-mount cannot hide it.
1 parent 28badee commit fb43642

4 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎Dockerfile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ ADD ./publishers/random_pub ${EXAMON_HOME}/publishers/random_pub
77
ADD ./docker/examon/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
88
ADD ./scripts/examon.conf $EXAMON_HOME/scripts/examon.conf
99
ADD ./web $EXAMON_HOME/web
10+
# Platform release version served by /api/health; kept at EXAMON_HOME so the
11+
# compose bind-mount of web/examon-server does not hide it
12+
ADD ./VERSION $EXAMON_HOME/VERSION
1013

1114
# Venvs
1215
WORKDIR $EXAMON_HOME/scripts

‎VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.4.0
1+
v0.5.0

‎deploy/docker/examon-server/Dockerfile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ COPY web/examon-server/requirements.txt .
1010
RUN CASS_DRIVER_BUILD_CONCURRENCY=8 pip install --no-cache-dir -r requirements.txt
1111

1212
COPY web/examon-server/ .
13+
COPY VERSION .
1314

1415
EXPOSE 5000
1516

‎web/examon-server/server.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,32 @@ def localize_timestamps(df, tz):
250250
df[col] = df[col].dt.tz_convert(tz)
251251
return df
252252

253+
def _read_platform_version():
254+
"""Read the platform release version from the root VERSION file.
255+
256+
Looks next to this file first (standalone image bakes it in /app),
257+
then two levels up (repo root / legacy image EXAMON_HOME).
258+
"""
259+
base_dir = os.path.dirname(os.path.abspath(__file__))
260+
for candidate in (os.path.join(base_dir, 'VERSION'),
261+
os.path.abspath(os.path.join(base_dir, '..', '..', 'VERSION'))):
262+
try:
263+
with open(candidate) as f:
264+
version = f.read().strip()
265+
return version[1:] if version.startswith('v') else version
266+
except (IOError, OSError):
267+
continue
268+
return 'unknown'
269+
270+
271+
PLATFORM_VERSION = _read_platform_version()
272+
273+
274+
@app.route('/api/health')
275+
def health():
276+
return jsonify({'status': 'ok', 'platform_version': PLATFORM_VERSION}), 200
277+
278+
253279
@app.route('/')
254280
@auth.login_required
255281
def index():

0 commit comments

Comments
 (0)