Skip to content

feat(replica): configurable volume replica count via lb_replica_count#11

Merged
roiyz-lb merged 2 commits into
mainfrom
feat/replica-count
Jun 11, 2026
Merged

feat(replica): configurable volume replica count via lb_replica_count#11
roiyz-lb merged 2 commits into
mainfrom
feat/replica-count

Conversation

@roiyz-lb

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

Copy link
Copy Markdown
Collaborator

Summary

Adds an optional lb_replica_count storage property so volumes can be created with more than one replica, instead of the hardcoded replicaCount: 1.

  • New property (integer, 1–3) + storage option (optional).
  • alloc_image uses $scfg->{lb_replica_count} // 1defaults to 1, so existing storages are unchanged.
  • The requested count must be supported by the cluster; an unsupported value surfaces the cluster's own clear error at create time (e.g. a single-node cluster rejects anything but 1).

Testing

  • Unit (t/replica_count.t): default → replicaCount 1; explicit 1/2/3 flow through to the create body. Full suite: 95 tests pass.
  • Integration (PVE 9.2.2 + single-node LightOS):
    • lb_replica_count=1 → volume created with replicaCount=1 (verified on the cluster).
    • lb_replica_count=3 → alloc fails cleanly: 400 ... "In single server cluster, replica count must be 1" — confirms the option flows PVE → plugin → API.
    • Storage config restored afterward; no leftover volumes.

Docs

  • README: removed the now-stale "Single replica" limitation, documented --lb_replica_count, trimmed the roadmap item. CHANGELOG updated.

Notes

  • Branched off main (independent of other feature groups). Group B in the feature split.

Summary by CodeRabbit

  • New Features

    • Storage volumes now support configurable replica counts (1–3, default 1), selectable during provisioning and constrained by cluster capability.
  • Documentation

    • Added provisioning guidance for multiple replicas and removed the outdated single-replica limitation from limitations and roadmap.
  • Tests

    • Added tests to verify the configured replica count is forwarded correctly (including numeric encoding).

Add an optional lb_replica_count storage property (integer, 1-3) used as
the replicaCount when creating volumes in alloc_image; defaults to 1, so
existing storages are unchanged. The requested count must be supported by
the cluster (a single-node cluster only accepts 1, which the cluster
rejects clearly otherwise).

Add t/replica_count.t (default + explicit values in the create body).
Update README (drop the now-stale single-replica limitation, document the
option, trim the roadmap item) and CHANGELOG.
@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: a0deec91-b68f-4b8c-8ff3-39598e6d7b8c

📥 Commits

Reviewing files that changed from the base of the PR and between 1a54009 and ac62538.

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

📝 Walkthrough

Walkthrough

This PR makes Lightbits volume replica count configurable via a new lb_replica_count storage option (1–3). The plugin forwards the integer to the Lightbits REST replicaCount field during provisioning, with tests, README, and CHANGELOG updates.

Changes

Configurable Lightbits volume replica count

Layer / File(s) Summary
Plugin replica count configuration
LightbitsPlugin.pm
properties() and options() are extended to define lb_replica_count as an optional integer storage configuration parameter with default 1, min 1, and max 3.
Volume allocation with configurable replica count
LightbitsPlugin.pm
The alloc_image REST create request body now sets replicaCount from lb_replica_count (integer-cast, default 1) instead of a fixed value.
Test validation of replica count behavior
t/replica_count.t
New test stubs the plugin to capture the POST payload and verifies that replicaCount defaults to 1, forwards values 1–3, accepts string input like '2' (converted to numeric 2), and serializes as a JSON number.
Documentation and changelog updates
README.md, CHANGELOG.md
README adds --lb_replica_count usage, removes the "Single replica" limitation, updates the Phase 2 roadmap; CHANGELOG documents the new lb_replica_count option and cluster constraint.

Estimated code review effort

🎯 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 and concisely describes the main change: adding a configurable volume replica count feature via the lb_replica_count property, which is the primary objective of the changeset.
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[bot]
coderabbitai Bot previously approved these changes Jun 11, 2026
Per security review: int() the replica count so a value read back from
storage.cfg (a string) serialises as a JSON number, matching the previous
hardcoded literal rather than "2". Add default => 1 to the property schema
so PVE surfaces it in generated docs/UI. Extend the test with a string-input
case asserting numeric JSON encoding.
@roiyz-lb roiyz-lb merged commit 142774a into main Jun 11, 2026
2 checks passed
@roiyz-lb roiyz-lb deleted the feat/replica-count branch June 11, 2026 09:08
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.

1 participant