Skip to content

The agent that grows with you

fix(cron): report an unwritable tick lock in cron status and doctor

kshitijk4poor70be36ada25a
diff --git a/cron/store_health.py b/cron/store_health.py
index a0e92bddeb1..0b363b35907 100644
--- a/cron/store_health.py
+++ b/cron/store_health.py
@@ -273,9 +273,11 @@ def probe_store(cron_dir: Path) -> Optional[OSError]:
size = jobs_file.stat().st_size + 4096
except OSError:
size = 4096
- target = os.path.realpath(jobs_file)
- if os.path.exists(target) and not os.access(target, os.W_OK): # e.g. a read-only symlink target
- return OSError(errno.EACCES, os.strerror(errno.EACCES), target)
+ # A read-only jobs.json symlink target, or a tick lock the ticker cannot open (root-owned in a
+ # writable dir: the tick skips every run while the dir itself still accepts writes).
+ for target in (os.path.realpath(jobs_file), str(cron_dir / ".tick.lock")):
+ if os.path.exists(target) and not os.access(target, os.W_OK):
+ return OSError(errno.EACCES, os.strerror(errno.EACCES), target)
tmp = None
chunk = b"\0" * 65536
try:
diff --git a/tests/cron/test_due_scan_save_failure.py b/tests/cron/test_due_scan_save_failure.py
index 2e0c3c44b66..2cb38a130e2 100644
--- a/tests/cron/test_due_scan_save_failure.py
+++ b/tests/cron/test_due_scan_save_failure.py
@@ -362,6 +362,13 @@ def test_unwritable_store_is_shown_in_cron_status_and_announced_once(cron_store,
finally:
os.chmod(target.parent, 0o700)
os.chmod(target, 0o600)
+ lock = cron_dir / ".tick.lock" # only the tick lock is unwritable (root-owned): every tick skips
+ lock.write_text("")
+ os.chmod(lock, 0o400)
+ try:
+ assert store_health.probe_store(cron_dir) is not None
+ finally:
+ os.chmod(lock, 0o600)
sent = []
gate = asyncio.Event()