The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cron): keep the outage marker when a skipped one-shot's dispatch fails
kshitijk4poor808dba987cac
diff --git a/cron/jobs.py b/cron/jobs.pyindex 198299d93a3..9547c369c6a 100644--- a/cron/jobs.py+++ b/cron/jobs.py@@ -2677,9 +2677,12 @@ def clear_run_claim(job_id: str) -> bool:tick" invariant that the scheduler comment promises (#86522)."""def apply(jobs, _i, job):- if job.get("schedule", {}).get("kind") != "once" or job.get("run_claim") is None:+ claim = job.get("run_claim")+ if job.get("schedule", {}).get("kind") != "once" or claim in (None, {"outage": True}):return False # recurring, or already cleared- job["run_claim"] = None+ # Keep the outage marker (no "at": a stale claim, so it re-dispatches) or the skipped+ # one-shot, past its grace, is retired as missed on the next scan.+ job["run_claim"] = {"outage": True} if isinstance(claim, dict) and claim.get("outage") else Nonesave_jobs(jobs)return Truediff --git a/tests/cron/test_due_scan_save_failure.py b/tests/cron/test_due_scan_save_failure.pyindex 3efe0776751..af53da906ec 100644--- a/tests/cron/test_due_scan_save_failure.py+++ b/tests/cron/test_due_scan_save_failure.py@@ -254,6 +254,8 @@ def test_skipped_oneshot_survives_recovery_by_any_save(cron_store, monkeypatch):assert get_due_jobs() == []clock["now"] += timedelta(minutes=31)assert [d["id"] for d in get_due_jobs()] == ["once"]+ cronjobs.clear_run_claim("once") # its dispatch failed (pool shut down): still not missed+ assert [d["id"] for d in get_due_jobs()] == ["once"]stale = dict(once, id="stale") # due during the outage, first scanned after the recovery scansave_jobs(load_jobs() + [stale])assert "stale" not in [d["id"] for d in get_due_jobs()]