Skip to content

feat(storcli2): logical volume create and delete#69

Merged
g-carre merged 8 commits into
mainfrom
feature/storcli2-lv-manager-create-delete
Jul 1, 2026
Merged

feat(storcli2): logical volume create and delete#69
g-carre merged 8 commits into
mainfrom
feature/storcli2-lv-manager-create-delete

Conversation

@g-carre

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

Copy link
Copy Markdown
Contributor

Summary

Implements the create/delete part of ports.LogicalVolumesManager on the storcli2/perccli2 logical-volume manager (ARTESCA-17647).

  • CreateLV — fills the request drives through the physical-drive getter, validates the RAID creation, formats a single-enclosure drives=e:s,... list (rejecting multi-enclosure requests), issues add vd with the bare RAID-level and cache tokens, and rediscovers the new volume by its physical-drive set.
  • DeleteLV — issues /cx/vx delete and surfaces the in-JSON failure payload.
  • The manager now also takes a PhysicalDrivesGetter; command verbs follow the storcli2 command map documented in DESIGN.md.

Testing

go build, go vet, gofmt, and the package test suite pass. New tests cover the create happy path, command-failure, multi-enclosure rejection, and a table-driven delete (success / invalid VD / nonexistent VD).

Note: This PR targets improvement/storcli2-cache-jbod-setter (its base), not main.

Issue: ARTESCA-17647

🤖 Generated with Claude Code

@g-carre g-carre requested a review from a team as a code owner June 25, 2026 09:11
@g-carre g-carre force-pushed the improvement/storcli2-cache-jbod-setter branch from 185c909 to b218449 Compare June 30, 2026 07:32
@g-carre g-carre force-pushed the feature/storcli2-lv-manager-create-delete branch from e5ba890 to 063bd83 Compare June 30, 2026 09:26
Comment thread pkg/implementation/logicalvolumemanager/storcli2.go
@claude

claude Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
  • pkg/implementation/logicalvolumemanager/storcli2.go:42 — StorCLI2 does not satisfy ports.LogicalVolumesManager (missing AddPDsToLV / DeletePDsFromLV). Add stubs returning ErrFunctionNotSupportedByImplementation and a compile-time assertion, matching the MDADM pattern.

    The rest of the implementation is solid: error wrapping is consistent, the single-enclosure validation in storcli2FormatDrives is correct, the PD-set matching for volume rediscovery is sound, and the test coverage (happy path, command failure, multi-enclosure rejection, table-driven delete) is good.

    Review by Claude Code

@g-carre g-carre force-pushed the feature/storcli2-lv-manager-create-delete branch from 063bd83 to 7de356c Compare June 30, 2026 13:26
Comment thread pkg/implementation/logicalvolumemanager/storcli2.go
@claude

claude Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
  • pkg/implementation/logicalvolumemanager/storcli2.go:41 — StorCLI2 is missing AddPDsToLV and DeletePDsFromLV from ports.LogicalVolumesManager. Add stub methods returning ports.ErrFunctionNotSupportedByImplementation and a compile-time interface assertion (var _ ports.LogicalVolumesManager = &StorCLI2{}) to match the MDADM adapter pattern.

    Review by Claude Code

Base automatically changed from improvement/storcli2-cache-jbod-setter to main June 30, 2026 13:33
Comment thread pkg/implementation/logicalvolumemanager/storcli2.go Outdated
Comment thread pkg/implementation/logicalvolumemanager/storcli2.go
Move ReadCacheToken/WriteCacheToken into pkg/implementation/storcli2 so
both the cache setter (lvcachesetter) and the upcoming create path
(logicalvolumemanager) share one source of truth for the policy→CLI-token
mapping, instead of each emitting its own (and the create path leaking the
domain enum's string representation as the token). The mapping fails closed
on any unmappable policy via an exhaustive switch default.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@g-carre g-carre force-pushed the feature/storcli2-lv-manager-create-delete branch from 7de356c to ddc8be4 Compare June 30, 2026 14:38
Comment thread pkg/implementation/logicalvolumemanager/storcli2.go
@claude

claude Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
  • pkg/implementation/logicalvolumemanager/storcli2.go:44 — StorCLI2 does not satisfy ports.LogicalVolumesManager (missing AddPDsToLV / DeletePDsFromLV). Add a compile-time interface check and stub the unsupported methods with ErrFunctionNotSupportedByImplementation, matching the MDADM implementation in this package.

    Review by Claude Code

@g-carre g-carre force-pushed the feature/storcli2-lv-manager-create-delete branch from ddc8be4 to 13d1232 Compare June 30, 2026 15:31
Comment thread pkg/implementation/logicalvolumemanager/storcli2.go
@claude

claude Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

1 issue found:

  • pkg/implementation/logicalvolumemanager/storcli2.go:42 — StorCLI2 is missing AddPDsToLV/DeletePDsFromLV stubs and the var _ ports.LogicalVolumesManager compile-time assertion that both existing adapters carry. Without these, the type cannot be used as a LogicalVolumesManager.

Looks good otherwise: error handling follows the errors.Wrap convention, cache-token extraction is correctly shared and fails closed, the findNewLogicalVolume rediscovery approach is sound, tests cover the happy path plus three failure modes (command error, multi-enclosure, unsettable policy, and table-driven delete), and fixtures match the code paths they exercise.

Review by Claude Code

Comment thread pkg/implementation/logicalvolumemanager/storcli2.go
@claude

claude Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
  • pkg/implementation/logicalvolumemanager/storcli2.go:44 — StorCLI2 implements CreateLV/DeleteLV but not AddPDsToLV/DeletePDsFromLV from LogicalVolumesManager. Consider adding stubs that return ErrFunctionNotSupportedByImplementation.

    Otherwise clean: error handling uses errors.Wrap consistently, hexagonal boundaries are respected, cache token refactoring to the shared storcli2 package is well-motivated, drive formatting correctly validates single-enclosure constraint before running the command, and the test suite covers happy path plus key failure modes (command error, multi-enclosure rejection, unsettable cache policy, invalid/nonexistent VD deletion) with realistic fixtures.

    Review by Claude Code

g-carre and others added 2 commits June 30, 2026 18:33
Implement the create/delete part of ports.LogicalVolumesManager on the
storcli2/perccli2 logical-volume manager:

- CreateLV fills the request drives through the physical-drive getter,
  validates the RAID creation, formats a single-enclosure "drives=e:s,..."
  list (rejecting multi-enclosure requests), issues "add vd" with the bare
  RAID-level and cache tokens, and rediscovers the new volume by its
  physical-drive set.
- DeleteLV issues "/cx/vx delete" and surfaces the in-JSON failure payload.

The manager now also takes a PhysicalDrivesGetter; command verbs follow the
storcli2 command map documented in DESIGN.md.

Issue: ARTESCA-17647
The decomposed storcli2 adapters store the injected commandrunner as an
unexported `runner` field; reviews kept flagging the exported type-name
form (StorCLI2/SSACLI). Document it next to the package-layout principle so
future adapters follow it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@g-carre g-carre force-pushed the feature/storcli2-lv-manager-create-delete branch from e2a38b2 to cae6f00 Compare June 30, 2026 16:35
g-carre added 2 commits June 30, 2026 18:35
Complete ports.LogicalVolumesManager on the storcli2/perccli2 manager:

- AddPDsToLV grows a volume through "expand drives=e:s,..." (online capacity
  expansion). storcli2 dropped "start migrate", so expansion is the only
  supported growth path; the firmware preserves the RAID level. Drives
  spanning multiple enclosures are rejected.
- DeletePDsFromLV returns ErrFunctionNotSupportedByImplementation: the
  storcli-to-storcli2 command map drops "start migrate" with no replacement
  for removing drives from a volume (see DESIGN.md).

Replace the stale plain-text migrate/fail.json fixture (captured with the
v1 grammar that storcli2 rejects) with proper expand/{success,fail}.json
fixtures, and update the collection script and testdata README accordingly.

Issue: ARTESCA-17648
revive's unused-receiver rule flagged the named 's' receiver, which the
not-supported stub never references.

Issue: ARTESCA-17648
Comment thread pkg/implementation/logicalvolumemanager/storcli2.go
@claude

claude Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
  • pkg/implementation/logicalvolumemanager/storcli2.go:44 — Missing compile-time interface assertion (var _ ports.LogicalVolumesManager = &StorCLI2{}) and stub implementations for AddPDsToLV/DeletePDsFromLV returning ErrFunctionNotSupportedByImplementation. Every other adapter in the codebase has this assertion; without it, StorCLI2 cannot be used as a LogicalVolumesManager.

    The rest of the PR — cache-token extraction into storcli2/cache.go, the create/delete logic, drive-list formatting, multi-enclosure rejection, and tests — looks solid.

    Review by Claude Code

@ezekiel-alexrod ezekiel-alexrod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

g-carre and others added 2 commits July 1, 2026 11:28
Implement ports.Blinker on the storcli2/perccli2 adapter:

- StartBlink / StopBlink issue "/cx/ex/sx start locate" / "stop locate"
  (same grammar as storcli), choosing the enclosure or no-enclosure
  selector form from the drive's parsed slot, and surface the in-JSON
  failure payload via storcli2.Decode.

A single implementation serves both binaries; the runner is injected.

Issue: ARTESCA-17650
feat(storcli2): physical drive blinker
…mbership

feat(storcli2): logical volume drive add (expand) and remove
@g-carre g-carre merged commit afaa680 into main Jul 1, 2026
7 checks passed
@g-carre g-carre deleted the feature/storcli2-lv-manager-create-delete branch July 1, 2026 16:10
runner commandrunner.CommandRunner
}

var _ ports.LogicalVolumesManager = &StorCLI2{}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ports.LogicalVolumesManager interface does not embed PhysicalDrivesGetter or LogicalVolumesGetter, so the compile-time assertion on this line only checks the four manager methods. But the struct embeds both getter interfaces, which means it also satisfies PhysicalDrivesGetter and LogicalVolumesGetter — and its PhysicalDrives method (from the embedded getter) is callable by external callers even though it's not part of the manager's contract.

This is consistent with how SSACLI and MDADM do it in the same package, so it's not a regression — just noting that the embedded getter interfaces leak as public API. If that's intentional (e.g. a composite RAIDController wires these together), it's fine.

— Claude Code

// storcli2ControllerSelector addresses a whole controller (used by "add vd").
storcli2ControllerSelector = "/c%d"
// storcli2VolumeSelector addresses a single virtual drive by its number.
storcli2VolumeSelector = "/c%d/v%s"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

storcli2VolumeSelector is defined identically in both this file and lvcachesetter/storcli2.go (line 18). Consider moving it to the shared storcli2 package alongside Decode and the cache-token helpers, since it's a common storcli2 addressing convention reused across adapters.

— Claude Code

@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

LGTM — clean implementation. Two minor observations posted as inline comments:

  • pkg/implementation/logicalvolumemanager/storcli2.go:30storcli2VolumeSelector is duplicated between this file and lvcachesetter/storcli2.go; could live in the shared storcli2 package.
  • pkg/implementation/logicalvolumemanager/storcli2.go:50 — Informational note that the embedded getter interfaces leak as public API on the struct (consistent with SSACLI/MDADM, not a regression).

Error handling is thorough (all paths wrapped with context), test coverage is solid across create/delete/expand/unsupported-ops, cache-token extraction was cleanly refactored into the shared storcli2 package, hexagonal boundaries are respected, and DeletePDsFromLV correctly returns ErrFunctionNotSupportedByImplementation. The blinker adapter is well-structured with enclosure/no-enclosure selector handling. All referenced testdata fixtures exist and match the code paths they exercise.

Review by Claude Code

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