fix(host_agent): disks behind a RAID controller each keep their own name (#5806)
smartctl reports every disk behind a PERC/MegaRAID controller as /dev/bus/0 with type megaraid,N; the helper named a drive by its path alone, so all of VDNT-Docker02's and Docker03's disks read as one drive "0", each overwriting the last. The slot is now part of the name (bus0-megaraid3), and Steward gives a repeated name an ordinal so two drives never share a series. Agent 1.20.1. fix(ansible): Steward stopping mid-run logs no traceback (#5749) The run's done-callback called exception() on a cancelled task, which raises; it now logs a run cut short by shutdown at INFO. A finished run's in-memory state is dropped by a timer rather than a sleeping task, which shutdown found still pending. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,7 +22,7 @@ from collections import deque
|
||||
from concurrent.futures import ThreadPoolExecutor, wait as wait_futures
|
||||
from datetime import datetime, timezone
|
||||
|
||||
AGENT_VERSION = "1.20.0"
|
||||
AGENT_VERSION = "1.20.1"
|
||||
|
||||
# Default path to the local Docker Engine socket. Overridable via the
|
||||
# `docker_socket` config key; collection is silently skipped if it's absent or
|
||||
|
||||
@@ -69,9 +69,20 @@ def judge(d: dict) -> dict:
|
||||
|
||||
|
||||
def drives_of(report) -> list[dict]:
|
||||
"""The report's drives, judged, what needs attention first."""
|
||||
"""The report's drives, judged, what needs attention first. A name seen
|
||||
twice gets an ordinal, so two drives never share one series: agent
|
||||
1.20.0 named every disk behind a RAID controller "0" (#5806)."""
|
||||
drives = report.get("drives") if isinstance(report, dict) else None
|
||||
judged = [judge(d) for d in drives or [] if isinstance(d, dict) and d.get("device")]
|
||||
judged, seen = [], {}
|
||||
for d in drives or []:
|
||||
if not isinstance(d, dict) or not d.get("device"):
|
||||
continue
|
||||
d = judge(d)
|
||||
name = str(d["device"])
|
||||
seen[name] = seen.get(name, 0) + 1
|
||||
if seen[name] > 1:
|
||||
d["device"] = f"{name}#{seen[name]}"
|
||||
judged.append(d)
|
||||
return sorted(judged, key=lambda d: (_ORDER[d["state"]], str(d["device"])))
|
||||
|
||||
|
||||
|
||||
@@ -199,9 +199,21 @@ def _int(v):
|
||||
return v if isinstance(v, int) and not isinstance(v, bool) else None
|
||||
|
||||
|
||||
def drive_summary(name: str, status, data) -> dict:
|
||||
def drive_name(name: str, kind) -> str:
|
||||
"""A drive's name, unique on its host. Disks behind a RAID controller
|
||||
share one path (/dev/bus/0) and differ only by the slot in their type
|
||||
(megaraid,3; cciss,0), so the slot is part of the name (#5806)."""
|
||||
base = os.path.basename(name)
|
||||
if name.startswith("/dev/bus/"):
|
||||
base = "bus" + base
|
||||
if isinstance(kind, str) and "," in kind:
|
||||
base += "-" + re.sub(r"[^A-Za-z0-9]", "", kind.split("+")[-1])
|
||||
return base
|
||||
|
||||
|
||||
def drive_summary(name: str, status, data, kind=None) -> dict:
|
||||
"""The few figures Steward reads from one drive's `smartctl -a` JSON."""
|
||||
out = {"device": os.path.basename(name)}
|
||||
out = {"device": drive_name(name, kind)}
|
||||
if not isinstance(data, dict) or status is None or status & _SMARTCTL_UNREAD:
|
||||
messages = ((data.get("smartctl") or {}).get("messages") or []) if isinstance(data, dict) else []
|
||||
text = "; ".join(str(m.get("string", "")) for m in messages if isinstance(m, dict))
|
||||
@@ -267,7 +279,7 @@ def do_drives() -> dict:
|
||||
continue
|
||||
args = ["-a", name] if not isinstance(kind, str) else ["-a", "-d", kind, name]
|
||||
status, data = smartctl_json(args)
|
||||
drives.append(drive_summary(name, status, data))
|
||||
drives.append(drive_summary(name, status, data, kind))
|
||||
return {**base, "drives": drives}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user