Repository navigation
fix(csi): enforce create volume capacity limits - #706
Open
jmclong (jmclong) wants to merge 2 commits into
Open
jmclong (jmclong) wants to merge 2 commits into
jmclong (jmclong) wants to merge 2 commits into
Conversation
jmclong (jmclong)
force-pushed
the
fix/jlong/create-capacity-limit
branch
from
November 11, 2026 23:36
c87b48b to
8d1b550
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Limit-only requests with unaligned upper bounds incorrectly return OutOfRange despite a feasible aligned allocation, requiring a normalization fix and regression test.
1 open issue
What changed in this PR
This PR adds capacity-limit enforcement to the driver's LVM-backed volume creation path, checking both predicted and actual allocation sizes.
Changes:
- Reject allocations whose extent/stripe rounding exceeds the limit, and remove unexpectedly oversized fresh volumes while preserving cleanup errors.
- Translate wrapped capacity errors to gRPC
OutOfRange, leaving existing-volume handling unchanged. - Add regression tests and update fake LVM metadata and removal behavior.
Shipped LVM behavior and mixed-version rollout/rollback remain unverified.
| File | Description |
|---|---|
internal/pkg/lvm/fake.go |
Supplies extent metadata and handles qualified names during removal. |
internal/csi/core/lvm/lvm.go |
Adds allocation-limit checks and oversized-volume cleanup. |
internal/csi/core/lvm/lvm_test.go |
Tests stripe rounding, missing metadata, and cleanup outcomes. |
internal/csi/core/lvm/controller_test.go |
Tests create-capacity boundaries and wrapped errors. |
internal/csi/controller/controller.go |
Maps capacity errors to gRPC OutOfRange. |
internal/csi/controller/controller_test.go |
Verifies the new error mapping. |
Review effort: Balanced
Comment on lines
+590
to
+591
| if err := checkCapacityLimit(capacity, limit, vg, int64(vg.PVCount)); err != nil { | ||
| return 0, err |
jmclong (jmclong)
marked this pull request as ready for review
November 12, 2026 15:17
jmclong (jmclong)
requested review from
a team,
Simon Croome (croomes) and
Lana Andreasyan (landreasyan)
as code owners
November 12, 2026 15:17
Reject impossible extent and stripe rounding before allocation, clean up unexpected oversized new volumes, and return OutOfRange through the controller. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4b7b1d07-f11e-424c-9e41-dedfe5e59990
Keep the capacity error without deleting the newly allocated LV. Use a strict mock regression to reject any removal call. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d8ae189-7c6e-42f6-8133-1109a48b853b
jmclong (jmclong)
force-pushed
the
fix/jlong/create-capacity-limit
branch
from
November 12, 2026 20:23
c225379 to
e8b39f6
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Reject create requests whose extent/stripe-rounded allocation cannot fit limit_bytes. Check the actual allocation too and return OutOfRange without deleting an unexpectedly oversized LV. Translate wrapped capacity errors to gRPC OutOfRange; matching existing-volume behavior remains unchanged.
Validation
Scope and limitations
One bug from the mutation audit. The expansion-limit PR will build on this helper. Existing EnsureVolume complexity decreased from 27 to 25; no helper proliferation. LVM analysis used candidate 2.03.23 source, not a proven shipped RPM. Mixed-version rollout/rollback was not runtime-tested; rollback restores the old limit-handling defect.
Concrete scenario
The VG has 4 MiB extents and one PV. A CSI client requests exactly 1 MiB,
including an explicit 1 MiB upper bound:
Before the fix,
lvcreaterounds the allocation to 4 MiB and the first callsucceeds with
capacity_bytes: 4194304, exceeding the client's maximum.Repeating the identical request then finds that 4 MiB LV and returns
AlreadyExistsbecause it does not fit the original range.With the fix, the preflight rejects the impossible range with
OutOfRangebefore creating an LV. Changing only
limit_bytesto4194304permits a4 MiB allocation. For a two-PV RAID0 VG with 4 MiB extents, the corresponding
regression is a 5 MiB request with a 6 MiB maximum: stripe rounding requires
8 MiB, so creation must be rejected before allocation.
These are direct CSI boundary cases. A PVC's storage request alone does not
reproduce the explicit CSI upper bound; adding
resources.limits.storageis not a substitute for sending this request.
Regression references:
TestLVM_CreateandTestEnsureVolume.The review follow-up is included in commit c225379: the post-create check
returns OutOfRange but preserves the LV; it never removes it. Race-enabled unit tests and six direct CSI
checks passed against the changed image in an isolated, linear-only Kind
fixture. The live checks covered impossible exact bounds, permitted rounding,
identical retry, exact extents, and an unlimited upper bound. Unexpected
post-create oversizing and preservation are covered by the strict mock
regression, not by an artificially induced live allocation mismatch.