Skip to content

fix(storcli2): treat absent "System Overview" as no controllers#75

Merged
g-carre merged 3 commits into
mainfrom
improvement/storcli2-controllergetter-no-controllers
Jun 26, 2026
Merged

fix(storcli2): treat absent "System Overview" as no controllers#75
g-carre merged 3 commits into
mainfrom
improvement/storcli2-controllergetter-no-controllers

Conversation

@g-carre

@g-carre g-carre commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a real-hardware failure surfaced by the storcli2 e2e harness on an ARTESCA node that has no storcli2-managed controller:

error: failed to get controllers: failed to get RAID controllers:
       failed to unmarshal system overview: key not found: System Overview

storcli2 show all omits the System Overview section 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.ErrKeyNotFound for the System Overview section 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: 0 output as a regression fixture (testdata/storcli2/all_no_controllers.json) and added a no managed controllers test case asserting an empty, error-free result.

Testing

go build ./..., full go test ./..., go vet, and gofmt all pass. New test case TestStorCLI2Controllers/no_managed_controllers passes.

Note: this is distinct from the existing {"Controllers":[]} case (an empty envelope, which Decode legitimately rejects). Here the envelope is a valid success payload that simply has no System Overview section.

Issue: ARTESCA-17644

🤖 Generated with Claude Code

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
@g-carre g-carre requested a review from a team as a code owner June 25, 2026 15:37
@claude

claude Bot commented Jun 25, 2026

Copy link
Copy Markdown

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.

Review by Claude Code

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
@claude

claude Bot commented Jun 25, 2026

Copy link
Copy Markdown

LGTM

The fix correctly handles the missing "System Overview" section by treating utils.ErrKeyNotFound as an empty inventory (return nil, nil), matching the established pattern used by the logical-volume getter (logicalvolumegetter/storcli2.go:180) and physical-drive getter (physicaldrivegetter/storcli2.go:189). The extracted controllersFromOverview method is well-documented and keeps Controllers() readable. The new test case and real-hardware fixture adequately cover the regression, and the existing assertion guard (if tt.expectedLen > 0) prevents a panic on the empty-result path.

Review by Claude Code

Comment thread pkg/implementation/controllergetter/testdata/storcli2/all_no_controllers.json Outdated
@claude

claude Bot commented Jun 25, 2026

Copy link
Copy Markdown

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.

Review by Claude Code

@g-carre g-carre merged commit 0cf6751 into main Jun 26, 2026
7 checks passed
@g-carre g-carre deleted the improvement/storcli2-controllergetter-no-controllers branch June 26, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants