Split into dedicated hardware poller + read-only consumers
Rearchitect so a single poller process is the sole owner of all SAS/SMART/ SES hardware I/O, serialized behind one gate and paced, writing results to Redis. The API/web and MQTT publisher become pure Redis readers — they no longer issue any subprocess and can restart freely without touching the bus. This addresses backplane/expander stress from concurrent + restart-triggered SMART/SES storms (the prior model re-ran a hardware sweep on every container start, and polled sg_ses 0x02+0x07 every 60s; 0x07 errored on the IOM6/ Xyratex expanders). - poller.py: paced sweep (inventory, SMART per-drive w/ gap, SES 0x02, ZFS, host/MegaRAID), startup jitter, single-instance Redis lock, LED-queue worker - services/hwgate.py: global serialization semaphore (POLL_CONCURRENCY=1) - services/store.py: Redis as the only producer<->consumer interface + LED queue - services/health.py: shared drive-health classifier (fixes overview double-count) - gate smartctl/sg_ses/zpool/ledctl; drop sg_ses 0x07 from the hot path - routers + temps read-only from the store; main.py drops the in-process poller - compose: 3 services (privileged poller + unprivileged app + redis) w/ pacing knobs
This commit is contained in:
@@ -1,24 +1,23 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from models.schemas import Enclosure, SlotInfo
|
||||
from services.enclosure import discover_enclosures, list_slots
|
||||
from services import store
|
||||
|
||||
router = APIRouter(prefix="/api/enclosures", tags=["enclosures"])
|
||||
|
||||
|
||||
@router.get("", response_model=list[Enclosure])
|
||||
async def get_enclosures():
|
||||
"""Discover all SES enclosures."""
|
||||
return discover_enclosures()
|
||||
"""List all discovered SES enclosures (from the poller inventory)."""
|
||||
inventory = await store.get_inventory()
|
||||
return [Enclosure(**e) for e in inventory.get("enclosures", [])]
|
||||
|
||||
|
||||
@router.get("/{enclosure_id}/drives", response_model=list[SlotInfo])
|
||||
async def get_enclosure_drives(enclosure_id: str):
|
||||
"""List all drive slots for an enclosure."""
|
||||
slots = list_slots(enclosure_id)
|
||||
if not slots:
|
||||
# Check if the enclosure exists at all
|
||||
enclosures = discover_enclosures()
|
||||
if not any(e["id"] == enclosure_id for e in enclosures):
|
||||
raise HTTPException(status_code=404, detail=f"Enclosure '{enclosure_id}' not found")
|
||||
return slots
|
||||
"""List all drive slots for an enclosure (from the poller inventory)."""
|
||||
inventory = await store.get_inventory()
|
||||
for enc in inventory.get("enclosures", []):
|
||||
if enc["id"] == enclosure_id:
|
||||
return [SlotInfo(**s) for s in enc.get("slots", [])]
|
||||
raise HTTPException(status_code=404, detail=f"Enclosure '{enclosure_id}' not found")
|
||||
|
||||
Reference in New Issue
Block a user