Documentation
¶
Overview ¶
Package diskpressure samples filesystem usage for the volume backing a given path and rate-limits the warnings kukeond emits when a data volume crosses a high-water mark. It is intentionally observation-only: nothing in this package deletes, reaps, or mutates on-disk state. The daemon uses it to make disk pressure visible (reconcile-loop WARN) and to refuse to dig the hole deeper (a CreateCell guard) without ever removing operator data (issue #1035).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Usage ¶
type Usage struct {
// TotalBytes is the filesystem's total capacity (f_blocks * f_bsize).
TotalBytes uint64
// AvailBytes is the space available to unprivileged writers
// (f_bavail * f_bsize) — the headroom that matters for "will the next
// write succeed".
AvailBytes uint64
// UsedBytes is TotalBytes minus the free space (f_bfree * f_bsize).
UsedBytes uint64
// UsedPercent is the fraction of capacity consumed, expressed as used /
// (used + available) * 100 — matching df(1)'s Use% so the number lines up
// with what an operator sees. Reserved-for-root blocks (f_bfree - f_bavail)
// are excluded from the denominator, so a volume an unprivileged process
// can no longer write to reports 100% even though root has a sliver left.
UsedPercent float64
}
Usage is a point-in-time snapshot of a filesystem's capacity, derived from a single statfs(2) call against a path on that filesystem.
type Warner ¶
type Warner struct {
// contains filtered or unexported fields
}
Warner rate-limits warnings per key (e.g. per realm) so a daemon whose reconcile interval is short does not emit a WARN every tick while a volume stays over the high-water mark. ShouldWarn returns true at most once per window per key. The zero value is not usable; construct with NewWarner.
func NewWarner ¶
NewWarner returns a Warner that lets a given key fire at most once per window. A non-positive window disables rate-limiting (every ShouldWarn call returns true).
func (*Warner) ShouldWarn ¶
ShouldWarn reports whether a warning for key should be emitted now, recording the decision so a subsequent call within the window returns false. Safe for concurrent use.