feat: alert on Sia hostd usage instead of df for /mnt/sia #34

Merged
jared merged 2 commits from feat/lxc-managed-volume-usage into main 2026-11-06 13:03:03 -05:00
Owner

Why

Ticket 500875604 fired because /mnt/sia on LXC 141 passed 80% on df, while hostd was only storing about 3.4 TiB.

hostd writes to its least-written slots first, so data.dat gets fully allocated over time and only then reuses freed slots. df on this mount is expected to read nearly full, so it can't tell us whether Sia is running out of room.

What changed

For mounts listed in the new LXC_MANAGED_VOLUMES config (currently only /mnt/sia on LXC 141):

  • The usual LXC thresholds (80% and 90%) apply to hostd's used and total sectors. These are read from its database in read-only mode, so nodes don't need the API password.
  • Tickets and metrics report hostd's figures, so they match the number that triggered the alert.
  • A critical ticket is still created if the filesystem has under 20 GiB left, which is a real out-of-space risk.

All other mounts keep normal df alerting, including the root disk of LXC 141.

Worth reviewing

If hostd's usage can't be read, the daemon logs a warning and only checks the 20 GiB floor. It deliberately doesn't fall back to df, which would raise a false ticket. The catch is that a hostd schema change could silently stop Sia usage alerts, with only that log warning to show for it.

Testing

  • Added tests in TestManagedVolumes: 119 tests pass, and flake8 and bandit 1.9.4 are clean.
  • Ran only the LXC storage check on large1 from a temporary copy, which can't create tickets: status OK, no issues, /mnt/sia at 23.0% (3.447 of 15 TiB).

Deployment

Hosts run hwmonDaemon.py directly from main, so merging this deploys it to every node on their next run. Ticket 500875604 can be closed once this is live.

🤖 Generated with Claude Code

## Why Ticket 500875604 fired because `/mnt/sia` on LXC 141 passed 80% on `df`, while hostd was only storing about 3.4 TiB. hostd writes to its least-written slots first, so `data.dat` gets fully allocated over time and only then reuses freed slots. `df` on this mount is expected to read nearly full, so it can't tell us whether Sia is running out of room. ## What changed For mounts listed in the new `LXC_MANAGED_VOLUMES` config (currently only `/mnt/sia` on LXC 141): - The usual LXC thresholds (80% and 90%) apply to hostd's used and total sectors. These are read from its database in read-only mode, so nodes don't need the API password. - Tickets and metrics report hostd's figures, so they match the number that triggered the alert. - A critical ticket is still created if the filesystem has under 20 GiB left, which is a real out-of-space risk. All other mounts keep normal `df` alerting, including the root disk of LXC 141. ## Worth reviewing If hostd's usage can't be read, the daemon logs a warning and only checks the 20 GiB floor. It deliberately doesn't fall back to `df`, which would raise a false ticket. The catch is that a hostd schema change could silently stop Sia usage alerts, with only that log warning to show for it. ## Testing - Added tests in `TestManagedVolumes`: 119 tests pass, and flake8 and bandit 1.9.4 are clean. - Ran only the LXC storage check on large1 from a temporary copy, which can't create tickets: status OK, no issues, `/mnt/sia` at 23.0% (3.447 of 15 TiB). ## Deployment Hosts run `hwmonDaemon.py` directly from `main`, so merging this deploys it to every node on their next run. Ticket 500875604 can be closed once this is live. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jared added 1 commit 2026-11-06 12:36:53 -05:00
feat: alert on Sia hostd usage instead of df for /mnt/sia
Lint / Python (flake8) (push) Successful in 2m6s
Lint / Notify on failure (push) Skipped
Security / Python Security (bandit) (push) Failing after 2m8s
Lint / Python (flake8) (pull_request) Successful in 1m22s
Lint / Notify on failure (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Failing after 1m24s
Test / Python Tests (pytest) (pull_request) Successful in 1m21s
Test / Python Tests (pytest) (push) Successful in 1m19s
d8f707ade7
hostd allocates its whole data.dat over time and then reuses freed slots,
so df on the mount is expected to read nearly full and says nothing about
real usage. Alert on hostd's used/total sectors for mounts listed in
LXC_MANAGED_VOLUMES, and keep a critical free-space floor for a real
out-of-space risk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jared added 1 commit 2026-11-06 12:57:55 -05:00
fix: filter hostd volumes in Python to avoid building SQL from a string
Lint / Python (flake8) (push) Successful in 1m35s
Lint / Notify on failure (push) Skipped
Lint / Python (flake8) (pull_request) Successful in 1m30s
Lint / Notify on failure (pull_request) Skipped
Security / Python Security (bandit) (push) Successful in 1m33s
Test / Python Tests (pytest) (push) Successful in 1m46s
Security / Python Security (bandit) (pull_request) Successful in 1m9s
Test / Python Tests (pytest) (pull_request) Successful in 1m16s
99d4350f4d
Bandit 1.9.4 in CI flagged the query (B608). Select every volume with a
static query and match the mountpoint in Python instead. Also stops a
mount like /mnt/sia-other from matching /mnt/sia.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jared merged commit 30b28677e8 into main 2026-11-06 13:03:03 -05:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/hwmonDaemon#34