Upraveno. Portál už neurčuje readiness podle job.status == success ani podle žádné Docker/group logiky.
Teď READY / NOT READY bere jen z explicitního výstupu skriptu uloženého v DB: result_json.ready jako boolean, result_json.readiness / migration_readiness s hodnotou READY nebo NOT READY, případně text READY / NOT READY v uloženém raw výstupu jobu.
This commit is contained in:
@@ -89,6 +89,32 @@ def _first_int(data: dict[str, Any], keys: tuple[str, ...]) -> int | None:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _readiness_from_script_output(result_data: dict[str, Any], combined_text: str) -> bool:
|
||||||
|
ready_value = result_data.get("ready")
|
||||||
|
if isinstance(ready_value, bool):
|
||||||
|
return ready_value
|
||||||
|
|
||||||
|
readiness_value = str(
|
||||||
|
result_data.get("readiness")
|
||||||
|
or result_data.get("migration_readiness")
|
||||||
|
or result_data.get("migrationReadiness")
|
||||||
|
or ""
|
||||||
|
).strip().upper()
|
||||||
|
|
||||||
|
if readiness_value == "READY":
|
||||||
|
return True
|
||||||
|
if readiness_value == "NOT READY":
|
||||||
|
return False
|
||||||
|
|
||||||
|
upper_text = combined_text.upper()
|
||||||
|
if re.search(r"(?<![A-Z0-9_])NOT\s+READY(?![A-Z0-9_])", upper_text):
|
||||||
|
return False
|
||||||
|
if re.search(r"(?<![A-Z0-9_])READY(?![A-Z0-9_])", upper_text):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def summarize_readiness(job: dict[str, Any] | None) -> dict[str, Any]:
|
def summarize_readiness(job: dict[str, Any] | None) -> dict[str, Any]:
|
||||||
if not job:
|
if not job:
|
||||||
return {
|
return {
|
||||||
@@ -123,22 +149,8 @@ def summarize_readiness(job: dict[str, Any] | None) -> dict[str, Any]:
|
|||||||
if fail_count is None:
|
if fail_count is None:
|
||||||
fail_count = _count_token(combined_text, "FAIL")
|
fail_count = _count_token(combined_text, "FAIL")
|
||||||
|
|
||||||
readiness_value = str(
|
|
||||||
result_data.get("readiness")
|
|
||||||
or result_data.get("ready")
|
|
||||||
or result_data.get("status")
|
|
||||||
or ""
|
|
||||||
).strip().upper()
|
|
||||||
|
|
||||||
if readiness_value in {"READY", "TRUE", "OK", "SUCCESS"}:
|
|
||||||
ready = fail_count == 0 and (job.get("status") or "").lower() == "success"
|
|
||||||
elif readiness_value in {"NOT READY", "FALSE", "FAIL", "FAILED", "ERROR"}:
|
|
||||||
ready = False
|
|
||||||
else:
|
|
||||||
ready = fail_count == 0 and (job.get("status") or "").lower() == "success"
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"ready": ready,
|
"ready": _readiness_from_script_output(result_data, combined_text),
|
||||||
"ok_count": ok_count,
|
"ok_count": ok_count,
|
||||||
"warn_count": warn_count,
|
"warn_count": warn_count,
|
||||||
"fail_count": fail_count,
|
"fail_count": fail_count,
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ def migration_readiness_page(request: Request, user=Depends(require_user)):
|
|||||||
f"""
|
f"""
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2>Migration Readiness</h2>
|
<h2>Migration Readiness</h2>
|
||||||
<p class="muted">Poslední výsledek maintenance skriptu {html.escape(PREFLIGHT_SCRIPT)} uložený v databázi.</p>
|
<p class="muted">Poslední výsledek maintenance skriptu {html.escape(PREFLIGHT_SCRIPT)} uložený v databázi. Stav vychází pouze z výstupu skriptu.</p>
|
||||||
<form method="post" action="/portal/migration-readiness/run">
|
<form method="post" action="/portal/migration-readiness/run">
|
||||||
<button type="submit">Spustit preflight kontrolu</button>
|
<button type="submit">Spustit preflight kontrolu</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user