v1.0.97: fix save_run — user_email passed as param, not called in background thread

This commit is contained in:
2026-07-28 10:26:24 +04:00
parent be9e165b4f
commit f6598650b5
2 changed files with 7 additions and 8 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ 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
# Версия — меняется при КАЖДОМ изменении кода. Показывается в топбаре UI. # Версия — меняется при КАЖДОМ изменении кода. Показывается в топбаре UI.
VERSION = "1.0.96" VERSION = "1.0.97"
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-test.ngcloud.ru/api/v1/svc") app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-test.ngcloud.ru/api/v1/svc")
+6 -7
View File
@@ -234,7 +234,8 @@ def api_test():
client.post(f"/instanceOperations/{op_uid}/run") client.post(f"/instanceOperations/{op_uid}/run")
# фоном ждать завершения # фоном ждать завершения
threading.Thread(target=_finish_op, args=(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, True, get_client_id(), get_stand(), params), daemon=True).start() user_email = get_token_info().get("email", "")
threading.Thread(target=_finish_op, args=(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, True, get_client_id(), get_stand(), params, user_email), daemon=True).start()
return jsonify({"status": "RUNNING", "opUid": op_uid, "instanceUid": instance_uid, "displayName": display_name}) return jsonify({"status": "RUNNING", "opUid": op_uid, "instanceUid": instance_uid, "displayName": display_name})
else: else:
@@ -261,10 +262,10 @@ def api_test():
# фоном ждать завершения # фоном ждать завершения
is_delete = (op_name == "delete") is_delete = (op_name == "delete")
# Получить реальное имя инстанса из API (не UUID!)
if not display_name: if not display_name:
display_name = _get_instance_display_name(client, instance_uid) display_name = _get_instance_display_name(client, instance_uid)
threading.Thread(target=_finish_op, args=(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, False, get_client_id(), get_stand(), is_delete, params), daemon=True).start() user_email = get_token_info().get("email", "")
threading.Thread(target=_finish_op, args=(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, False, get_client_id(), get_stand(), is_delete, params, user_email), daemon=True).start()
return jsonify({"status": "RUNNING", "opUid": op_uid, "instanceUid": instance_uid, "displayName": display_name}) return jsonify({"status": "RUNNING", "opUid": op_uid, "instanceUid": instance_uid, "displayName": display_name})
except Exception as e: except Exception as e:
@@ -303,7 +304,7 @@ def _get_instance_display_name(client, instance_uid):
return instance_uid return instance_uid
def _finish_op(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, is_create, client_id, stand, is_delete=False, params=None): def _finish_op(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, is_create, client_id, stand, is_delete=False, params=None, user_email=""):
"""Фоном ждать dtFinish и сохранить результат.""" """Фоном ждать dtFinish и сохранить результат."""
import time import time
_cleanup_op_results() # очистить старые записи перед добавлением новой _cleanup_op_results() # очистить старые записи перед добавлением новой
@@ -344,10 +345,8 @@ def _finish_op(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_
# Сохранить в БД историю # Сохранить в БД историю
try: try:
from db.save_run import save_run from db.save_run import save_run
from api.auth import get_token_info
user = get_token_info()
save_run(client_id, stand, save_run(client_id, stand,
user.get("email", ""), user_email,
svc_id, op.get("svc", ""), op_name, svc_op_id, svc_id, op.get("svc", ""), op_name, svc_op_id,
op_uid, instance_uid, display_name, op_uid, instance_uid, display_name,
"OK" if is_ok else "FAIL", "OK" if is_ok else "FAIL",