Skip to content

The agent that grows with you

fix(gateway): recheck the store before announcing a replayed cron store outage

kshitijk4poorb841dee558df
diff --git a/gateway/cron_store_notices.py b/gateway/cron_store_notices.py
index 10066e00b05..704e48d0381 100644
--- a/gateway/cron_store_notices.py
+++ b/gateway/cron_store_notices.py
@@ -48,8 +48,8 @@ def install_cron_store_notices(runner, loop: asyncio.AbstractEventLoop) -> None:
if event == "unwritable":
if (handle := pending.pop(store, None)) is not None:
handle.cancel() # never told it recovered: the outage notice still stands
- elif store not in announced:
- announced.add(store)
+ elif store not in announced and degraded_record(Path(store)) is not None:
+ announced.add(store) # recheck: a boot replay can land after the store recovered
send(event, record)
elif store in announced and store not in pending: # no lone "recovered"
pending[store] = loop.call_later(NOTICE_REPEAT_SECONDS, send_recovered, record)
diff --git a/tests/cron/test_due_scan_save_failure.py b/tests/cron/test_due_scan_save_failure.py
index fba3a3988ff..897f4dafc67 100644
--- a/tests/cron/test_due_scan_save_failure.py
+++ b/tests/cron/test_due_scan_save_failure.py
@@ -279,6 +279,11 @@ def test_unwritable_store_is_shown_in_cron_status_and_announced_once(cron_store,
settle()
assert [m[:2] for _, m in sent] == ["⚠️"] # still down: no "writable again", ever
save_jobs([_due_job()])
+ cronjobs.warn_store_unwritable(enospc, "x", "scan", [_due_job()]) # re-entry cancels the pending recovery
+ save_jobs([_due_job()])
+ settle()
+ cronjobs.warn_store_unwritable(enospc, "x", "scan", [_due_job()]) # already writable when the loop runs:
+ save_jobs([_due_job()]) # nothing announced, so no lone "recovered" either
settle()
install_cron_store_notices(SimpleNamespace(), loop) # a send that raises is logged, not lost
cronjobs.warn_store_unwritable(enospc, "x", "scan", [_due_job()])