v1.0.48: tracker_add sync before thread (Sonnet fix); log is_ok; flexbox buttons
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ from routes.main import bp as main_bp
|
||||
from routes.api import bp as api_bp
|
||||
from routes.api_test import bp as api_test_bp
|
||||
|
||||
VERSION = "1.0.47"
|
||||
VERSION = "1.0.48"
|
||||
|
||||
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")
|
||||
|
||||
+10
-6
@@ -111,6 +111,12 @@ def api_test():
|
||||
{"instanceOperationUid": op_uid, "svcOperationCfsParamId": int(pid), "paramValue": str(pval)})
|
||||
client.post(f"/instanceOperations/{op_uid}/run")
|
||||
|
||||
# Записать в трекер СРАЗУ, до фонового потока (поток может умереть под gunicorn)
|
||||
try:
|
||||
tracker_add(instance_uid, svc_id, display_name)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# фоном ждать завершения
|
||||
threading.Thread(target=_finish_op, args=(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, True), daemon=True).start()
|
||||
return jsonify({"status": "RUNNING", "opUid": op_uid, "instanceUid": instance_uid})
|
||||
@@ -173,12 +179,10 @@ def _finish_op(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_
|
||||
if dt_finish and str(dt_finish).strip():
|
||||
is_ok = op.get("isSuccessful")
|
||||
err = op.get("errorLog") or ""
|
||||
# Сначала трекер — чтобы UI при poll уже видел инстанс
|
||||
if is_ok:
|
||||
if is_create:
|
||||
tracker_add(instance_uid, svc_id, display_name)
|
||||
elif is_delete:
|
||||
tracker_remove(instance_uid)
|
||||
print(f"[DEBUG] _finish_op op_uid={op_uid} isSuccessful={is_ok!r}", flush=True)
|
||||
# tracker_add для create уже вызван синхронно в api_test()
|
||||
if is_ok and is_delete:
|
||||
tracker_remove(instance_uid)
|
||||
_op_results[op_uid] = {
|
||||
"status": "OK" if is_ok else "FAIL",
|
||||
"error": str(err) if err else "",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
.inst-item { cursor:pointer; display:flex; align-items:center; gap:6px; padding:4px 8px; font-size:12px; border-radius:4px; }
|
||||
.inst-item:hover, .inst-item.active { background:var(--brand-grey-light); }
|
||||
.inst-ops { display:none; margin-left:16px; }
|
||||
.inst-ops.open { display:block; }
|
||||
.inst-ops.open { display:flex; flex-wrap:wrap; gap:4px; padding:4px 0; }
|
||||
.btn-sm { height:24px; font-size:11px; padding:0 8px; }
|
||||
.param-row { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
|
||||
.param-row label { width:160px; font-size:11px; text-align:right; flex-shrink:0; }
|
||||
@@ -139,9 +139,7 @@ async function toggleInstance(iuid){
|
||||
const d=await r.json();
|
||||
const ops=d.operations.filter(o=>o.operation!=='reconcile'&&o.operation!=='create');
|
||||
opsEl.innerHTML=ops.map(o=>
|
||||
`<div class="inst-item" style="margin-left:0;">
|
||||
<button class="btn btn-sm" onclick="runOp('${o.operation}',${o.svcOperationId})">${o.operation}</button>
|
||||
</div>`
|
||||
`<button class="btn btn-sm" onclick="runOp('${o.operation}',${o.svcOperationId})">${o.operation}</button>`
|
||||
).join('');
|
||||
opsEl.classList.add('open');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user