Fix: main.py /api/operations now returns tracked instances, v1.0.38

This commit is contained in:
2026-07-25 09:02:02 +04:00
parent 8307308a0a
commit 9668f03d3e
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ from routes.main import bp as main_bp
from routes.api import bp as api_bp from routes.api import bp as api_bp
from routes.api_test import bp as api_test_bp from routes.api_test import bp as api_test_bp
VERSION = "1.0.37" VERSION = "1.0.38"
app = Flask(__name__, template_folder="templates", static_folder="static") app = Flask(__name__, template_folder="templates", static_folder="static")
app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-dev.ngcloud.ru/api/v1/svc") app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-dev.ngcloud.ru/api/v1/svc")
+9 -1
View File
@@ -3,6 +3,7 @@ from flask import Blueprint, current_app, render_template, request, make_respons
from api.http_client import HttpClient from api.http_client import HttpClient
from operations.get_instances import get_organization, get_instances from operations.get_instances import get_organization, get_instances
from operations.get_services import get_services, get_service_detail from operations.get_services import get_services, get_service_detail
from operations.tracker import list_all as tracker_list
from runner import load_config from runner import load_config
bp = Blueprint("main", __name__) bp = Blueprint("main", __name__)
@@ -118,6 +119,13 @@ def api_operations(svc_id):
client = HttpClient(current_app.config["NUBES_API_ENDPOINT"], active_token) client = HttpClient(current_app.config["NUBES_API_ENDPOINT"], active_token)
detail = get_service_detail(client, svc_id) detail = get_service_detail(client, svc_id)
ops = detail.get("operations", []) ops = detail.get("operations", [])
return jsonify({"svc": detail.get("svc", ""), "operations": ops}) # только отслеживаемые инстансы этого сервиса
tracked = tracker_list()
tracked_uids = {t["instanceUid"] for t in tracked if t["svcId"] == svc_id}
instances = get_instances(client)
svc_instances = [i for i in instances
if i.get("instanceUid") in tracked_uids
and i.get("explainedStatus") not in ("deleted", "not created")]
return jsonify({"svc": detail.get("svc", ""), "operations": ops, "instances": svc_instances})
except Exception as e: except Exception as e:
return jsonify({"error": str(e)}), 500 return jsonify({"error": str(e)}), 500