Repository navigation
feat(zfs): read ZFS pools, datasets and snapshots (read only) - #27
Merged
Merged
Conversation
GET /v1/disks/zfs, /v1/disks/zfs/snapshots and /v1/disks/zfs/io. zpool list, zpool status and zfs list run in their scripted forms, without a shell, with time-outs and one at a time; a box without ZFS answers available: false. The test fixtures are written from the OpenZFS documentation and a pasted healthy pool, not captured from a box.
zpool list, zfs list and zpool status of a healthy mirror, pasted by a user.
This was referenced Nov 9, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shows ZFS in the Storage manager, first step, read only (design:
docs/superpowers/specs/2026-11-09-zfs-storage-design.mdin ReCasaOS/CasaOS; request: ReCasaOS/CasaOS discussion 66). This is the LocalStorage half; the dashboard half is a separate PR in CasaOS-UI.GET /v1/disks/zfs: whether ZFS is usable (available, with areason:tools_missing,module_missing,failed), the pools (size, allocated, free, fragmentation, capacity, health; fromzpool status: state, last scan, data errors, tree of vdevs with their read/write/cksum counters, the disk each one is on) and the datasets (used, available, referenced, space held by snapshots, mount point, mounted, quota, key status).GET /v1/disks/zfs/snapshots?dataset=: the snapshots of one dataset, newest first, 200 at most (truncated). The dataset must be one the box lists, otherwise 404 and nothing is run.GET /v1/disks/zfs/io: the I/O counters of each pool from/proc/spl/kstat/zfs/<pool>/io, no command; the dashboard takes the rate between two readings./v1/disksis already routed).How the commands are run, since ZFS can hang:
zpool list,zpool statusandzfs list, as argument lists, no shell,LC_ALL=C, scripted forms (-H -p) exceptzpool status, which has no-Hand is read by its section names; a line it does not understand is skipped;zpool statuswhere it cannot be killed, and a dashboard asking every few seconds must not pile such processes up. Meanwhile the last answer is returned markedstale;known: false, never as healthy.Nothing here changes a pool.
Checked on a real box, partly. A user (OpenZFS 2.4.1, Ubuntu 26.04) pasted the output of
zpool list -H -p,zfs list -H -pandzpool status -p -Pfor a healthy mirror (service/testdata/zfs/real_*); the parsers read them and the column lists are accepted by 2.4. The indentation of thezpool statustree was lost in the paste and put back by hand. Still written from the OpenZFS docs, not captured: a degraded pool, scrubs/resilvers in progress, logs/cache/spares, a volume, a locked dataset,no pools available, and the kstat counters; and nothing was run against OpenZFS 2.1/2.2/2.3 or compared withzpool iostat. See the spec ("À la charge du constructeur").Tests:
go generate ./... && go test ./service/ ./route/...ingolang:1.26, all green.