Reviewed-on: #17 Reviewed-by: sundapeng <sundp@mail.zgclab.edu.cn> Reviewed-by: xuxt <xuxt@zgclab.edu.cn>
25 lines
801 B
Python
25 lines
801 B
Python
from __future__ import annotations
|
|
|
|
from flask import Flask, jsonify
|
|
|
|
from .config import AppConfig
|
|
from .nodes_api import create_nodes_blueprint
|
|
from .scheduler import StatusScheduler
|
|
from .storage import Storage
|
|
|
|
|
|
def register_routes(app: Flask, storage: Storage, scheduler: StatusScheduler, config: AppConfig) -> None:
|
|
app.register_blueprint(create_nodes_blueprint(storage, scheduler), url_prefix="/api/v1/master")
|
|
|
|
@app.get("/healthz")
|
|
def healthz():
|
|
return jsonify({"status": "ok"})
|
|
|
|
@app.get("/readyz")
|
|
def readyz():
|
|
try:
|
|
storage.list_nodes() # simple readiness probe
|
|
except Exception as exc: # pragma: no cover - defensive
|
|
return jsonify({"status": "error", "error": str(exc)}), 500
|
|
return jsonify({"status": "ok"})
|