Fix: ZFS-Erkennung via tatsächlichem zpool-Test statt which()
shutil.which() reicht nicht: auf privilegierten LXC-Containern ist zpool installiert, aber /dev/zfs fehlt → Befehl schlägt fehl. _probe_zfs() führt zpool list einmal aus und wertet den Exit-Code aus. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -16,8 +16,17 @@ import re
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Detect ZFS availability once at import time — avoids repeated ERROR logs on LXC/non-ZFS systems
|
# Detect ZFS availability once at import time — avoids repeated ERROR logs on LXC/non-ZFS systems
|
||||||
import shutil as _shutil
|
# shutil.which is not enough: on privileged LXC containers zpool exists but /dev/zfs is missing
|
||||||
ZFS_AVAILABLE = bool(_shutil.which("zpool"))
|
def _probe_zfs() -> bool:
|
||||||
|
try:
|
||||||
|
r = subprocess.run(["zpool", "list"], capture_output=True, timeout=3)
|
||||||
|
return r.returncode == 0
|
||||||
|
except (FileNotFoundError, subprocess.TimeoutExpired, OSError):
|
||||||
|
return False
|
||||||
|
|
||||||
|
ZFS_AVAILABLE = _probe_zfs()
|
||||||
|
if not ZFS_AVAILABLE:
|
||||||
|
logger.info("ZFS not available on this system (pools/snapshots disabled)")
|
||||||
|
|
||||||
# Cache with TTL
|
# Cache with TTL
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
Reference in New Issue
Block a user