Skip to content

The agent that grows with you

fix(cron): count root-reserved blocks when probing the store as root

kshitijk4poor760e01ef5d77
diff --git a/cron/store_health.py b/cron/store_health.py
index 65fc69cd7f4..1c4174c7520 100644
--- a/cron/store_health.py
+++ b/cron/store_health.py
@@ -182,7 +182,12 @@ def probe_report(cron_dir: Path) -> Optional[dict]:
def free_bytes(path: Path) -> Optional[int]:
+ """Bytes this process can still write. Root may also fill the reserved blocks that
+ ``disk_usage().free`` leaves out, so a 'full' disk is not full for root."""
try:
+ if hasattr(os, "geteuid") and os.geteuid() == 0:
+ stats = os.statvfs(path)
+ return stats.f_bfree * stats.f_frsize
return shutil.disk_usage(path).free
except OSError:
return None