fix(daemon): sample disk usage on the filesystems pi2d uses
The status tile read `—` on a fresh machine: the sampler ran `statfs` on the daemon's state dir, which is created lazily on the first instance log, so the call failed with ENOENT and `diskUsedBytes`/`diskTotalBytes`/`diskPercent` all came back null — `/info` then dropped `disk` altogether and the failure was indistinguishable from a full disk. `probeMount()` now walks up to the nearest existing ancestor and then to the filesystem boundary (`st_dev` change), so a sample describes a volume, not a directory. Candidates are pi2d's own write targets — `/` (the home volume on macOS, where `/` is the sealed read-only system volume), the pi session store and the visible workspace roots — never a mount-table dump: an unrelated or hung network mount must not stall the sampler. Rows are deduped by `st_dev`, sorted most-constrained first, capped at four, and reported as `system.disks[]` with the legacy scalars aliasing the worst row. A sample that yields nothing now carries `diskError` instead of silent nulls. The status tile shows the worst filesystem and, when several are in play, one quiet row per mount instead of a single percentage that hides the full volume.
This commit is contained in:
1 parent
1d907c08fa
commit
01fd7b9922
9 files changed
+474
-31
No files matched your search
@@ -45,6 +45,9 @@ export const FAKE_SYSTEM_STATS: SystemStats = {
|
||||
diskUsedBytes: 50 * 1024 ** 3,
|
||||
diskTotalBytes: 200 * 1024 ** 3,
|
||||
diskPercent: 25,
|
||||
disks: [
|
||||
{ mountPoint: "/tmp/pi2-test", fsType: "ext4", usedBytes: 50 * 1024 ** 3, totalBytes: 200 * 1024 ** 3, percent: 25 },
|
||||
],
|
||||
};
|
||||
|
||||
export function makeFakeSysinfoSampler(stats: Partial<SystemStats> = {}): SysinfoSampler {
|
||||
|
||||
Reference in new issue
Block a user