Skip to content

Fix storage totals for shared Arr filesystems#2721

Merged
enoch85 merged 4 commits into
Maintainerr:developmentfrom
nbellowe:codex/fix-storage-totals
Apr 19, 2026
Merged

Fix storage totals for shared Arr filesystems#2721
enoch85 merged 4 commits into
Maintainerr:developmentfrom
nbellowe:codex/fix-storage-totals

Conversation

@nbellowe

@nbellowe nbellowe commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix storage headline totals when Sonarr and Radarr expose multiple root-folder paths that all point at the same underlying filesystem.

This update now:

  • prefers root-folder-backed mounts when computing the headline total
  • keys root-folder selection by instanceType + instanceId so Sonarr and Radarr IDs do not collide
  • keeps the Arr root-folder merge logic shared in ServarrApi
  • dedupes accurate mounts per host using the best available filesystem-like signature:
    • label + totalSpace when a stable volume label is present
    • otherwise totalSpace + MiB-bucketed freeSpace to absorb tiny cross-instance drift without collapsing obviously different same-size disks

Closes #2720.

Root Cause

getDiskspaceWithRootFolders() can return multiple distinct paths like /movies, /tv, and /downloads for the same shared filesystem.

Before this change, computeTotals() deduped by normalized path, so those entries were summed independently even when they referred to the same media disk.

Notes

Arr APIs do not expose a stable filesystem or device identifier in these payloads, so the totals logic still has to rely on a heuristic.

For accurate mounts without a label, the fallback now uses totalSpace + MiB-bucketed freeSpace as the filesystem signature. That fixes the shared-filesystem double-count while avoiding the stricter totalSpace-only collision on equal-capacity disks with materially different usage. Two separate unlabeled filesystems on the same host could still theoretically collide if they expose the same total space and land in the same free-space bucket.

Validation

  • Added focused unit coverage for:
    • shared-filesystem root folders being counted once
    • overlapping radarr(1) / sonarr(1) IDs not colliding
    • same-host free-space drift still merging shared filesystems
    • same-host equal-capacity disks with different usage staying distinct
    • inaccurate-total path dedupe
    • getRootFolders() returning undefined in the shared Servarr helper
  • Ran:
    • yarn workspace @maintainerr/server test --runInBand src/modules/storage-metrics/storage-metrics.service.spec.ts src/modules/api/servarr-api/common/servarr-api.service.spec.ts
    • yarn workspace @maintainerr/server tsc --noEmit
    • yarn workspace @maintainerr/server build
  • Result: all passed

@nbellowe nbellowe requested a review from enoch85 as a code owner April 19, 2026 00:15
enoch85

This comment was marked as resolved.

@enoch85

enoch85 commented Apr 19, 2026

Copy link
Copy Markdown
Collaborator

@nbellowe I've decided to help you fix this. 👍

@enoch85

enoch85 commented Apr 19, 2026

Copy link
Copy Markdown
Collaborator

Checks pass --> merge to development for further testing.

@enoch85 enoch85 merged commit 933a2ef into Maintainerr:development Apr 19, 2026
10 checks passed
@enoch85 enoch85 added this to the 3.8.0 milestone Apr 19, 2026
@nbellowe

Copy link
Copy Markdown
Contributor Author

Thanks @enoch85 ! I can test it locally as well, when I get a few minutes in the next week.

@enoch85

enoch85 commented Apr 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks @enoch85 ! I can test it locally as well, when I get a few minutes in the next week.

Would be great!

@maintainerr-automation

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.8.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@nbellowe

Copy link
Copy Markdown
Contributor Author

Hey @enoch85 there is still an issue if I have multiple containers, with different hostnames, and the same volumes and some double counts. I think we should remove the "hostname" from the key. Any objections? Happy to open up a PR.

@enoch85

enoch85 commented Apr 25, 2026

Copy link
Copy Markdown
Collaborator

@nbellowe If you open a PR, use GPT 5.4 please.

Test the changes locally first and make it tight, minimal and tell the AI to do fact based changes. 👍

That said, we want to keep hostnames.

@nbellowe

nbellowe commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

Not really sure how else to fix it (besides removing hostname, which has the issue of not supporting multi-host setups using the same disks on multiple hosts well). There doesn't appear to be additional disk metadata available to use for grouping. We could use "free disk space" but that could have issues as well.

@enoch85

enoch85 commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator

Not really sure how else to fix it (besides removing hostname, which has the issue of not supporting multi-host setups using the same disks on multiple hosts well). There doesn't appear to be additional disk metadata available to use for grouping. We could use "free disk space" but that could have issues as well.

Please open a new issue and describe it as detailed as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Storage totals double-count shared filesystems across Arr root folders

2 participants