Skip to content

fix(controller,satellite): re-add a tiebreaker only after the survivors dropped the old peer - #307

Merged
Andrei Kvapil (kvaps) merged 7 commits into
mainfrom
fix/tiebreaker-readd-stale-peer
Nov 23, 2026
Merged

Andrei Kvapil (kvaps) merged 7 commits into
mainfrom
fix/tiebreaker-readd-stale-peer

Conversation

@kvaps

Copy link
Copy Markdown
Member

What this PR does

When linstor-csi deletes a volume it removes the replicas one at a time. Removing one diskful replica out of three leaves two, so the controller wants a tiebreaker. On a three-node cluster the only free node is the one that just lost its replica. The controller put the tiebreaker there as soon as that node's Resource was gone, but the other replicas' kernels still held the old connection to it. The new replica got a new DRBD node-id, and each survivor's drbdadm adjust failed with (174) Already exists ... drbdsetup new-peer <res> <id> --_name=<node> on every pass, until the stale-slot prune removed the old connection about 30 seconds later. Each failure recorded a Warning ApplyFailed Event.

LINSTOR does not hit this. It keeps a deleted replica in the definition, flagged DELETE, until every connected satellite has dropped it, so its autoplacer cannot pick that node for a tiebreaker in the meantime. Its satellite also removes a peer being deleted with drbdsetup del-peer <res> <node-id>, so a stale connection never sits in front of a new one.

Controller:

  • A node that an online replica of the definition still reports a kernel connection to (Status.Connections) is not a tiebreaker candidate. The tiebreaker lands once every online survivor has run del-peer for the old replica. The reconciler already requeues every 5 seconds, so it does not wait for another event.
  • The connections of a replica whose node is OFFLINE do not count. They are the last report of a satellite that is not there to drop them, and LINSTOR's resource delete does not wait for an offline satellite either: the update to it ends in a not-connected warning and the delete goes on. When the satellite comes back it drops the old connection itself (see below).
  • A definition flagged DELETE in its spec gets no tiebreaker, the same as one with a DeletionTimestamp. LINSTOR never runs its auto-tiebreaker helper on a definition that is being deleted. The guard stops all witness management for such a definition, removal and the quorum recount included, as upstream does. linstor-migrate does not adopt definitions flagged DELETE, so the flag only appears through an explicit write.

Satellite:

  • Before the adjust, a kernel connection to a peer that the desired state lists under a different node-id is removed by node-id with drbdsetup del-peer, and its slot is forgotten when the local replica has metadata. drbdadm adjust cannot do this on its own: it matches peers by node-id, and the del-peer it schedules for the old id waits on the new-peer that fails. tearDownRemovedPeers misses it too, because the node's name never left the .res.
  • A connection that is Connected is left alone even when its node-id disagrees. In the case above the old replica is gone, so its slot sits in Connecting or StandAlone. A Connected slot under a mismatching node-id means the ids disagree some other way, and dropping it would cut a working peer, possibly the only UpToDate source of a diskless primary. Adjust keeps failing in that case, as it did before this PR.
  • A del-peer that fails because the connection went on its own in the meantime ("unknown connection") does not fail the pass. As in LINSTOR's satellite, forget-peer still runs, and the del-peer error is dropped once forget-peer succeeds or the kernel no longer holds that node-id. A del-peer failure with the connection still present is an error.
  • The kernel is read only when the rendered .res does not already list every peer under its node-id, or when the resource's last DRBD apply on this satellite failed, so a resource whose peers have not changed makes no extra call. The second condition covers a .res already rewritten with the new node-id by a pass that could not read the kernel, or by an older satellite before an upgrade, where the .res looks current while the adjust keeps failing.

Behaviour changes

  • After a replica is deleted, a new tiebreaker on the same node waits until the online survivors have dropped their connection to the old one. While it waits, a 2-diskful definition has no tiebreaker and quorum stays off, as it does when no node is free.
  • A satellite that finds a peer under a stale node-id, not Connected, removes that connection before the adjust. The adjust no longer fails, so there is no ApplyFailed Event for it.
  • A satellite whose DRBD apply of a resource failed reads that resource's kernel state once more on the next pass.

Known limitations

  • LINSTOR would not delete the replica at all here: its tiebreaker helper takes over the replica being deleted and toggles it to a diskless tiebreaker, keeping its node-id. blockstor still deletes the replica and places a new tiebreaker afterwards. This PR only makes that sequence wait for the old connection to go.
  • A survivor that is down but not yet marked OFFLINE by the heartbeat still holds the node out of placement until it is marked.
  • The failed-apply record is kept in process memory only, so after a satellite restart the first failing pass sets it again. fix(satellite): retry a failed adjust in full, not with --skip-net #299 adds a per-resource adjust-failure record that survives a restart; the two touch the same Reconciler fields and conflict textually. Whichever merges second should read the kernel on adjustFailedBefore and drop the separate map.
  • When the local replica is diskless, LINSTOR drops a failed del-peer without checking the kernel; blockstor re-reads the kernel and keeps the error if the connection is still there.

Testing

  • internal/controller: no tiebreaker goes to a node while either online survivor still reports a connection to it, and one goes there once both have dropped it. The stale connections of an OFFLINE survivor do not keep the tiebreaker off. A definition flagged DELETE gets no tiebreaker. All fail without the fix.
  • pkg/satellite: a peer the kernel holds under node-id 1 while the desired state lists it under node-id 3 is removed with drbdsetup del-peer <res> 1 and then forgotten. Through Apply, that del-peer runs before drbdadm adjust. A peer under its current node-id, one without a node-id yet, or a Connected one is left alone. With an up-to-date .res, no command runs, and after an Apply whose adjust failed the next Apply runs the del-peer before its adjust. A del-peer failing with "unknown connection" passes when forget-peer succeeds or the connection is gone, and fails when the connection is still there. Every branch was mutation-checked.
  • Reproduced on dev/v0.4.0-alpha.10: the controller tests fail there, the commits cherry-pick cleanly, and the controller, satellite and drbd packages pass with them.
  • make lint-config, golangci-lint run (0 issues), go test ./... and go test -tags=integration ./tests/integration/....

Not tested

  • Not run on a live cluster. The sequence was reconstructed from the satellite logs and DRBD state samples of the run that hit it.
  • No e2e run.

Deleting one diskful replica out of three leaves two and calls for a
tiebreaker. When the only spare is the node that just lost its
replica, the controller placed the witness there as soon as that
node's Resource was gone, while the survivors' kernels still held the
old connection. The witness came up with a new node-id and each
survivor's adjust failed `new-peer ... name already exists` until the
stale slot was reaped some 30 s later.

LINSTOR keeps a deleted replica in the definition, flagged DELETE,
until every satellite has dropped it, so its autoplacer never offers
that node in this window. Do the same: a node any replica of the
definition still reports a kernel connection to is not a tiebreaker
candidate.

A definition flagged DELETE gets no witness either, as LINSTOR never
runs its auto-tiebreaker helper on a definition being deleted.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
A replica deleted and recreated on the same node before a survivor
had run del-peer for it comes back under a new node-id. The kernel
still holds the node under the old one, so adjust's new-peer fails
`(174) name already exists`. drbdadm adjust does not get out of it:
it matches peers by node-id, and the del-peer it schedules for the
old id waits on that same failing new-peer. tearDownRemovedPeers does
not see it either, as the node's name never left the .res. The apply
failed on every pass until the stale-slot prune reaped the connection
some 30 s later.

Before the adjust, remove a kernel connection whose peer the desired
state names under another node-id, by node-id through drbdsetup
del-peer, as LINSTOR's satellite removes a peer being deleted, and
forget its slot. The kernel is read only when the rendered .res does
not already carry every peer's node-id, so a steady resource pays no
extra call.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The tiebreaker picker keeps a node off while any replica's kernel still
reports a connection to it. A replica whose satellite is offline keeps
the connections it last reported for as long as it stays away, and
nobody drops them, so a single offline survivor held the witness off
the only spare node indefinitely and left the definition with two
diskful replicas and no tiebreaker.

LINSTOR's resource delete does not wait for an offline satellite
either: the update to it ends in a not-connected warning and the delete
goes on. The satellite learns the node's new node-id when it is back
and drops the old connection itself, so only online replicas' kernel
peers count now.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The comment claimed a definition adopted from LINSTOR mid-delete could
carry the flag, but linstor-migrate skips such definitions. It also did
not say that the guard stops all witness management for the
definition, removal and the quorum recount included, which matters
when the flag is written by hand and never cleared.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The re-identified peer teardown drops any kernel connection whose
node-id differs from the one the controller now gives the peer. In the
case it exists for, the replica behind the old node-id is gone, so the
old connection sits in Connecting or StandAlone. A Connected slot under
a mismatching node-id means the ids disagree some other way, and
dropping it cuts a working peer, possibly the only UpToDate source of a
diskless primary. Before the teardown existed, adjust simply failed in
that case and the connection stayed up; it does so again.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The old connection can go on its own between the kernel read and the
del-peer, which then fails with "unknown connection" and failed the
whole apply pass. LINSTOR's satellite hits the same race when two
replicas are deleted at once and swallows it: it still runs
forget-peer, and drops the del-peer error once forget-peer succeeds or
the kernel no longer holds the peer. Do the same; a del-peer failure
with the connection still present stays an error.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The re-identified peer check reads the kernel only while the .res
names a peer under a stale node-id. A pass that rewrote the .res with
the new node-id without reading the kernel (an unreadable kernel, or an
older satellite before an upgrade) closed that window for good: the
.res looked current, the adjust kept failing with "name already
exists", and recovery waited on the stale-slot prune again. The check
now also runs after the resource's last DRBD apply failed.

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

coderabbitai Bot commented Nov 22, 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 48 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: 7bfa1146-da1f-44aa-b128-8cb179819e9f
Commits

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

Files selected for processing: 5

  • internal/controller/ensure_tiebreaker_departed_peer_test.go
  • internal/controller/resourcedefinition_controller.go
  • pkg/drbd/drbdadm.go
  • pkg/satellite/reconciler.go
  • pkg/satellite/reidentified_peer_internal_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

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 main this is correct: the kernel-peer exclusion ignores OFFLINE survivors, the satellite never drops a Connected slot, and a del-peer that lost a race is checked against the kernel before it fails the pass. Nothing blocking.

One merge-order hazard with #308, with no textual conflict to catch it. This PR relies on the RD reconciler's standing 5 s requeue to come back once the survivors have run del-peer. #308 removes that requeue, and the RD reconciler's Resource watch passes only generation changes, so a survivor dropping the old connection (a status write) wakes nothing. With both merged, the RD that skipped the node at the replica's delete stays without a witness, and with quorum off, until the informer resync. Whichever of the two lands second should ask for a retry (askRDRetry with rdReconcileRequeue) when a node was excluded only for a kernel connection, with a test like the placement-hold requeue one in #303.

@kvaps
Andrei Kvapil (kvaps) merged commit 675b13f 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