mesh/merge-gate pass: builds new: modules/zfs, sent nowhere; no bus step; every machine composes with the change as it did without (4 of 4 compose)
mesh/repo-check fail: its merge-check.sh failed: --- FAIL: TestASnapshotIsAnsweredFromTheListAfterwardsAndRecorded (0.00s)
mesh/delivery superseded: a newer head of the same pull request
The home server's pool holds the operator's media library, and no mesh tool could say whether it is healthy, how full it is, when it was last scrubbed or what snapshots exist; the only way was a login. This module reads all of it with fixed zfs and zpool commands (list, get, status, iostat, events, history) and has one act, zfs_snapshot, which only adds a snapshot: refused for an unknown dataset, a name outside [A-Za-z0-9._-], an existing snapshot or no why; run as sudo -n zfs snapshot -- ds@name; answered from zfs list afterwards, with any other snapshot that came or went meanwhile; recorded as the event snapshot.taken. No destroy, rollback, set or send exists, and a test holds every command to its verb. Health (ADR 0240): zfs_health on the watch process, unhealthy for a pool not ONLINE, device or data errors, a pool past 90 % full or no ZFS at all; past 80 % and a scrub older than 35 days are warnings. Beside it, the event follower (zpool events -f, as root) keeps ZFS's errors in its journal past a reboot and is judged by its unit, the check the module does not run itself. No seat (ADR 0121), no package: ZFS is the machine's.
46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
// The zfs module's Go bundle: the mesh's view of ZFS on a machine — its pools' health, layout, space,
|
|
// scrubs, I/O, cache and events, every dataset with its space and snapshots — and one act, taking a named
|
|
// snapshot of one dataset.
|
|
//
|
|
// One binary, three ways to run. With no argument it is the bundle the node's tool runner launches and
|
|
// speaks MCP to over stdio (novox/hq ADR 0188, ADR 0193), as the operator account. With `watch` and
|
|
// `events` it is one of the module's two long-running processes, run by the node-engine: the watch, which
|
|
// the health check zfs_health stands on (watch.go), and the event follower, as root, judged by its unit
|
|
// (follow.go).
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
stdio "git.novox.be/novox/mesh-sdk/go"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) > 1 {
|
|
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGTERM, os.Interrupt)
|
|
defer stop()
|
|
switch os.Args[1] {
|
|
case "watch":
|
|
(&Watch{M: Here(), Out: os.Stdout}).Run(ctx)
|
|
case "events":
|
|
Follower(ctx, os.Stdout)
|
|
default:
|
|
fmt.Fprintf(os.Stderr, "zfs-tools: %q is not a way to run; with no argument it serves its tools, with watch it "+
|
|
"watches the pools, with events it follows ZFS's events\n", os.Args[1])
|
|
os.Exit(2)
|
|
}
|
|
return
|
|
}
|
|
m := Here()
|
|
m.Emit = func(eventType string, body any) error { return stdio.Emit(eventType, body) }
|
|
// An empty name serves as the module the runtime names (MESH_SERVED_MODULE): zfs.
|
|
if err := stdio.Serve("", Tools(m)); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|