Skip to content

fix(controller): allocate no DRBD port or minor for a definition without DRBD - #289

Merged
Andrei Kvapil (kvaps) merged 6 commits into
mainfrom
fix/no-drbd-port-without-drbd
Nov 23, 2026
Merged

Andrei Kvapil (kvaps) merged 6 commits into
mainfrom
fix/no-drbd-port-without-drbd

Conversation

@kvaps

@kvaps Andrei Kvapil (kvaps) commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What this fixes

A resource definition whose layer stack has no DRBD layer (STORAGE, or LUKS,STORAGE) still had a DRBD port, node-id and minor allocated for every replica. Such a replica never listens on that port, yet r l showed one, and each allocation took a slot out of the node's finite port range and the cluster's minor range.

The balancing passes had the same blind spot. The scheduled rebalance and the RG event path topped such definitions up like any other, so a storage-only volume whose only replica was deleted got a fresh, empty replica under its name. Once #280 lands, its new guard (skip a definition with no UpToDate diskful replica) reads these definitions as never UpToDate, because a replica without DRBD has no DRBD disk state, and logs a skip for each of them on every pass.

What LINSTOR does

LINSTOR creates a resource's TCP port, node-id and volume minor as part of its DRBD layer data (RscDrbdLayerHelper), so a resource built from a stack without DRBD has none. Its balance task (BalanceResources.shouldIgnoreRscDfn) ignores a definition that does not use the DRBD layer before it checks anything else, the UpToDate rule included. An explicit rg modify with a replica count autoplaces every child definition short of that count regardless of the stack, and regardless of the BalanceResources setting (CtrlRscGrpApiCallHandler.java:583-621), which only the balance task reads (BalanceResources.java:270, 300-308).

Changes

  • The Resource controller reads the definition's layer stack before the DRBD-ID allocation and skips the allocation when DRBD is absent. A definition that leaves its stack to a group which sets one is waited for (short requeue, plus the existing RD watch) until the RD controller pins it, because the pin keeps the default stack for a definition that already holds data. A definition that is gone keeps the old behaviour. The satellite already skips its allocation gate for these stacks, so nothing waits on the IDs.
  • The Resource controller reads that stack through the cache, falling back to the apiserver only on a miss, so the check adds no uncached read to each reconcile. A stack is set once and never cleared, so a cached copy gives the same answer; the fallback covers a replica that arrives before the cache has its freshly created definition, which would otherwise read as gone and get IDs.
  • The scheduled rebalance pass and the RG event path skip a definition whose own or inherited stack has no DRBD layer.
  • An explicit rg modify still places on such a definition through the rebalance annotation, with balancing on or off. With BalanceResourcesEnabled=false the rebalance reconciler used to only strip the annotation, which worked only because the RG event path placed every child on the same update. It now places every child itself before stripping the annotation, DRBD and storage-only alike, as LINSTOR's modify does. Leaving the DRBD children to the RG event path made the modify depend on a path LINSTOR does not place from, and once fix(controller): keep rebalance from re-placing a definition whose replicas were deleted #280 makes that path apply the balance checks, the switch among them, it would place nothing there with balancing off.
  • The spawn-shortfall replay keeps placing on storage-only definitions on purpose: it finishes a spawn that came up short, not a top-up after a deletion. A comment says so.

Interactions with other open PRs

Not changed

  • Replicas that already hold a DRBD port, node-id or minor from before this change keep them. The fields are settable-once by design, and releasing them would need a separate, careful migration; the cost is a few unused ports per node.
  • The minor on the definition's volume definitions is likewise left as it is where it was already allocated.
  • The rg modify annotation is stamped on a place-count raise and also on a change to a placement filter (layer stack, replicas-on-same, not-place-with-rsc, x-replicas-on-different), while LINSTOR autoplaces only when a replica count is given. So a filter-only modify still places on an under-placed child, storage-only ones included. This predates the PR and applies to DRBD definitions the same way; on main the RG event path placed storage-only children on every group event, controller start included, so this PR narrows the gap rather than widening it. fix(controller): keep rebalance from re-placing a definition whose replicas were deleted #280 closes it on the REST side of rg modify.

Testing

  • New unit tests: no DRBD IDs or minors for STORAGE and LUKS,STORAGE definitions, IDs still allocated for an explicit DRBD stack and for the default one, and a requeue without allocation while the stack is not pinned yet; the scheduled pass and the RG event path place nothing on a storage-only definition (stack on the definition or inherited from the group), the scheduled pass still tops up a DRBD definition, and the rg modify path still places on a storage-only one. With BalanceResourcesEnabled=false, an rg modify places both a storage-only and a DRBD child whichever of the RG event path and the rebalance reconciler runs first, and the rebalance reconciler alone places on a DRBD child too. TestRGRebalanceReconcilerHonoursBalanceResourcesDisabled on main asserted that such a modify places nothing with the switch off, which is not what LINSTOR does; it now asserts the placement, and the scheduled tick stays suppressed (TestRebalanceHonoursDisabled). The layer-stack check makes no apiserver read when the cache has the definition, and does not allocate when the cache misses a definition the apiserver has. All of these fail without the fix.
  • make lint-config && make lint: 0 issues.
  • go test ./... with envtest assets: pass.
  • go test -tags=integration ./tests/integration/... for the tests touching layer stacks, DRBD ports and rebalance: pass. After the kill-switch change, -run 'TestGroup(KW|FR|RG)': pass. One run hit a snapshot timeout in a workflow test unrelated to this change; the rerun passed. After the review fixes, the RG, RD, DRBD minor, layer-stack, concurrency and balance-tick integration tests (TestGroupC*, TestGroupD, TestGroupL, TestGroupKWFBalanceResourcesTick, TestBug433*, TestBug434*, TestSmoke*) pass again.
  • pkg/naming provenance guard: pass.

Not tested

  • Not run against a live cluster. The behaviour on an adopted cluster with existing storage-only volumes follows from the unit tests: no new allocation, existing values kept.

LINSTOR creates a resource's DRBD port, node-id and minor with its
DRBD layer data, so a definition whose layer stack has no DRBD layer
holds none of them. blockstor allocated all three for every replica,
so a STORAGE-only volume showed a DRBD port it never listens on and
took a port and a minor out of each node's finite range.

The allocator now reads the definition's stack first and skips it
when DRBD is absent. A stack still left to a group that sets one is
waited for, since the pin may keep the default stack for a
definition that already holds data. The satellite already skips its
allocation gate for such stacks, so nothing waits on the IDs.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
LINSTOR's balance task ignores a definition that does not use DRBD:
with no peer to resync from, a replica it tops up is only an empty
volume under the definition's name. blockstor's scheduled pass and
the RG event path placed on such definitions all the same, so a
storage-only volume whose replica was deleted got a fresh empty one.

Both now skip a definition whose own or inherited stack has no DRBD
layer. An explicit rg modify still places on it, as LINSTOR's
autoplace on a replica-count change does.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
…ing off

The RG event path now leaves definitions without DRBD to the rebalance
annotation, but with BalanceResourcesEnabled=false the rebalance
reconciler only stripped that annotation. An explicit `rg modify
--place-count` then placed the DRBD children and silently skipped the
storage-only ones.

LINSTOR's modify autoplaces every child of the group whatever its layer
stack and whatever the BalanceResources setting; the kill switch covers
the balance task only. With balancing off, the rebalance reconciler now
places the children the RG event path leaves out before it strips the
marker. DRBD children stay with the RG event path, so the existing
kill-switch contract for them is unchanged.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The layer-stack check runs on every live Resource reconcile, RD-watch
and sibling fan-out included, and it read the definition, and often
its group, straight from the apiserver right before runApply read the
same definition again from the cache.

A stack is set once and never cleared, and the satellite applies the
same gate, so a cached copy gives the same answer. Only a cache miss
goes to the apiserver: a replica can arrive before the cache has the
definition created a moment earlier, and reading that miss as a
definition that is gone would allocate DRBD IDs for a storage-only
replica.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The Bug 302 comments still said DRBD IDs are allocated unconditionally
on every live reconcile, which is no longer true for a definition
without DRBD or one whose stack is not pinned yet.

The spawn-shortfall replay has no layer-stack skip while the scheduled
pass does. That is deliberate, since it finishes a spawn that came up
short rather than topping up after a deletion; say so, so it is not
taken for an oversight.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 45a78846-fecb-42fa-a117-b89eee77646a
Commits

Reviewing files that changed from the base of the PR and between 216e577 and fc13186.

Files selected for processing: 7

  • internal/controller/resource_allocator_no_drbd_test.go
  • internal/controller/resource_controller.go
  • internal/controller/resource_drbd_layer.go
  • internal/controller/resourcegroup_controller.go
  • internal/controller/rg_rebalance_controller.go
  • internal/controller/rg_rebalance_controller_test.go
  • internal/controller/rg_rebalance_no_drbd_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

With BalanceResourcesEnabled=false the rebalance reconciler placed an
explicit `rg modify` only on children without DRBD and left the DRBD
ones to the RG event path. That path is not where LINSTOR's modify
places, and once it makes the balance checks, the switch among them,
nothing placed the DRBD children: the modify topped up storage-only
volumes and silently skipped the rest.

LINSTOR reads the switch in its balance task alone
(BalanceResources.java:270 and 300-308); `rg modify` autoplaces every
child short of the place count without consulting it
(CtrlRscGrpApiCallHandler.java:583-621). The disabled branch now
places every child itself.

TestRGRebalanceReconcilerHonoursBalanceResourcesDisabled asserted
that such a modify places nothing, and
TestRGRebalanceDisabledLeavesDRBDChildToRGEvent pinned the split;
both now assert the placement.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>

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.

I checked the LINSTOR side at linstor-server v1.35.3. BalanceResources.shouldIgnoreRscDfn skips a definition without DRBD before the UpToDate checks (L235-261). rg modify with a replica count autoplaces every child short of it, without looking at the stack or the balance switch (CtrlRscGrpApiCallHandler.java L644-667 at that tag; the PR cites L583-621, which match a different version). The ID gate waits only on the group-stack case, and pinLayerStack resolves that independently of the replicas, so a DRBD replica cannot stall there. The RG event path's applyRGToRD does nothing but place, so skipping it for storage-only children loses nothing else. CI is green. LGTM.

@kvaps
Andrei Kvapil (kvaps) merged commit 071c6a2 into main Nov 23, 2026
16 checks passed
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