Repository navigation
fix(satellite): leave DRBD slots alone unless blockstor provably owns them - #272
Conversation
The orphan sweeper treated a failed read of its own Node as "no opt-out" and a failed ResourceDefinition list as "no RD inside the grace window", and swept anyway. Both are guesses in the direction that destroys data: the skip annotation is the only way an operator can stop the sweeper, and a slot inside the grace window is one the controller is still creating or the satellite is still deleting. Skip the cycle and report instead. A missing Node counts as unreadable, and an annotation value that does not parse as a bool counts as an opt-out we cannot read. The price is one cycle of delay on a genuine orphan. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The sweeper downs a kernel slot without a Resource CRD only when blockstor's StateDir holds an ownership marker for it, so that a co-resident DRBD manager's resources survive. Three paths read "we do not know" as "ours": a marker probe failing with anything but ENOENT (EACCES, EIO) counted as owned; os.Stat followed a symlink or accepted a directory under the marker's name; and an empty StateDir turned the marker check off, so every slot without a CRD was an orphan. On a node being migrated from LINSTOR any of these downs a live resource, which the reconciler cannot rebuild because it was never blockstor's. Only a regular file under a marker name now proves ownership; a probe error, a marker of another kind or a kernel name that is not a plain file name leaves the slot up and logs why. One marker proving ownership still wins over the other failing to probe. Without a StateDir the sweeper sweeps nothing and says so every cycle. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The .res GC downs a loaded kernel slot before unlinking a stale `<rd>.res`, and it accepted any non-directory entry, a symlink included. blockstor writes its .res files with os.WriteFile, so a link in StateDir was put there by something else, for example to expose another manager's config to drbdadm, and the slot behind it is not the GC's to down. Skip such entries and log them, matching the regular-file rule the kernel-slot sweep now applies to its markers. 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 38 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.
Every path that used to fall through to a teardown now needs positive proof, and the production wiring keeps the genuine-orphan path alive: manager.go passes cfg.Apply.StateDir() to the sweeper, so the empty-StateDir refusal only affects an explicit --state-dir=. .owned is stamped on every render and survives the startup .res wipe, so slots blockstor brought up still classify as owned after a restart.
The red Integration job is TestGroupFRToggleDiskful2DisklessReapsTieBreaker timing out. It fails the same way on unrelated branches, and the sweeper is not on that path.
What this PR does
The satellite's DRBD orphan sweeper runs
drbdsetup downon kernel slots it decides blockstor owns but no Resource CRD covers. Several paths reached that decision from missing information rather than evidence. On a node where another DRBD manager is still running, LINSTOR during a migration for example, any of them can take down a live resource that blockstor never owned and cannot rebuild. With this change the sweeper fails closed: if it cannot prove ownership it leaves the slot up and logs why, and if it cannot read its inputs it skips the whole cycle and reports it.Fixed paths, all in
pkg/satellite/controllers/sweeper.goandsweeper_resfile.go:yes, an empty string) was read as "not opted out". It now skips the cycle with an error. Any spellingstrconv.ParseBoolreads as true still opts out.os.Stat, so a symlink or a directory under a marker's name counted as ownership. Only a regular file counts now, checked withos.Lstat. A kernel name that is not a plain file name is treated as unknown, since joining it onto StateDir could probe a path outside StateDir.--state-dir=explicitly..resGC, which downs a loaded slot before it unlinks a stale.res, accepted symlinked.resentries. It now skips them and logs them.A genuine orphan, meaning a slot with no CRD, a regular ownership marker, readable inputs and no opt-out, is still torn down as before.
The change touches only the DRBD sweeper and its tests, plus one stale doc comment on
Reconciler.StateDir(). Manager wiring and the storage sweeper are not touched, so it does not conflict with the storage sweeper removal in #271.Testing
sweeper_failclosed_test.gouse a fake client with interceptors and a fakelstat. They cover: Node read error and missing Node (cycle skipped, no kernel calls,.resGC not run); the annotation values table; RD list error (cycle skipped); EACCES and EIO on one or both markers (slot left up, reported as unknown) and EIO on one marker with the other present (still torn down); a symlink or a directory as the marker; non-plain kernel names; no StateDir; a symlinked.resin the GC; and a control showing that the same fixture with readable inputs does down its orphan and collect its stale.res.make lint-config && make lint: 0 issues.go test ./...with envtest assets: green, including the provenance guard inpkg/naming/guard_test.go.go test -race -count=3.Not tested
lstathook, not produced by a real filesystem.