fix(storcli2): treat absent "System Overview" as no controllers#75
Conversation
storcli2 "show all" omits the "System Overview" section on a host with no
controllers ("Number of Controllers": 0). The controller getter treated the
missing key as a fatal error ("key not found: System Overview") and aborted
the whole inventory, so any tool running on a node without a storcli2-managed
controller failed instead of reporting an empty list.
Handle utils.ErrKeyNotFound as an empty inventory, mirroring the logical-volume
and physical-drive getters. Captured a real "Number of Controllers: 0" output
as a regression fixture.
Issue: ARTESCA-17644
|
LGTM — the fix correctly mirrors the existing ErrKeyNotFound-as-empty-inventory pattern already used in the logical-volume and physical-drive getters. The test fixture is captured from real hardware output, and the existing index-into-controllers[0] guard in the test is properly fixed. |
Handling the absent "System Overview" section pushed Controllers() over the gocognit threshold (13 > 10). Extract the per-envelope overview resolution into a helper, dropping both functions well under the limit. No behavior change. Issue: ARTESCA-17644
|
LGTM |
|
LGTM — the fix correctly mirrors the existing ErrKeyNotFound → empty-inventory pattern already used by the logical-volume and physical-drive getters. The extracted controllersFromOverview method is a clean refactor, the regression fixture matches a real storcli2 payload, and the test fix for the controllers[0] guard prevents index-out-of-range on the new zero-length case. |
Summary
Fixes a real-hardware failure surfaced by the storcli2 e2e harness on an ARTESCA node that has no storcli2-managed controller:
storcli2 show allomits theSystem Overviewsection when"Number of Controllers": 0. The controller getter treated the missing key as a fatal error and aborted the whole inventory, so any consumer (the e2e harness, the report generator) failed on such a host instead of reporting an empty controller list.Fix
Handle
utils.ErrKeyNotFoundfor theSystem Overviewsection as an empty inventory (continue), exactly as the logical-volume and physical-drive getters already do for their sections.Captured the node's real
Number of Controllers: 0output as a regression fixture (testdata/storcli2/all_no_controllers.json) and added ano managed controllerstest case asserting an empty, error-free result.Testing
go build ./..., fullgo test ./...,go vet, andgofmtall pass. New test caseTestStorCLI2Controllers/no_managed_controllerspasses.Issue: ARTESCA-17644
🤖 Generated with Claude Code