fix(zfs): skip zpool list when /dev/zfs unavailable in Linux (#2325)

Co-authored-by: henrygd <hank@henrygd.me>
This commit is contained in:
Santhi Prakash
2026-09-16 22:58:47 +05:30
committed by GitHub
parent 6a7b2772d9
commit 982101743e
7 changed files with 144 additions and 2 deletions

View File

@@ -13,7 +13,10 @@ import (
"strings"
)
var procZfsPath = "/proc/spl/kstat/zfs"
var (
procZfsPath = "/proc/spl/kstat/zfs"
devZfsPath = "/dev/zfs"
)
func ARCSize() (uint64, error) {
file, err := os.Open(filepath.Join(procZfsPath, "arcstats"))
@@ -40,6 +43,19 @@ func ARCSize() (uint64, error) {
return 0, fmt.Errorf("size field not found in arcstats")
}
// checkZfsDevice lets containers without /dev/zfs fail fast instead of
// waiting for ZFS utility commands to time out.
func checkZfsDevice() error {
_, err := os.Stat(devZfsPath)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return ErrNoZfs
}
return err
}
return nil
}
// PoolKernelStats reads pool state and cumulative I/O counters directly from
// procfs. These kstats are the same interfaces used by node_exporter's Linux
// ZFS collector and avoid keeping a `zpool iostat` subprocess alive.