Skip to content

feat(drbd): give peer slots LINSTOR's semantics - #325

Open
Andrei Kvapil (kvaps) wants to merge 32 commits into
fix/adopted-backing-sizefrom
feat/drbd-peer-slots
Open

Andrei Kvapil (kvaps) wants to merge 32 commits into
fix/adopted-backing-sizefrom
feat/drbd-peer-slots

Conversation

@kvaps

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

Copy link
Copy Markdown
Member

Stacked on #321.

What changes

DRBD peer slots now behave as in LINSTOR v1.33.1. A definition records its peer-slot count, each replica copies it, metadata is created with it (create-md --max-peers), the lower disk introduced in #321 is sized for it instead of a fixed 15, and a replica with a disk that the count cannot hold is refused with FAIL_INSUFFICIENT_PEER_SLOTS rather than created and left to fail in DRBD.

LINSTOR reference

  • The count lives on the definition's DRBD layer (DrbdRscDfnData.peerSlots) and is resolved when that layer is created (RscDrbdLayerHelper.createRscDfnData, getPeerSlotsForNewResource, lines 159-174 and 1033-1064): the request's drbd_peer_slots, else the group's peer_slots (CtrlRscDfnApiCallHandler.createRscDfn), else PeerSlotsNewResource on the definition, group and controller, else DEFAULT_PEER_SLOTS = 7 (InternalApiConsts.java:227).
  • Each replica copies the count (DrbdRscData.peerSlots); rd modify --peer-slots changes it for replicas created afterwards and is refused when too low for the replicas with a disk already there (checkPeerSlotCount).
  • A new replica with a disk is refused when an existing replica has fewer slots than the replicas with a disk (CtrlRscCrtApiHelper.checkPeerSlotsForNewPeer, CtrlRscToggleDiskApiCallHandler.ensureAllPeersHavePeerSlotLeft), with FAIL_INSUFFICIENT_PEER_SLOTS (993). Autoplace and spawn create their replicas through CtrlRscCrtApiHelper.createResource in one transaction (CtrlRscGrpApiCallHandler.spawnInTransaction, autoPlaceInTransaction), so the first replica refused fails the whole request.
  • REST shows the count in the definition's layer_data[].data.peer_slots and the replica's layer_object.drbd.peer_slots; a count above 31 is refused (ResourceGroups.parsePeerSlots). Node ids run 0..31 (NodeId.NODE_ID_MAX).

Design

  • ResourceDefinition.spec.peerSlots and Resource.spec.peerSlots (1..31). The controller copies the definition's count onto a replica in the same patch as its node id, which the satellite waits for, so a later rd modify --peer-slots leaves existing metadata and grow sizing alone. The replica's count is settable once.
  • A replica that got its node id before counts were recorded was created either by blockstor with 15 or by LINSTOR with its own count (7 by default) before an older linstor-migrate adopted it, and nothing in the API tells which. On a migrated cluster the adopted replicas reported 15 over REST while their superblocks had 7, and a new replica of such a definition was stamped 15 for good. Now the satellite reads max-peers from the superblock of such a replica once (drbdadm dump-md --force, not during a resize) and publishes it as status.metadataPeerSlots. The controller records that as the replica's count and leaves the replica unrecorded until then, read as 15 as before.
  • A definition without a count records the least count its replicas with a disk hold, once all of them have reported. A new replica of such a definition gets that count, and waits for the first report instead of being stamped 15. A definition with no such replica, eg one written straight to the CRD, still reads as 15. Only new definitions get LINSTOR's resolution.
  • Definition create, spawn and the CLI resolve the count; clone and restore take the source's; rd c --peer-slots (previously refused as an unknown field), rg spawn --peer-slots and rg modify --peer-slots are accepted.
  • The satellite creates metadata with the replica's count, sizes a new lower disk for it, and re-initialises a found superblock with no more slots than the replica has. A grow is sized for the count the superblock holds, which the satellite reads once for every diskful replica: drbdadm resize takes everything beyond the metadata as data, so a grow sized for more slots than the superblock has enlarges the device past the definition (25 MiB on 100 GiB for 7 vs 15), past what a clone or restore at the definition's size holds. Until the read, as on the first pass after the upgrade, the grow is sized for at least 15, which can leave the device larger but never short.
  • The refusal runs on resource create, toggle-disk, migrate-disk, autoplace and the CLI. Autoplace, spawn and a resource create on several nodes are checked for all the replicas they add before the first one is written, since LINSTOR creates them in one transaction through the same check. Checked one by one, the replicas written by the same request were not in the cache yet: a spawn of three replicas with one peer slot was accepted and left all three AttachFailed, with satellites failing drbdadm adjust with (162). Now it fails with FAIL_INSUFFICIENT_PEER_SLOTS, nothing is created and the spawned definition is removed. Diskless replicas take no slot. The node-id allocator hands out 0..31 instead of stopping at 15.
  • linstor-migrate carries the count of each definition's DRBD layer, each replica's own count from LAYER_DRBD_RESOURCES, and each group's peer_slots; a definition with no DRBD layer gets what LINSTOR would resolve for it.

Remaining differences

Recorded in docs/cli-parity-known-deltas.md (rows 116, 117): a replica predating the record whose superblock cannot be read, and a definition with no replica to report a count, read as 15; the new replica is held to the same bound as the others where LINSTOR checks it loosely; the refusal answers HTTP 400 where LINSTOR answers 500; a restore takes the source definition's current count rather than the one the snapshot recorded.

Testing

  • pkg/drbd: the effective count of a missing one is 15, validation, the new-peer and modify checks, node ids past 15.
  • pkg/satellite: create-md --max-peers=7 and a 20976040 KiB lower disk for a 7-slot replica of 20 GiB, --max-peers=15 and 20981164 KiB without a count; a 1 GiB 7-slot zvol is 1048848 KiB on a 16 KiB volblocksize, the size LINSTOR creates; LUKS sizing for 7 slots matches LINSTOR's 20976040 KiB plus the header; a superblock is re-initialised with no more slots than the replica has; a grow of a 7-slot volume leaves the device at the definition and equals the lower disk a new replica of the definition gets (25612 KiB larger on 100 GiB with the 15-slot floor, which fails the test); without a read it keeps the 15-slot floor.
  • Controller stamping, dispatcher, k8s store round trips (writes that name no count keep it), REST resolution order, modify, reporting, spawn, group peer slots, refusals on create, toggle-disk and autoplace, CLI create and refusal, migrate carry and resolution.
  • Adopted replicas: the satellite reads the least max-peers over the volumes only when asked and never on a failed or growing pass; the status is written once; a replica predating the record is stamped from its superblock and stays unrecorded until it is read, also after rd modify lowered the definition; an adopted definition records 7 once every replica reported, also next to a 15-slot replica; a new replica gets 7 and gets no node id while no count is known; REST and the store show the superblock's count.
  • Whole requests: spawn, autoplace and a three-node r c on a one-slot definition are refused with nothing created, and the spawn leaves no definition.
  • Every check was mutated and the corresponding test fails. The migrate golden manifests gain peerSlots, the only format change.
  • go test ./... passes.

Not tested

Not run on a stand: a new definition with 7 slots coming up across three nodes, an adopted volume getting a 7-slot replica, and an upgrade of a cluster with replicas adopted by an older linstor-migrate, which should then get the count from their superblocks.

blockstor created every replica's metadata with 15 peer slots and
sized its lower disk for them, where LINSTOR uses the count of the
definition, 7 unless set otherwise. A replica now carries its own
count, the one it is created with and its lower disk and grows are
sized for, and a superblock that is re-initialised keeps no more slots
than the replica has.

A replica without a recorded count was created with 15 and is read as
15, so nothing already deployed changes. Nothing records a count yet.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
DRBD 9 and drbdmeta take node ids 0..31 whatever peer-slot count the
metadata was created with, and LINSTOR allocates from that range. The
allocator stopped at 15 because every replica had 15 peer slots, which
also capped a definition at 16 replicas, diskless ones included. With
the peer slots bounding the replicas with a disk, the node ids are
bounded only by DRBD.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
LINSTOR keeps the peer-slot count on the definition's DRBD layer and
copies it to every replica it creates, so a later change of the
definition's count leaves the replicas already there alone. blockstor
had no count anywhere and wrote 15 into every replica.

Definitions and replicas now carry peerSlots. The controller copies
the definition's count onto a replica in the same patch as its node
id, which the satellite waits for, and the dispatcher hands the
replica's count to the satellite. The stores keep both across writes
that do not name them, and a replica's DRBD layer reports it.

A definition or replica without a count was created with 15 and is
read and stamped as 15, so nothing already deployed changes.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
LINSTOR resolves a definition's peer slots when it creates its DRBD
layer: the count the request names, else the group's peer_slots, else
PeerSlotsNewResource on the definition, its group and the controller,
else 7. blockstor took none of these, and refused `rd c --peer-slots`
outright as an unknown field.

Definition create, spawn and the CLI resolve the count that way, a
clone or restore takes the source's, `rd modify --peer-slots` changes
it for replicas created afterwards and is refused when it is too low
for the replicas already there, `rg c`/`rg modify --peer-slots` are
checked against what a superblock holds and the latter is applied, and
the definition's DRBD layer reports the count in layer_data.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
A replica keeps one bitmap per peer slot and each peer with a disk
takes one, so a definition holds one replica with a disk more than its
slots. LINSTOR refuses the one beyond that with
FAIL_INSUFFICIENT_PEER_SLOTS when it is created, toggled diskful or
migrated to. blockstor created it and left DRBD to fail on it.

Resource create, toggle-disk, migrate-disk, autoplace and the CLI now
check every replica of the definition against the replicas with a
disk it would have, the new one included, and refuse with LINSTOR's
return code. Diskless replicas take no slot and are not counted.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
An adopted definition without a count would be read as the 15 of a
definition blockstor created before it recorded one: new replicas
would get 15 slots where their LINSTOR peers have 7, and placement
would be checked against the wrong count.

The converter carries the count of each definition's DRBD layer, the
count each replica's metadata was created with, and each group's
peer_slots. A definition LINSTOR never created a DRBD layer for gets
what LINSTOR would resolve for it. The golden manifests gain the
counts.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The parity list said blockstor never synthesises the data of a
definition's DRBD layer; it now reports peer_slots there. Two rows
record what remains different from LINSTOR: a definition or replica
without a recorded count reads as 15, and the new replica is held to
the same peer-slot bound as the others. The migration guide says the
counts are carried.

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

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

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: ab5cb3ae-df05-4343-9b7d-6f0ed8b30fd0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

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.

NOT LGTM. The LINSTOR side checks out against v1.33.2 (resolution order in RscDrbdLayerHelper.getPeerSlotsForNewResource, DEFAULT_PEER_SLOTS = 7, the group fallback in CtrlRscDfnApiCallHandler, clone carrying the source's count, the 993 code). What blocks is the upgrade path: the recorded count can end up below what a replica's metadata has, and the grow now trusts it. Details inline.

Lint is red on this head, and seven of its eleven findings are on lines this PR adds: funlen on handleRGCreate (pkg/rest/resource_groups.go:152), G115 at internal/cli/snapshot.go:408, internal/controller/resource_controller.go:994 and pkg/store/k8s/resources.go:945, slicescontains at pkg/store/peer_slots.go:175, noinlineerr at pkg/linstormigrate/convert.go:1918, prealloc at pkg/drbd/peerslots_test.go:84. The four in pkg/satellite/controllers/observer.go come from the base branch.

Comment thread pkg/satellite/grow.go Outdated

if withDRBD && vol.GetMetaPool() == "" {
size = drbdGrossKib(max(size, vol.GetDeviceSizeKib()))
size = drbdGrossKib(max(size, vol.GetDeviceSizeKib()), drbd.EffectivePeerSlots(dr.GetPeerSlots()))

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 grow now sizes the backing for the recorded count, but the record can be lower than what the superblock holds. One way to get there: a rolling upgrade. While a satellite still runs the old binary, it creates --max-peers=15 metadata for a new replica that the new controller has already stamped with 7, because the old satellite drops the field it does not know. A later grow on the upgraded satellite targets data plus metadata for 7 slots on a disk whose metadata takes 15, so the device ends up short of the definition by the difference. That is the case the planGrow comment describes, and resize retries stop at the limit. Before this PR a grow always assumed 15, which could only oversize. Fix: never size a grow below what the superblock needs. Either read the superblock's count, the way createMDGeometry does through Adm.MetadataGeometry (I have not checked that this works on an attached device), or size the grow of an existing device for max(recorded, 15) until the record is known to match. Oversizing costs a few MiB; undersizing leaves the volume short.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed, fixed in 2571693 with the second option: a grow sizes the metadata for max(recorded, 15). The superblock can only hold more slots than the record, never fewer, so this oversizes the bitmap by a few MiB at worst and never leaves the device short. grow_test.go has rows for a replica recorded with 7 and one with 31.

// definition without a count was created with 15 and is stamped so,
// which is what the satellite already reads for it. Set-if-nil.
if target.Spec.PeerSlots == nil && rd != nil {
v := int32(drbd.EffectivePeerSlots(rd.Spec.PeerSlots))

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.

A replica that existed before this change gets stamped with the definition's current count, not with the 15 its metadata was created with. If rd modify --peer-slots 7 runs on an old definition before the controller's first pass over one of its replicas, that replica gets 7 forever (the field is settable once). Until the stamp lands, replicaPeerSlots in the dispatcher also hands it 7. Its grows then undersize as in the grow.go comment, and the slot check counts it with 7. Fix: stamp drbd.LegacyPeerSlots on a replica that already had a node id before this pass (originalSpec.DRBDNodeID or Status.DRBDNodeID set), and use the definition's count only for a replica allocated in this pass.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in f4fe5d1 as you suggested: a replica that already had a node id (spec or status) before this pass is stamped 15; only a replica allocated in this pass gets the definition's count. The dispatcher's fallback and the REST view follow the same rule until the stamp lands, so neither hands such a replica 7 in the meantime. Tests cover the controller stamp, the dispatcher and the store projection.

Comment thread pkg/store/peer_slots.go Outdated
})
}

err = drbd.CheckPeerSlotsForNewPeer(existing, node, ReplicaPeerSlots(0, rd.PeerSlots))

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.

On toggle-disk the replica on node already exists and carries its own stamped count, and the satellite creates its metadata with that count (replicaPeerSlots takes target.Spec.PeerSlots first). This check uses the definition's current count for it instead. Example: a witness is stamped 7, then rd modify --peer-slots 15, then toggle-disk with 8 diskful peers. The check passes with 15 and the metadata is created with 7, which is the replica this check exists to refuse. Fix: when the existing list has a replica on node, pass ReplicaPeerSlots(thatReplica.PeerSlots, rd.PeerSlots) as the new replica's count.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 5283dd0: when a replica already exists on the node, its own count is used for the new peer. Your example (witness stamped 7, definition raised to 15, toggle-disk next to 8 diskful) is a test row and is refused now. 56837e4 matches the node name the same way names are compared everywhere else.

Comment thread docs/cli-parity-known-deltas.md Outdated
| 40 | `n c <node> <ip> --node-type Satellite` (node-create success envelope) | WIRE_SHAPE | permanent | BLOCKSTOR envelope shape on satellite node registration. BS emits `node created: <node>` + a `SUCCESS: No active connection to satellite '<node>'` line; upstream emits `New node '<node>' registered.` (with a UUID detail) + a `WARNING: No active connection to satellite '<node>'` line whose Details explain the controller will (re-)establish the connection. Both register the node and exit 0; the operator-visible outcome (node exists, awaiting satellite handshake) is identical. The "no active connection" notice is INFO/SUCCESS-class in BS vs WARNING-class upstream, and BS does not surface the volatile node UUID inline. Envelope-shape only; no behavioural divergence. |
| 16 | `ps l` (physical-storage list — `size` field) | WIRE_SHAPE | 2026-12-31 | BS `/v1/physical-storage` omits the per-device `size` key that python-linstor's `show_physical_storage` reads unconditionally (`linstor/responses.py` `devices.size`), so `linstor ps l` raises `KeyError: 'size'` and exits 2 against BS where upstream renders the table and exits 0. `ps l` is a hardware-discovery convenience surface; linstor-csi / piraeus-operator never call it, and the device-pool creation path (`ps create-device-pool`, cli-matrix `ps-cdp-*`) is unaffected. Tracked as a missing wire field to populate on the physical-storage DTO; whitelisted until then. |
| 86 | `node interface modify <node> <nic> --active` | BEHAVIOR | permanent | blockstor has no satellite-to-controller connection to re-target: the satellite talks only to the Kubernetes API through the in-cluster Service. `NodeNetInterface` carries no `Active` field, and the REST `is_active` flag is synthesised on read as "first interface", so `--active` changes nothing. To make another interface active, reorder `spec.netInterfaces` so it comes first; a changed address reaches the node's DRBD configuration after its satellite pod restarts. Pinned by `TestSatelliteFlagsLackControllerBindAddress` and `TestNodeCRDHasNoActiveField` in `pkg/satellite/stream/redial_spec_test.go`. |
| 98 | `rd l` / `r l` / `rd c` / `r c` / `rd modify --peer-slots` on definitions and replicas created before peer slots were recorded | BEHAVIOR | permanent | Peer slots follow LINSTOR: a definition gets its count when it is created (`--peer-slots`, else the group's `peer_slots`, else `PeerSlotsNewResource` on the definition, group or controller, else 7), each replica copies it when the controller allocates its node id, `create-md --max-peers` and the lower disk use the replica's count, and a replica with a disk the count cannot hold is refused with `FAIL_INSUFFICIENT_PEER_SLOTS`. blockstor created every replica with 15 before it recorded a count, so a definition or replica without one, which LINSTOR never has, is read as 15: its `layer_data[].data.peer_slots` and `layer_object.drbd.peer_slots` show 15, its new replicas get 15, and placement is checked against 15. A definition written straight to the CRD without the field (kubectl, GitOps) reads the same way; only the REST, CLI and migration writers resolve LINSTOR's count. Pinned by `pkg/drbd/peerslots_test.go`, `pkg/satellite/peer_slots_test.go`, `internal/controller/peer_slots_stamp_test.go` (L1). |

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.

"blockstor created every replica with 15 before it recorded a count" does not hold for replicas adopted by an earlier linstor-migrate: their metadata was created by LINSTOR with the count in LAYER_DRBD_RESOURCES.peer_slots, 7 by default, and their definitions carry no count. After upgrade the controller stamps them 15, REST reports 15, and the new refusal counts them as 15, so it admits a ninth diskful replica that their 7-slot metadata cannot hold. That part is no worse than before, but the row has to state it. Fix: say in this row that replicas adopted before this version are recorded and checked as 15 whatever LINSTOR created them with, or stamp them from the superblock.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right, fixed in 15d9d4e. The row now says that replicas adopted by an older linstor-migrate are recorded, reported and checked as 15 whatever LINSTOR created them with, so the refusal can admit a diskful replica their metadata cannot hold, as before this version.

Comment thread docs/cli-parity-known-deltas.md Outdated
| 16 | `ps l` (physical-storage list — `size` field) | WIRE_SHAPE | 2026-12-31 | BS `/v1/physical-storage` omits the per-device `size` key that python-linstor's `show_physical_storage` reads unconditionally (`linstor/responses.py` `devices.size`), so `linstor ps l` raises `KeyError: 'size'` and exits 2 against BS where upstream renders the table and exits 0. `ps l` is a hardware-discovery convenience surface; linstor-csi / piraeus-operator never call it, and the device-pool creation path (`ps create-device-pool`, cli-matrix `ps-cdp-*`) is unaffected. Tracked as a missing wire field to populate on the physical-storage DTO; whitelisted until then. |
| 86 | `node interface modify <node> <nic> --active` | BEHAVIOR | permanent | blockstor has no satellite-to-controller connection to re-target: the satellite talks only to the Kubernetes API through the in-cluster Service. `NodeNetInterface` carries no `Active` field, and the REST `is_active` flag is synthesised on read as "first interface", so `--active` changes nothing. To make another interface active, reorder `spec.netInterfaces` so it comes first; a changed address reaches the node's DRBD configuration after its satellite pod restarts. Pinned by `TestSatelliteFlagsLackControllerBindAddress` and `TestNodeCRDHasNoActiveField` in `pkg/satellite/stream/redial_spec_test.go`. |
| 98 | `rd l` / `r l` / `rd c` / `r c` / `rd modify --peer-slots` on definitions and replicas created before peer slots were recorded | BEHAVIOR | permanent | Peer slots follow LINSTOR: a definition gets its count when it is created (`--peer-slots`, else the group's `peer_slots`, else `PeerSlotsNewResource` on the definition, group or controller, else 7), each replica copies it when the controller allocates its node id, `create-md --max-peers` and the lower disk use the replica's count, and a replica with a disk the count cannot hold is refused with `FAIL_INSUFFICIENT_PEER_SLOTS`. blockstor created every replica with 15 before it recorded a count, so a definition or replica without one, which LINSTOR never has, is read as 15: its `layer_data[].data.peer_slots` and `layer_object.drbd.peer_slots` show 15, its new replicas get 15, and placement is checked against 15. A definition written straight to the CRD without the field (kubectl, GitOps) reads the same way; only the REST, CLI and migration writers resolve LINSTOR's count. Pinned by `pkg/drbd/peerslots_test.go`, `pkg/satellite/peer_slots_test.go`, `internal/controller/peer_slots_stamp_test.go` (L1). |
| 99 | `r c` / `r td` / `rd ap` beyond the peer slots | BEHAVIOR | permanent | BLOCKSTOR_STRICTER. Upstream checks the replicas already there (`checkPeerSlotsForNewPeer`, `ensureAllPeersHavePeerSlotLeft`) and holds the new replica only to `peerSlots + 1 >= diskful - 1`, so after `rd modify --peer-slots` lowers the count it creates a replica DRBD cannot attach. blockstor holds the new replica to the same bound as the others. The refusal answers HTTP 400 where upstream answers 500, with the same `FAIL_INSUFFICIENT_PEER_SLOTS` return code. A restore or clone takes the source definition's current count where upstream takes the count the snapshot recorded; they differ only when the source's count was modified after the snapshot. Pinned by `pkg/rest/peer_slots_test.go` (L1). |

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.

Row ids 98 and 99 are also taken by other open PRs: #322 adds 98, and its test fails on duplicate ids, and #192 adds 99. The highest id used across open PRs is 115, so 116 and 117 are free right now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Moved to 116 and 117 in 81cd51b.

…eat/drbd-peer-slots

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

# Conflicts:
#	docs/cli-parity-known-deltas.md
#	docs/linstor-migration.md
#	internal/cli/write_more.go
#	pkg/linstormigrate/convert.go
#	pkg/placer/placer.go
#	pkg/rest/nodes.go
#	pkg/rest/resource_groups.go
#	pkg/satellite/kernel_cleanup.go
The recorded peer-slot count can be lower than what a superblock
holds: a satellite that predates the record creates 15-slot metadata
for a replica the controller already stamped with 7. A grow sized for
the record then leaves the device short of the definition, and resize
retries stop at their limit. Before peer slots were recorded every
grow assumed 15, which could only oversize.

Size the metadata of an existing device for the recorded count or 15,
whichever is larger. Oversizing costs 32 KiB per GiB per spare slot;
undersizing leaves the volume short.

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

A replica that already had a node id before peer slots were recorded
was stamped with its definition's current count. After an
`rd modify --peer-slots 7` on an old definition, such a replica was
recorded as 7 for good although its metadata holds 15, and until the
stamp landed the dispatcher and the slot check read it as 7 too. The
settled-identities shortcut from main also skipped the stamping pass
entirely for these replicas, so they kept no count at all.

Stamp 15 on a replica whose node id predates this pass, keep the
definition's count for one allocated now, and read an unstamped
pre-existing replica as 15 in the dispatcher and on the wire. An
unstamped replica no longer counts as settled.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
On toggle-disk the replica already exists with its stamped count, and
the satellite creates its metadata with that count. The check used the
definition's current count instead, so a witness stamped 7 under a
definition since raised to 15 passed next to eight diskful peers and
then got metadata that cannot hold them. Use the existing replica's
count when there is one on the node.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The behaviour row now says that replicas adopted by an older
linstor-migrate are recorded and checked as 15 whatever LINSTOR
created them with, that a replica predating the record is stamped 15,
and that a grow never sizes metadata below 15. The rows themselves
moved to ids 116 and 117 in the merge, as 98 and 99 are taken by other
open pull requests.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Main now refuses a dump whose DRBD replica rows carry no port, as one
read past its storage version does. The peer-slot fixture was written
before that check and had none, so every conversion in it failed.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Node names reach the check in the caller's spelling, so the replica
on that node is found by key, as everywhere else names are compared.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The peer-slot helpers now return int32, the type every count is stored
in, so callers no longer narrow an int (gosec G115). The group create
handler moves its count checks into a helper to stay under funlen, and
the rest are mechanical: slices.Contains, a plain error assignment and
a preallocated test slice.

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

Copy link
Copy Markdown
Member Author

The seven findings on lines this PR adds are fixed in 446a6fb: the peer-slot helpers return int32, the type the count is stored in, so the G115 conversions are gone; handleRGCreate moves its count checks into a helper; the rest is slices.Contains, a plain error assignment and a preallocated test slice. The four in observer.go came from #321 and are fixed there (6584a9b, 8823e76), merged here in 9e35e67.

…eat/drbd-peer-slots

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

# Conflicts:
#	pkg/satellite/lower_disk_size_test.go
#	pkg/satellite/reconciler_luks_attach_grow_test.go

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.

NOT LGTM. All five points from my last review are fixed in the code. Grow never sizes below 15 slots now. A replica that had a node id before the record is stamped 15, and the dispatcher and the k8s store read it the same way until the stamp lands. Toggle-disk checks the replica's own count. Row 116 covers replicas adopted by an older linstor-migrate, and 116 and 117 are free across open PRs. The seven lint findings on this PR's lines are gone too. The one Lint error left, at observer.go:2645, comes from the base branch, and #321's current head no longer has it. One thing remains, and it comes from the grow floor I suggested: it changes the visible device size, not only the bitmap. Details inline. I would rather see the grow read the slot count from the superblock than document the larger device, for one reason I have not verified: if a guest grows its filesystem to the end of that larger device, does a clone or a restore into a new volume sized by the definition still hold it? If that target can be smaller than the source, the difference is not cosmetic.

Comment thread docs/cli-parity-known-deltas.md Outdated
| 16 | `ps l` (physical-storage list — `size` field) | WIRE_SHAPE | 2026-12-31 | BS `/v1/physical-storage` omits the per-device `size` key that python-linstor's `show_physical_storage` reads unconditionally (`linstor/responses.py` `devices.size`), so `linstor ps l` raises `KeyError: 'size'` and exits 2 against BS where upstream renders the table and exits 0. `ps l` is a hardware-discovery convenience surface; linstor-csi / piraeus-operator never call it, and the device-pool creation path (`ps create-device-pool`, cli-matrix `ps-cdp-*`) is unaffected. Tracked as a missing wire field to populate on the physical-storage DTO; whitelisted until then. |
| 86 | `node interface modify <node> <nic> --active` | BEHAVIOR | permanent | blockstor has no satellite-to-controller connection to re-target: the satellite talks only to the Kubernetes API through the in-cluster Service. `NodeNetInterface` carries no `Active` field, and the REST `is_active` flag is synthesised on read as "first interface", so `--active` changes nothing. To make another interface active, reorder `spec.netInterfaces` so it comes first; a changed address reaches the node's DRBD configuration after its satellite pod restarts. Pinned by `TestSatelliteFlagsLackControllerBindAddress` and `TestNodeCRDHasNoActiveField` in `pkg/satellite/stream/redial_spec_test.go`. |
| 105 | `n describe` / `r lv` (`/v1/view/resources` volume of a replica with no resolvable pool) | WIRE_SHAPE | permanent | A diskful replica whose satellite has not reported a volume yet is listed with one placeholder volume per volume definition, as LINSTOR lists the replica's own volumes (`Json.apiToResourceWithVolumes`). The placeholder names the pool LINSTOR would resolve (`CtrlStorPoolResolveHelper.resolveStorPool`: the StorPoolName chain, then the diskful neighbours' pools, then `DfltStorPool`, first one present on the node). When none resolves, it is listed with an empty `storage_pool_name`. LINSTOR cannot produce that row, because it creates every Volume with a resolved pool; python-linstor's `construct_rsc` then calls `add_child` on the `None` that `find_child("")` returns, so `n describe` fails for that replica until its satellite reports the volume. Deliberate: the alternative is an empty `volumes` list, on which linstor-scheduler-extender indexes `volumes[0]` without a length check and panics on every filter call, keeping the pod Pending. Pinned by `pkg/rest/view_client_contract_test.go::TestViewUnresolvablePoolStillListsTheVolume`. |
| 116 | `rd l` / `r l` / `rd c` / `r c` / `rd modify --peer-slots` on definitions and replicas created before peer slots were recorded | BEHAVIOR | permanent | Peer slots follow LINSTOR: a definition gets its count when it is created (`--peer-slots`, else the group's `peer_slots`, else `PeerSlotsNewResource` on the definition, group or controller, else 7), each replica copies it when the controller allocates its node id, `create-md --max-peers` and the lower disk use the replica's count, and a replica with a disk the count cannot hold is refused with `FAIL_INSUFFICIENT_PEER_SLOTS`. blockstor created every replica with 15 before it recorded a count, so a definition without one, which LINSTOR never has, is read as 15: its `layer_data[].data.peer_slots` and `layer_object.drbd.peer_slots` show 15, its new replicas get 15, and placement is checked against 15. A replica that had a node id before the count was recorded is stamped 15 whatever its definition says now. That includes replicas adopted by a `linstor-migrate` older than this version, whose metadata LINSTOR created with its own count (7 by default): they are recorded, reported and checked as 15, so the refusal can admit a diskful replica their metadata cannot hold, as before this version. A grow sizes the metadata of an existing device for at least 15, so a replica whose superblock holds more slots than its record is never grown short; a 7-slot replica's grow oversizes its bitmap by 32 KiB per GiB per spare slot. A definition written straight to the CRD without the field (kubectl, GitOps) reads the same way; only the REST, CLI and migration writers resolve LINSTOR's count. Pinned by `pkg/drbd/peerslots_test.go`, `pkg/satellite/peer_slots_test.go`, `internal/controller/peer_slots_stamp_test.go` (L1). |

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.

"A 7-slot replica's grow oversizes its bitmap" is not what happens. drbdadm resize runs without --size and the .res sets no disk { size }, so DRBD gives the data area everything the lower disk has beyond the metadata its superblock actually holds. When every diskful replica has 7 slots, which is every new volume by default, a grow sized for 15 leaves the device larger than the definition by 8 x 32 KiB per GiB, 25 MiB on a 100 GiB volume. The guest and v l see that. LINSTOR's device stays at the definition. Please state the larger device in this row. Sizing from the superblock's own count would avoid it, if you prefer that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed, the row now says the grow is sized for the superblock's count and states the larger device (32 KiB per GiB per spare slot, 25 MiB on 100 GiB) for the window before the read.

Comment thread pkg/satellite/grow.go Outdated
// whatever the controller stamped, as during a rolling upgrade. Sized
// for the record alone, the grow would leave the device short of the
// definition by the difference; sized for 15 when the record is lower,
// it only oversizes the bitmap, by 32 KiB per GiB for each slot too

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.

Same as the row 116 comment: the extra space ends up in the device, not in the bitmap, because the superblock still holds the recorded count and resize takes everything else as data. Please correct this sentence together with the row.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed together with the row, grownPeerSlots now takes the superblock's count and the comment explains why more slots means a larger device.

A spawn of three replicas with a disk from a group whose
PeerSlotsNewResource is 1 was accepted: the replicas were created,
never attached, and their satellites failed drbdadm adjust with (162)
on every pass. Each replica was checked against the replicas stored
before it, and the ones the same request wrote a moment earlier were
not in the cache yet, so every one passed.

LINSTOR creates the replicas of an autoplace, a spawn and a multi-node
resource create in one transaction, each through the check a single
create runs (CtrlRscCrtApiHelper.checkPeerSlotsForNewPeer), so the
first one the slots cannot hold fails the request with
FAIL_INSUFFICIENT_PEER_SLOTS and nothing is created. Check all the
replicas such a request adds before the first is written, and roll a
refused spawn's definition back, as LINSTOR's transaction does.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Replicas adopted by a linstor-migrate that predates the count carry
none, and were stamped and reported as 15, the count blockstor gave
its own replicas, while LINSTOR created their metadata with 7. REST
answered 15 where LINSTOR answered 7, the slot check counted them as
15, and a new replica of such a definition was stamped 15 for good,
the field being settable once. A later linstor-migrate carries the
count, but a cluster migrated before that has no source for it except
the superblocks.

The satellite now reads max-peers from the superblock of a diskful
replica that predates the record, once, outside a resize, and
publishes it as status.metadataPeerSlots. The controller stamps such
a replica with that value and leaves it unrecorded until then;
records on a definition without a count the least count its replicas
hold once all of them have told it; and gives a new replica of such a
definition the count its replicas told, holding it back while none
has, instead of stamping 15.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Row 116 now says that a replica predating the record is recorded with
the count its superblock holds rather than 15, and when a definition
without a count gets one. Row 117 says that a placement, a spawn and a
multi-node create are refused whole, as LINSTOR refuses them.

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

Copy link
Copy Markdown
Contributor

One more thing for when this branch takes the new head of #321 (cf57d96). git merge-tree shows conflicts in two tests, lower_disk_size_test.go and reconciler_luks_attach_grow_test.go. And grow_test.go lines 71 and 86 here use kibPerMib, which cf57d96 removed: git merges that without a conflict, but the test package will not build.

Read the superblock's peer slots after the apply rather than inside
it, and give the spawn refusal, the read gates and the definition read
their own helpers, so applyOne and spawnCreate stay under funlen and
an error from the client is wrapped. The read also skips a pass that
failed. Behaviour is otherwise unchanged.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Name the matched replica's index for what it is, and give the failing
dump-md of the superblock test a static error.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
drbdadm resize runs without --size, so DRBD gives the data area all
of the lower disk beyond the metadata the superblock holds. A grow
sized for at least 15 slots therefore enlarged the device of a 7-slot
volume past its definition, 25 MiB on 100 GiB, instead of the bitmap,
and a clone or restore created at the definition's size, with blank
replicas or an LVM receive, would not hold a filesystem grown to the
end of it. LINSTOR's device stays at the definition.

The satellite now reads max-peers once for every diskful replica, not
only for adopted ones, and a grow sizes the metadata for that count,
so the grown backing is what a new replica of the definition gets.
Until it is read, as on the first pass after the upgrade, or when the
volumes of a replica disagree, the grow keeps the 15-slot floor that
can only leave the device larger, never short.

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

Copy link
Copy Markdown
Member Author

Thanks, you're right about the device. Switched to reading the superblock in e4e4ec0: the satellite reads max-peers once for every diskful replica (status.metadataPeerSlots) and the grow sizes the metadata for that, so a 7-slot volume grows to the definition and the grown backing equals the lower disk a new replica of the definition gets. With the floor it was 25612 KiB larger on 100 GiB, the new test in grow_test.go catches that.

The 15 floor stays only until the read, i.e. a grow requested before the satellite's first successful pass after the upgrade, and when the volumes of one replica hold different counts. There it can only make the device larger, and row 116 now says so with the size.

On the clone/restore question: yes, it was not cosmetic. A local ZFS clone or LVM thin snapshot keeps the source size, but a blank-fallback replica and an LVM thin receive are created at the definition plus metadata, so the restored device is the smaller one and a filesystem grown to the end of the source device would not fit. LINSTOR does not hit it because its device stays at the definition after a grow. With the grow sized from the superblock the device does not go past what a definition-sized copy provides, except in the window above.

The same read also fixes the adopted replicas from the test cluster (they were reported as 15 while their superblocks hold 7), see 154bf2d.

@kvaps

Copy link
Copy Markdown
Member Author

Already merged, cf57d96 is in this branch since a71e86b. Both test conflicts are resolved keeping both sides: the zvol helper takes the peer slots and the volblocksize dry run, and the LUKS grow test expects the unaligned 15-slot size in KiB. grow_test.go no longer uses kibPerMib. CI is green on e4e4ec0, unit tests included.

fix(satellite): size a new lower disk for DRBD metadata like LINSTOR
Merging the approved set pushed handleRDDelete past funlen and left
an assignment glued to a defer in the satellite apply, so Lint on
main went red although every PR was green on its own. The DELETE
flag and the cascade move into a small helper, keeping their order,
and the assignment gets its blank line.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The satellite re-reads a Resource uncached when its cache has no DRBD
ids yet, and took only the ids from that read. The controller writes
the replica's peer slots and skip-initial-sync decision in the spec
write that precedes the ids, so the apply ran on ids next to a cached
spec that had neither. Such a replica reads as one created before
counts were recorded: its lower disk was sized for 15 slots, and the
next pass created 7-slot metadata on it. The device came out larger
than the definition, and larger than the replicas whose satellites
saw the write in one piece, which DRBD then refused to connect. Since
backings are rounded to the pool's block size rather than a whole
MiB, the difference shows.

The apply now runs on the whole revision it re-read, so lower disk
and metadata are sized from the one count the controller stamped.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The superblock read that records a replica's peer slots ran for every
new replica too, usually twice within a second: once per pass until
the count it reported reached the Resource. Those replicas' metadata
was created by this satellite a moment before, with a count it had in
hand.

The satellite now keeps, per volume, the count it created metadata
with or read, reports that instead of reading the disk again, and
drops it with the volume.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
A restore into a definition larger than its snapshot grows the clone
before the replica's first activation creates metadata on it, in the
replica's own layout. The grow sized that metadata for at least 15
peer slots, since no count had been read, and create-md then wrote 7:
the device came out larger than the definition, 64 KiB on 256 MiB,
and larger than the blank replica beside it, which DRBD then refused
every second for as long as the volume lived.

A grow now sizes the metadata for the count the superblock will hold:
the count published, else the one this satellite created or read,
else, while the replica's metadata is still to be created here, the
replica's own count, the one create-md writes. Only metadata that
exists and was neither created nor read here keeps the 15-slot floor
for replicas made by an older satellite during a rolling upgrade.

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

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

# Conflicts:
#	pkg/rest/resource_definitions.go

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.

NOT LGTM. The superblock read works on an attached device: dump-md does not modify metadata, and --force drops the exclusive open. The fallback when it fails can only make the device larger, the whole-request slot check matches LINSTOR's per-resource check inside one transaction, and the new tests fail without their code. One restore path still produces the device-size split that ebc3bad set out to fix, and two smaller points sit next to it, all inline.

The base branch is already in main and this branch has merged main, so it should be retargeted to main. It also carries 8ed1393 from #326, which lands with it unless #326 merges first.

Comment thread pkg/satellite/grow.go
}

if r.metadataPending(dr) {
return replicaGeometry(dr).MaxPeers

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.

This sizes a restored clone for the replica's own count, but the clone's metadata ends up with the snapshot's count or less. The restored definition takes the source definition's current count (snapshot_restore.go:1446), while the snapshot's superblock carries the source replica's count, and replicas keep theirs on rd modify --peer-slots. The probe then leaves min(found, own) on the clone (ClampedTo at reconciler.go:5122 and :5174) or keeps a clean superblock as it is. Example: rd c with 7, rd modify --peer-slots 15, snapshot, restore into a larger PVC. The grow sizes for 15, the metadata stays at 7, and the device ends up 8 x 32 KiB per GiB larger than the definition and than a blank sibling, for good. That is the split TestRestoredReplicaGrowsToItsBlankSiblingsSize describes. LINSTOR avoids it by giving the restored replica the snapshot replica's count (RscDrbdLayerHelper.java:984 in v1.33.2). Please either do the same, or read the clone's superblock with dump-md before the grow and size for what the probe will leave.

Comment thread pkg/satellite/grow.go
// upgrade. So it is sized for at least 15 then, which can only leave the
// device larger, never short.
func (r *Reconciler) grownPeerSlots(dr *intent.DesiredResource, vol *intent.DesiredVolume) int {
if read := dr.GetMetadataPeerSlots(); read != nil {

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.

status.metadataPeerSlots is written once and never cleared, and it wins over the count this process noted at create-md. A replica an older satellite created with 15 while the controller stamped 7 reads 15. After a toggle-disk to diskless and back, create-md writes 7 and the process knows it, but the grow still sizes for 15, so the device ends up larger than the definition. Please check the process memory first, and clear the status field when the replica loses its disk so the next read sets it again.


return inner
})
if cerrors.Is(err, errAwaitingPeerSlots) {

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.

When no replica ever reports its count (a satellite left on the old version, dump-md failing on every old replica, nodes offline), the new replica stays without a node id with no time limit, and the only trace is this V(1) line. After a minute the satellite reports "local DRBD node-id not yet allocated by controller", which does not say why. Please put a Warning Event or a condition on the Resource that names the replicas whose count is still missing.

| 105 | `n describe` / `r lv` (`/v1/view/resources` volume of a replica with no resolvable pool) | WIRE_SHAPE | permanent | A diskful replica whose satellite has not reported a volume yet is listed with one placeholder volume per volume definition, as LINSTOR lists the replica's own volumes (`Json.apiToResourceWithVolumes`). The placeholder names the pool LINSTOR would resolve (`CtrlStorPoolResolveHelper.resolveStorPool`: the StorPoolName chain, then the diskful neighbours' pools, then `DfltStorPool`, first one present on the node). When none resolves, it is listed with an empty `storage_pool_name`. LINSTOR cannot produce that row, because it creates every Volume with a resolved pool; python-linstor's `construct_rsc` then calls `add_child` on the `None` that `find_child("")` returns, so `n describe` fails for that replica until its satellite reports the volume. Deliberate: the alternative is an empty `volumes` list, on which linstor-scheduler-extender indexes `volumes[0]` without a length check and panics on every filter call, keeping the pod Pending. Pinned by `pkg/rest/view_client_contract_test.go::TestViewUnresolvablePoolStillListsTheVolume`. |
| 106 | `rd sp <rd> AutoSnapshot/RunEvery <n>` (schedule after a controller restart or failover) | BEHAVIOR | permanent | Upstream keeps the auto-snapshot schedule in memory: after a controller start `AutoSnapshotTask` books the first run at start + `RunEvery` + one poll (`TASK_TIMEOUT`, 10 s; `AutoSnapshotTask.java` in v1.33.1), so every restart shifts the schedule. blockstor keeps the last slot in the definition's annotation and books the next one at slot + `RunEvery`, so a restart or leader failover shorter than `RunEvery` does not shift it, and the first snapshot after a short restart can come sooner than upstream's. A slot missed by a whole interval or more (longer downtime) is booked at the time it is taken, with no catch-up, which matches the upstream outcome of one snapshot, not a burst. Between restarts the cadence matches upstream (10 s poll, next run booked at the slot as `AutoSnapshotConfig.next()`). Pinned by `internal/controller/autosnapshot_cadence_test.go::TestAutoSnapshot{RunEveryOneTakesOnePerMinute,AfterDowntimeTakesOneNotABurst}`. |
| 116 | `rd l` / `r l` / `rd c` / `r c` / `rd modify --peer-slots` on definitions and replicas created before peer slots were recorded | BEHAVIOR | permanent | Peer slots follow LINSTOR: a definition gets its count when it is created (`--peer-slots`, else the group's `peer_slots`, else `PeerSlotsNewResource` on the definition, group or controller, else 7), each replica copies it when the controller allocates its node id, `create-md --max-peers` and the lower disk use the replica's count, and a replica with a disk the count cannot hold is refused with `FAIL_INSUFFICIENT_PEER_SLOTS`. A replica that had a node id before the count was recorded was created by a blockstor that kept no count, with 15, or by LINSTOR, with its own count (7 by default), before a `linstor-migrate` older than this version adopted it. Its satellite reads the count from its superblock once (`status.metadataPeerSlots`, read for every diskful replica) and the controller records that, never a guess; a definition without a count, which LINSTOR never has, records the least count its replicas with a disk hold once all of them have told theirs. Until then such a replica and definition read as 15 in `layer_data[].data.peer_slots`, `layer_object.drbd.peer_slots` and the placement check, and a new diskful replica of such a definition waits for the first count to arrive rather than be stamped 15 for good; a definition with no such replica keeps reading as 15. A replica whose superblock cannot be read, or whose node is offline, keeps reading as 15, and holds its definition unrecorded. A grow sizes the metadata of an existing device for the slots its superblock holds, which the satellite reads once for every diskful replica (`status.metadataPeerSlots`), so the device stays at the definition as LINSTOR's does. A grow of a replica whose metadata the satellite has not created yet, as a restore into a larger definition grows its clone before it first comes up, sizes it for the replica's own count, which create-md writes next, and a grow of metadata the satellite created or read itself uses that count. Otherwise, before that read, as on the first pass after the upgrade, a grow sizes it for at least 15, so a replica whose superblock holds more slots than its record, as one an older satellite created during a rolling upgrade, is never grown short; `drbdadm resize` takes everything beyond the metadata as data, so such a grow of a 7-slot replica leaves the device larger than the definition by 32 KiB per GiB per spare slot, 25 MiB on 100 GiB. A definition written straight to the CRD without the field (kubectl, GitOps) reads the same way; only the REST, CLI and migration writers resolve LINSTOR's count. Pinned by `pkg/drbd/peerslots_test.go`, `pkg/satellite/peer_slots_test.go`, `internal/controller/peer_slots_stamp_test.go` (L1). |
| 117 | `r c` / `r td` / `rd ap` beyond the peer slots | BEHAVIOR | permanent | BLOCKSTOR_STRICTER. Upstream checks the replicas already there (`checkPeerSlotsForNewPeer`, `ensureAllPeersHavePeerSlotLeft`) and holds the new replica only to `peerSlots + 1 >= diskful - 1`, so after `rd modify --peer-slots` lowers the count it creates a replica DRBD cannot attach. blockstor holds the new replica to the same bound as the others. A placement, a spawn and a resource create naming several nodes are checked for all their replicas with a disk before the first is written, as LINSTOR creates them in one transaction: the request fails whole with nothing created, and a refused spawn leaves no definition behind. The refusal answers HTTP 400 where upstream answers 500, with the same `FAIL_INSUFFICIENT_PEER_SLOTS` return code. A restore or clone takes the source definition's current count where upstream takes the count the snapshot recorded; they differ only when the source's count was modified after the snapshot. Pinned by `pkg/rest/peer_slots_test.go` (L1). |

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.

"They differ only when the source's count was modified after the snapshot" is not right: replicas keep their count on rd modify --peer-slots, so the source definition's count and the snapshot's per-replica count also differ when the definition was modified at any point after its replicas were created. Upstream takes the snapshot replica's count (RscDrbdLayerHelper.java:984). Please correct this together with the restore fix on grow.go.

This branch has not been deployed

No deployments
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