Repository navigation
fix(rest): let linstor-csi delete the definition of a volume it deletes - #288
Conversation
linstor-csi deletes every replica it listed, then lists again and deletes the resource definition only if each remaining replica carries DELETE; it never retries once DeleteVolume returned success. LINSTOR runs its auto-tiebreaker helper inside the resource-delete transaction, so a tiebreaker left without diskful peers is already flagged DELETE when the last diskful delete returns. blockstor manages the witness from the asynchronous RD reconciler. Dropping the attach-time diskless of a 2-diskful RWX volume makes it stamp a fresh witness while csi is still deleting, and it reaps that witness only after csi's final listing. csi then sees a live TIE_BREAKER and leaves an empty resource definition behind. When a replica delete leaves no diskful replica, delete the remaining auto-managed witnesses in the same request. That shape has no witness in any branch of the reconciler or of LINSTOR, so the two cannot disagree; every other witness decision stays with the reconciler. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
linstor-csi deletes every replica of a volume, lists what is left and deletes the resource definition only when each remaining replica is flagged DELETE; it never retries. While a satellite holds a deleted diskful replica through a slow DRBD or ZFS teardown, the RD reconciler still counted it: its direct list ignored the DeletionTimestamp, and neither the active filter nor the diskful split looked at DELETE. Two terminating diskful replicas with the witness already gone read as "2 diskful, no witness", the reconciler grew a fresh TIE_BREAKER, csi's final listing saw it live and the definition was left behind. Upstream's auto-tiebreaker and auto-quorum helpers skip DELETE and INACTIVE replicas before counting anything. Mark the direct list the same way the store marks it and drop DELETE replicas from the voting set, so the witness and quorum decisions run over the replicas that stay. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The reap ran only once no diskful replica was left, so after the first of two diskful deletes the witness stayed live until the RD reconciler caught up. LINSTOR v1.33.1 decides the witness inside the `r d` transaction and flags it DELETE as soon as fewer than two voting diskful replicas remain; the reap now covers that shape too, keeping the reconciler's carve-outs at one diskful: --keep-tiebreaker and an INACTIVE replica waiting for a backfill onto the witness. The decision read the informer cache, which can miss a diskful another apiserver replica has just created, and would then drop the third quorum voter of a healthy two-diskful definition. It now reads the replicas from the API server. The delete goes through DeleteIfTieBreaker so a witness being promoted to a backfill replica survives, and a failed list or delete is logged at V(1) so a leaked definition can be traced back. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
|
Warning Review limit reachedYou'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 59 minutes. View limit details
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. |
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
I checked this against linstor-server v1.35.3. CtrlRscAutoTieBreakerHelper.isDrbdResource (L553-561) skips DELETE, DRBD_DELETE and INACTIVE replicas, and shouldTieBreakerExist (L447-487) wants at least two diskful replicas, an even count and no diskless. Reaping only below two diskful is therefore a subset of what upstream drops inside the delete call, and the reconciler still owns every other case. The reap reads past the cache through store.LiveReplicas and deletes through DeleteIfTieBreaker, so neither a fresh diskful from another apiserver nor a witness being promoted can be lost. CI is green. LGTM.
What
A replica delete now removes the auto-managed TIE_BREAKER witness before it answers whenever fewer than two voting diskful replicas remain, which is where LINSTOR v1.33.1 drops it inside the same call. The RD reconciler no longer counts replicas that are being deleted, so it cannot grow a new witness for a volume whose replicas are all on their way out.
Why
linstor-csi (v1.11.2,
DeleteanddeleteResourceDefinitionAndGroupIfUnused) deletes every replica it listed, deletes the volume definitions, then lists the replicas again and deletes the resource definition only if every listed replica carriesDELETE. It never retries after DeleteVolume returned success, so a single live replica in that last listing leaves an empty definition behind for good.LINSTOR keeps that listing clean because its auto-tiebreaker helper runs inside the resource-delete transaction (
CtrlRscDeleteApiCallHandlercallsCtrlRscAutoHelper.manage).shouldTieBreakerExistcounts only replicas not flaggedDELETE,DRBD_DELETEorINACTIVE, so as soon as fewer than two diskful replicas remain the tiebreaker is marked deleted before the call returns.blockstor runs the witness logic in the asynchronous RD reconciler. On a test cluster, deleting an RWX block volume (CDI prime and tmp PVCs) went like this: csi listed 2 diskful replicas plus the attach-time diskless, deleted the diskless first, the reconciler saw "2 diskful, no diskless" and created a fresh witness, csi deleted both diskful replicas, then listed again and found the new witness without
DELETE. The reconciler removed the witness about seven seconds later, but csi had already returned. Two definitions were left with 0 resources and 0 volume definitions. RWO volumes, whose witness already existed and was deleted first (which suppresses re-creation), were cleaned up fully.The same leak had a second path that a delete-time reap alone does not close. While a satellite holds a deleted diskful replica through a slow DRBD or ZFS teardown, or while it is down, the replica stays listed with
DELETEsynthesised from its DeletionTimestamp. The reconciler read the replicas without looking at the DeletionTimestamp and did not filterDELETE, so two terminating diskful replicas with the witness already gone looked like "2 diskful, no witness" and got a new, live TIE_BREAKER, exactly what csi's final listing must not see.How
DELETEin its direct list, the way the store already does, and dropsDELETEreplicas from the voting set before the INACTIVE probe and the diskful/diskless split. This matches upstream'sisDrbdResourcefilter and also applies to the quorum decision, which upstream counts the same way.--keep-tiebreakerand an INACTIVE replica waiting for a backfill onto the witness (Bug 393). With none left neither applies, as in the reconciler. Two or more diskful replicas leave the decision to the reconciler. Plain DISKLESS replicas are left alone.DeleteIfTieBreaker, as the reconciler does, so a witness being promoted to a backfill replica survives, and logs a failed list or delete at V(1).No tiebreaker-suppression stamp is added on this path. With the reconciler no longer counting terminating replicas it has nothing to suppress, and a five-minute stamp would keep a witness off a definition that gets two new diskful replicas within that window, which LINSTOR would give one.
LINSTOR's takeover (turning a deleted diskless into the witness) is not reproduced here. Without it the reconciler can still create a witness while csi is deleting, but that witness is gone before the last diskful delete returns.
Interactions with open PRs
#271 changes
waitForResourceDeletionVisibleto return whether the delete converged and edits the lines right around the new call inhandleResourceDelete, so one of the two will need a small rebase. The new helper ignores the return value, which still compiles after #271. #273 adds a step to the RD reconciler'sReconcileand its watch predicate, in hunks this change does not touch. #277 and #283 also touchpkg/rest/autoplace.go, but not this handler.Testing
pkg/rest/resource_delete_orphan_witness_test.goreplays the delete shapes against the REST server and reads/v1/view/resourceswith the predicate csi uses: csi deleting both diskful replicas (the witness is gone after the first delete, as on LINSTOR),--keep-tiebreaker, an INACTIVE replica holding the witness, two diskful left, and a plain DISKLESS replica.DELETE).internal/controller/ensure_tiebreaker_deleting_replicas_test.gochecks that the reconciler grows no witness for two terminating diskful replicas, through both the direct reader and the store path. Both fail without the change.go test ./...passes with envtest assets 1.35.0, including the provenance guard.make lint-config && make lint(golangci-lint v2.11.4): 0 issues.go test -tags=integration): pass. In the first combined run, two group F auto-place create tests timed out while the full unit suite ran on the same machine at the same time; both pass alone and group F passes in full on a rerun. Neither test deletes a replica.Not tested