From 963fce5a33ded2e8ee33ed56c35a29536113dc9e Mon Sep 17 00:00:00 2001 From: VACInc Date: Mon, 9 Mar 2026 17:54:53 -0400 Subject: [PATCH] agent: mark mdraid rebuild as warning, not failed (#1797) --- agent/mdraid_linux.go | 11 +++++++++-- agent/mdraid_linux_test.go | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/agent/mdraid_linux.go b/agent/mdraid_linux.go index 7e827470..f891f425 100644 --- a/agent/mdraid_linux.go +++ b/agent/mdraid_linux.go @@ -170,11 +170,18 @@ func mdraidSmartStatus(health mdraidHealth) string { case "inactive", "faulty", "broken", "stopped": return "FAILED" } + // During rebuild/recovery, arrays are often temporarily degraded; report as + // warning instead of hard failure while synchronization is in progress. + syncAction := strings.ToLower(strings.TrimSpace(health.syncAction)) + switch syncAction { + case "resync", "recover", "reshape": + return "WARNING" + } if health.degraded > 0 { return "FAILED" } - switch strings.ToLower(strings.TrimSpace(health.syncAction)) { - case "resync", "recover", "reshape", "check", "repair": + switch syncAction { + case "check", "repair": return "WARNING" } switch state { diff --git a/agent/mdraid_linux_test.go b/agent/mdraid_linux_test.go index fcb50d6c..28430a58 100644 --- a/agent/mdraid_linux_test.go +++ b/agent/mdraid_linux_test.go @@ -85,6 +85,9 @@ func TestMdraidSmartStatus(t *testing.T) { if got := mdraidSmartStatus(mdraidHealth{arrayState: "inactive"}); got != "FAILED" { t.Fatalf("mdraidSmartStatus(inactive) = %q, want FAILED", got) } + if got := mdraidSmartStatus(mdraidHealth{arrayState: "active", degraded: 1, syncAction: "recover"}); got != "WARNING" { + t.Fatalf("mdraidSmartStatus(degraded+recover) = %q, want WARNING", got) + } if got := mdraidSmartStatus(mdraidHealth{arrayState: "active", degraded: 1}); got != "FAILED" { t.Fatalf("mdraidSmartStatus(degraded) = %q, want FAILED", got) }