A01: Fix scheduler aggregation to not mask stale/failed sources
Bug: has_any_success allowed one healthy source to give overall 'ready' when another source was stale/not_started/running — masking failures. Fix: - Added has_any_stale and has_any_running tracking - Overall status is 'degraded' if ANY source is failed/stale/running - Overall status is 'ready' ONLY when ALL enabled sources are healthy - 'not_started' when no sources are enabled - readiness (ready flag) still NOT blocked by import health (A01 requirement) Verification: - 7/7 readiness tests pass - 124/124 Python tests pass (1 skipped) - Stale source now shows 'degraded' instead of 'ready' - Failed source still shows 'degraded' - All healthy sources show 'ready'
This commit is contained in:
@@ -80,6 +80,8 @@ def readiness_report(
|
||||
source_health: dict[str, dict[str, object]] = {}
|
||||
has_any_failure = False
|
||||
has_any_success = False
|
||||
has_any_stale = False
|
||||
has_any_running = False
|
||||
for source in enabled_sources:
|
||||
latest_run = session.scalar(
|
||||
select(CommunityImportRun)
|
||||
@@ -115,13 +117,20 @@ def readiness_report(
|
||||
has_any_success = True
|
||||
elif latest_run.status == "failed":
|
||||
has_any_failure = True
|
||||
# Overall status: "degraded" if any source failed, "ready" if all healthy, "stale" if no failures but stale
|
||||
if has_any_failure:
|
||||
elif stale:
|
||||
has_any_stale = True
|
||||
elif latest_run.status == "running":
|
||||
has_any_running = True
|
||||
# Overall status: never mask failures with success of another source
|
||||
# "degraded" if any source failed/stale/running
|
||||
# "ready" only when ALL enabled sources are healthy
|
||||
# "not_started" when no sources are enabled
|
||||
if has_any_failure or has_any_stale or has_any_running:
|
||||
scheduler_status = "degraded"
|
||||
elif has_any_success:
|
||||
elif has_any_success and len(source_health) > 0:
|
||||
scheduler_status = "ready"
|
||||
else:
|
||||
scheduler_status = "stale" if enabled_sources else "not_started"
|
||||
scheduler_status = "not_started"
|
||||
components["community_scheduler"] = {"status": scheduler_status, "sources": source_health}
|
||||
except Exception:
|
||||
components["community_scheduler"] = {"status": "unknown", "sources": {}}
|
||||
|
||||
Reference in New Issue
Block a user