Skip to content

feat(resize): support growing Lightbits volumes via qm resize#9

Merged
roiyz-lb merged 2 commits into
mainfrom
feat/volume-resize
Jun 11, 2026
Merged

feat(resize): support growing Lightbits volumes via qm resize#9
roiyz-lb merged 2 commits into
mainfrom
feat/volume-resize

Conversation

@roiyz-lb

@roiyz-lb roiyz-lb commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds volume resize (grow) to the Lightbits storage plugin, exposed through qm resize / the Proxmox UI.

  • volume_resize: 4 KiB-aligns the new size (PVE passes bytes, pre-padded to a 1 KiB multiple), PUTs it to the project-scoped volume endpoint, and polls until the cluster reports the new size.
  • Resizes regardless of $running — PVE follows up with QEMU block_resize on a running guest, which requires the backing volume to already be larger. (The file-based base plugin returns early when running; that's wrong for network block storage.)
  • After the cluster resize, issues an nvme ns-rescan on the owning controller as a robustness backup. The NVMe controller normally refreshes namespace capacity via an async event; the rescan forces a synchronous re-read so the new size is visible before block_resize, and covers kernel/target combinations that don't honor the event. Rescanning the controller (not the namespace) keeps it correct under NVMe multipath, and avoids blockdev --rereadpt (which only re-reads a partition table).
  • Advertises resize in volume_has_feature.

Testing

  • Unit: t/volume_resize.t — asserts the PUT path/body and 4 KiB alignment across representative sizes. Full suite: 73 tests pass.
  • Integration (PVE 9.2.2 + LightOS 3.15.3): attached a disk on lb-storage to a VM and resized via qm resize, offline and with the volume activated. The Lightbits volume grew (1→2→3 GiB) and the host block device (/dev/nvme0n1) reflected the new capacity each time.

Notes

  • Branched off main (independent of other in-flight feature groups). Grow-only; shrink is not supported by the backend.

Summary by CodeRabbit

  • New Features

    • Lightbits volumes can now be grown via the UI or qm resize, supporting online and offline workflows and ensuring the host sees the new capacity reliably after resize.
  • Documentation

    • Roadmap updated to move volume resize into Phase 1 with grow/online-offline details.
  • Tests

    • Added tests validating 4 KiB alignment, API request formatting, success and timeout/failure behaviors.

Implement volume_resize: 4 KiB-align the new size (PVE passes bytes,
padded to a 1 KiB multiple), PUT it to the project-scoped volume
endpoint, and poll until the cluster reports the new size. Resize runs
regardless of $running — PVE follows up with QEMU block_resize on a
running guest, which needs the backing volume already grown.

After the cluster resize, issue an 'nvme ns-rescan' on the owning
controller as a robustness backup: the NVMe controller normally refreshes
namespace capacity via an async event, but the rescan forces a synchronous
re-read so the new size is visible before block_resize, and covers
kernels/targets that don't honor the event. Rescans the controller (not
the namespace) so it works under NVMe multipath.

Advertise resize in volume_has_feature. Add t/volume_resize.t covering
the PUT shape and 4 KiB alignment. Verified end-to-end on PVE 9.2.2 +
LightOS 3.15.3 (offline and activated resize, host device reflected the
new size).
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7c0f799e-b8b2-4a28-9c04-2d65a8e0ac48

📥 Commits

Reviewing files that changed from the base of the PR and between 0affd8c and 54e2ddc.

📒 Files selected for processing (2)
  • LightbitsPlugin.pm
  • t/volume_resize.t

📝 Walkthrough

Walkthrough

Adds grow-only volume resize to the Lightbits Proxmox plugin: the plugin now advertises resize support, implements volume_resize to 4KiB-align and PUT size via REST API with polling until Available, optionally runs nvme ns-rescan to refresh kernel capacity, and includes tests and docs updates.

Changes

Volume Resize Implementation

Layer / File(s) Summary
Resize implementation and feature support
LightbitsPlugin.pm
volume_has_feature reports resize. New volume_resize aligns size to 4KiB, PUTs the aligned size to the Lightbits REST API, polls GET until the volume is Available and size >= target (dies on timeout), conditionally runs nvme ns-rescan when the device symlink targets an NVMe controller, and returns the aligned byte size.
Test coverage for resize behavior
t/volume_resize.t
Tests stub _api to capture PUT path/body and drive GET responses, assert PUT uses project-scoped UUID and stringified size, verify returned and sent sizes are 4KiB-aligned across representative inputs, ensure PUT is still issued when running is true, and validate timeout/error messaging on non-convergence.
Documentation and roadmap updates
README.md, CHANGELOG.md
README moves "Volume resize (grow)" into Phase 1 with online/offline note. CHANGELOG adds Unreleased entry documenting resize behavior and nvme ns-rescan step.

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding volume resize (grow) support for Lightbits volumes accessible via qm resize command.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@LightbitsPlugin.pm`:
- Around line 571-578: The polling loop that checks volume size/state using _api
and variables $cur and $state may exit via timeout without confirming success;
after the for loop that polls "/api/v2/volumes/$uuid?projectName=$project" add a
post-loop verification: re-fetch the volume (or use last fetched $cur/$state),
and if $cur < $bytes or $state ne 'Available' then fail fast (croak/die/return
an error) instead of proceeding to the NVMe rescan and returning $bytes; ensure
the error includes $uuid, expected $bytes, actual $cur and $state for debugging
so callers don’t assume the resize succeeded.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b7e6d4e0-b36c-4193-9151-8bb78d109229

📥 Commits

Reviewing files that changed from the base of the PR and between f9a342d and 0affd8c.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • LightbitsPlugin.pm
  • README.md
  • t/volume_resize.t

Comment thread LightbitsPlugin.pm Outdated
The poll loop declared $cur/$state inside the loop, so on timeout it fell
through and proceeded to the rescan + returned $bytes — reporting success for
an incomplete resize (PVE would then block_resize the guest to a size the
volume doesn't have). Hoist $cur/$state and die after the loop, with the
volume UUID, expected bytes, and last-seen size/state, if it never converged.

Extend t/volume_resize.t with a timeout case (no-op sleep so it runs instantly).
@roiyz-lb

Copy link
Copy Markdown
Collaborator Author

@robb-lb If you have a chance, please review this pr as well before merging. This is scoped specifically for the volume resize with some additional tests and resiliency improvements.

@robb-lb

robb-lb commented Jun 11, 2026

Copy link
Copy Markdown

@robb-lb If you have a chance, please review this pr as well before merging. This is scoped specifically for the volume resize with some additional tests and resiliency improvements.

@roiyz-lb Happy with the PR. Nothing to add.

@roiyz-lb roiyz-lb merged commit 5a7602e into main Jun 11, 2026
2 checks passed
@roiyz-lb roiyz-lb deleted the feat/volume-resize branch June 11, 2026 08:21
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