Repository navigation
fix(rest): remove a deleted volume's definition after a retried snapshot delete - #306
Conversation
linstor-csi removes the definition of a deleted volume when it deletes the volume's last snapshot: once the snapshot delete answers, it lists the definition's snapshots and deletes the definition only if none is left that is not being deleted. A CSI retry of a snapshot delete that timed out finds the snapshot already gone on the API server and is answered at once, before this replica's cache has seen it go. The list was served from that cache, handed the snapshot back as live, and linstor-csi kept the definition for good. LINSTOR answers the delete and the list from one model, so the list never shows a snapshot whose delete was answered. Read the list from the API server, as the definition delete's own snapshot check does. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
A retry of a snapshot delete that timed out finds the snapshot already gone on the API server and was answered at once, while the cache that serves the reads after it could still hold the snapshot: a GET right after the answer returned it with 200. The first delete waits for the cache before answering and so does the resource delete on the same path. LINSTOR answers every read after the delete from the model the delete changed, so wait here as well; the answer stays 200 either way, since the API server already says the snapshot is gone. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The interface comment still said the uncached per-definition list was for `rd d` alone and that every other listing stays cached. The per-definition REST list now reads past the cache too, and a reader of that comment could move it back. Name the readers and say the restriction is about the paginated snapshot view. 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 25 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. |
A snapshot delete gave up after 10 seconds and answered 504 when the satellites had not deleted their copies yet. LINSTOR answers a snapshot delete once its satellites have done so and has no deadline of its own for a connected satellite. Under a burst of deletes on CPU-limited satellites the drain took longer than that, and the 504 left the definition of a deleted volume behind: linstor-csi removes it only after a delete that succeeded, and its retry finds the snapshot being deleted, then gone, without sending the delete again. Keep waiting past the budget while every node the snapshot lists is online. The budget and the 504 still apply once one of them is offline, since that node's copy will not go until it is back. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The orphan-cleanup case sent the snapshot delete and only then stripped the satellite finalizer by hand. A delete now waits for that strip while the snapshot's nodes are online, as LINSTOR waits for its satellites, so sending it first and waiting for its answer deadlocked the test. Send it in the background, check it has not answered while the finalizer holds the snapshot, and that it answers 200 once the finalizer is gone. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
A satellite that failed to delete its copy (lvremove refused, pool in error) only logged it and requeued, keeping the finalizer. Its node stayed online, so the snapshot delete, which now waits as long as the listed nodes are online, hung until the client gave up and said nothing about why. LINSTOR answers the delete with the error its satellite returned. The satellite now records the failure per node on the Snapshot status, and the delete answers it at once as an error. The satellite keeps retrying, so the snapshot stays in its deleting state and a repeated delete reports the latest failure. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The snapshot delete keeps waiting past its budget while every node the snapshot lists is online, and a node the store no longer has counted as online. A snapshot left listing only deleted or lost nodes has no satellite to take the finalizer off, so its delete hung until the client gave up instead of answering 504 as for an offline node. Treat a node the store does not know as unable to drain the snapshot. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The wait behind a snapshot delete took any failed read of the snapshot for it being gone. Now that the wait can outlast the budget and ends when the request context does, a read cut short by a server shutdown while the client is still connected would answer 200 "snapshot deleted" with the snapshot still there. Only NotFound shows the snapshot went; a cancelled read ends the wait as pending, and any other failed read is retried until the budget is spent. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The Bug 193 test still described a stuck satellite as answered with 504, which now holds only because its snapshot lists no node; one whose nodes are online is waited on until the client's deadline. The integration check that the delete has not answered runs inside the budget, so it cannot show the delete outlasts it; the unit tests, which shorten the budget, do. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
I checked the parity claims against the versions the stand pins: linstor-csi v1.10.1, which piraeus-operator v2.10.0 ships, and linstor-server v1.33.2 (stand/install-oracle.sh).
linstor-csi: SnapDelete sends the delete and runs deleteResourceDefinitionAndGroupIfUnused only after it succeeds (pkg/client/linstor.go L1185-1193). That check deletes the definition only when every listed resource and snapshot carries DELETE (L2535-2565). A retried DeleteSnapshot looks the snapshot up first (pkg/driver/driver.go L1026-1044). While the snapshot is flagged DELETE the lookup fails with DeleteInProgressError (linstor.go L1700-1718, via linstorSnapshotToCSI). Once it is gone the lookup returns nothing and the call succeeds without a delete or the definition check. So the orphan path described in the PR is real.
LINSTOR: the delete marks the snapshot, then waits on updateSatellites with notConnectedWarn, so a disconnected node only produces a warning (CtrlSnapshotDeleteApiCallHandler.java L366-379). There is no deadline on that path; CtrlSatelliteUpdateCaller applies a timeout only in attemptConnecting (L538-548). Satellite failures come back as response entries through combineResponses (CtrlResponseUtils.java L33), and the snapshot is not removed from the model then. The new wait matches both.
On main the failure record and the uncached per-definition list hold up. Only NotFound counts as gone, and treating everything but OFFLINE as online matches isNodeOnline. CI is green. LGTM.
Non-blocking, for whichever of this and #271 lands second: under #271's per-node finalizers, a node that failed once and then succeeded keeps its deleteFailures entry while another node is still deleting, and the next wait answers 500 at once. Clearing the node's entry when it releases its finalizer would fix that.
What this PR does
linstor-csi removes the definition of a deleted volume when it deletes that volume's last snapshot. Right after the snapshot delete answers, it lists the definition's snapshots and deletes the definition only when no snapshot is left that is not being deleted. It runs that check only after a snapshot delete that succeeded: a retried DeleteSnapshot first looks the snapshot up, gets "being deleted" while the snapshot is still there, and once it is gone reports success without sending the delete or running the check again.
So the definition was left behind in two ways, and this PR closes both.
The first snapshot delete answered 504 while the satellites were merely slow
blockstor's snapshot delete waits for the satellites to delete their copies before it answers, as LINSTOR does, but it gave up after 10 seconds and answered 504. LINSTOR has no such deadline for a connected satellite: its REST call returns once every satellite has answered and the snapshot is removed from its model. During a burst of deletes on CPU-limited satellite pods the drain took longer than 10 seconds, the delete answered 504, linstor-csi's retries never sent the delete again, and the definition stayed.
The delete now keeps waiting past the budget for as long as every node the snapshot lists is online, and answers 200 once the snapshot is gone. The request's own deadline still bounds the wait. When one of the listed nodes is offline, or is no longer known at all, its copy will not go until it is back, so the existing behaviour stays: 504 with the stuck-satellite message once the budget is spent. LINSTOR answers an offline node right away with a warning instead; that difference predates this PR and is kept.
The satellites share one finalizer on the Snapshot, so "gone" means the first listed satellite has deleted its copy and dropped it, not that every node has.
A satellite that fails the delete now answers it with its error
Without a deadline, an online satellite whose delete fails (lvremove refuses, the pool is in error) would have kept the call waiting: the satellite only logged the failure and retried, with the finalizer in place and its heartbeat alive. LINSTOR answers the delete with the error its satellite returned. The satellite now records the failure for its node on the Snapshot status, and the delete answers it at once with HTTP 500 and one error entry per failing node carrying the satellite's message. The satellite keeps retrying, so the snapshot stays in its deleting state and a repeated delete reports the latest failure.
The wait also no longer takes a failed read of the snapshot for it being gone. Only NotFound counts; a read cut short by the request ending, for example a server shutdown while the client is still connected, no longer answers 200 "snapshot deleted" with the snapshot still there, and other read failures are retried until the budget is spent.
A list served from the cache showed the deleted snapshot as live
When the first delete did time out and the snapshot then went, a CSI retry could still get its success, and the follow-up list was served from the informer cache of the apiserver replica that took the request. A cache that had not yet seen the snapshot go returned it as a live snapshot, and linstor-csi kept the definition.
LINSTOR answers the snapshot delete and every read after it from one in-memory model, so nothing read after the delete answered shows that snapshot. Two changes bring blockstor in line:
The store interface comment now names every reader of the uncached snapshot list, so nobody moves the per-definition list back onto the cache by following the old comment.
Release note
Existing orphaned definitions
This change prevents new orphans. It does not remove definitions that were already left behind, because linstor-csi never looks at them again. They have to be deleted by hand with
linstor rd d <name>. To find them, look for definitions that have no resources and no snapshots and whose PVC name property points at a PVC that no longer exists in the cluster. Check every candidate against the cluster before deleting it.Testing
TestSnapshotDeleteWaitsOutASlowOnlineSatellite: the snapshot's nodes are online and its copies go only after three times the wait budget. The delete must answer 200 and a GET right after must be 404. It fails without the change (504 at the budget) and fails the same way on the current alpha prerelease branch with the production 10 second budget, which matches the 504 seen on the test cluster.TestSnapshotDeleteGivesUpOnAnOfflineNode: one listed node is offline and the copy never goes. The delete must still answer 504 at the budget. It fails when the offline check is removed (the delete never answers).TestSnapshotDeleteGivesUpOnAnUnknownNode: the snapshot lists a node the store does not have. The delete must answer 504 at the budget. It fails when a missing node counts as online (the delete never answers).TestSnapshotDeleteAnswersASatelliteFailure: both nodes are online and one reports that deleting its copy failed. The delete must answer 500 before the budget with that node's error. It fails without the change (the delete never answers).TestSnapshotDeleteFailureIsRecorded(satellite): lvremove fails on a deleting snapshot, and the reconciler must record the failure for its node on the Snapshot status and keep the finalizer. It fails without the change.TestCRDToWireSnapshotCarriesDeleteFailureschecks the store passes the record on to the REST layer.TestSnapshotDrainIsNotProvedByAFailedRead: a cancelled read and a read that keeps failing must not end the wait as "gone". It fails without the change.TestGroupG/SnapOrphanCleanupplays the satellite by stripping the finalizer by hand after the delete. With the nodes online the delete now waits for that strip, so the case sends the delete in the background, checks it has not answered while the finalizer holds the snapshot, and that it answers 200 once the finalizer is gone. That check runs inside the 10 second budget, so it only shows the delete waits for the finalizer; waiting past the budget is shown by the unit tests, which shorten it.TestSnapshotListAfterDeleteDoesNotShowTheDeletedSnapshotuses a store whose cache still holds a snapshot the API server has already deleted, then runs linstor-csi's sequence: snapshot delete, then the per-definition list. It fails without the change (the deleted snapshot is listed without a DELETE flag) and passes with it.TestSnapshotGetAfterRetriedDeleteIsNotFounduses a cache that still serves the deleted snapshot for a couple of reads, retries the delete, then GETs the snapshot. It fails without the change (200 with the snapshot) and passes with it (404).make lint-config && make lint: 0 issues.go test ./...with envtest assets: all packages pass.-tags integration ./tests/integration/): the full run passed on the earlier revision of this PR, whereTestGroupFRAutoPlace3WithTieBreakertimed out once while the machine was loaded and passed on a rerun (it does not touch snapshots). After the latest changes, group G was rerun and passes.Not tested