Repository navigation
✨ feat(sink): retract exports on inventory deletion via deletionPolicy - #383
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
konih
added a commit
that referenced
this pull request
Oct 1, 2026
…implicit layout doubt Every deletion on a default git/gitlab sink (no explicit layout.mode) emitted a false-positive CleanupRetained warning even when the retraction fully succeeded, because the outcome check fell back to "an implicit tree is possible" for every non-explicit sink — alert noise that trains operators to ignore the warning, and the flip side: a pathTemplate/serialization change after the last export still yielded a silent false-clean tombstone. Persist the last-exported paths and decide on evidence: - InventorySinkExportStatus gains lastExportPaths: the sink-relative paths the last successful export actually wrote (document, layout sidecars, projected per-resource files; sorted, deduplicated, capped sample). RunExportEnvelope now returns its written paths and both inventory controllers record them, carrying the previous recording across debounced/failed reconciles. - RunCleanupExport consults the recorded state via the wired ExportCleaner seam: it consumes DeleteExport's deleted-path report, and retention is announced only when a recorded path is neither among the candidates nor in the deleted report — a changed pathTemplate/serialization format, or tree-shaped files no document-side candidate addresses. The ModeExplicit "implicit tree possible" heuristic is gone: a fully retracted default git/ gitlab sink is now a clean tombstone. - treeMode/staleGenerations/mrMediated stay structural: recorded paths only describe the last export, so past-generation objects, explicit non-document layouts, and unmerged deletion MRs are announced regardless. Regression coverage pins the false positive (a default git sink deletion that fully retracts must not emit CleanupRetained — verified failing against the pre-fix decision) and the false-clean tombstone (recorded path outside the candidates announces retention). Docs: troubleshooting.md drops the "consciously accepted limit, follow-up tracked" wording for the template/format case, and the CRD references document lastExportPaths. Stacks on #383; retargets to main when it merges.
konih
force-pushed
the
fm/kollect-382-fix
branch
from
October 1, 2026 18:39
35f69d1 to
2c3385d
Compare
konih
force-pushed
the
fm/kollect-382-fix
branch
from
October 1, 2026 19:58
2c3385d to
dc20d06
Compare
konih
force-pushed
the
fm/kollect-382-fix
branch
from
October 1, 2026 20:09
dc20d06 to
99a9215
Compare
…clone tip All inventories of a git/gitlab sink share one warm mirror worktree per (clone URL, clone branch), but exports locked on the push branch, so two merge-request inventories could drive the same worktree concurrently. Lock on the mirror identity instead. A push branch the mirror did not hold yet was created at the mirror's current HEAD, which on a shared branchMR mirror can be another inventory's unmerged feature tip, so a new branch could carry someone else's export. An existing branch was reset to that same HEAD (git checkout -B / go-git Create), dropping a commit it still had to deliver. Both engines now check out an existing push branch as-is and create a missing one from the fetched clone-branch tip. The CLI engine also clears warm-mirror dirt (reset --hard + clean -fd) before the fetch and branch switch, so a crashed operation's leftovers can neither block the checkout nor ride into the next commit; the reset never moves HEAD, so a stranded commit on an existing branch survives.
KollectSnapshotSink gains spec.deletionPolicy (ADR-0421): Retain, the
CRD default, or Delete. Admission rejects any other value and the
controller reads anything but an exact Delete as Retain.
Retain: inventory deletion leaves the sink's exported objects in place,
never builds the backend (a revoked credential cannot block it),
releases the finalizer and records a Normal CleanupRetainedByPolicy
event. This keeps the previous outcome for snapshot sinks, whose
backends skipped the empty cleanup export and left the objects as they
were.
Delete (K-28/C-2a): deletion retracts what the inventory exported - git
and gitlab via a deletion commit, s3/gcs/local by deleting objects -
including the .part-NNNN-of-NNNN siblings (4+ digit widths), layout
sidecars, and for parquet the inventory's hive partitions, among them
the name=<inv>.part-NNNN-of-NNNN/ partitions a multipart export writes.
Retraction is announced as CleanupRetained whenever it cannot be
proven: layout trees, {generation} templates, merge_request mode, a
recorded export path the cleanup no longer addresses, or an export from
before paths were recorded. InventorySinkExportStatus.lastExportPaths
records what the last successful export wrote and is carried across
debounced and failed reconciles, so a fully retracted default git sink
stays silent. A KollectClusterInventory X and a KollectInventory X in
namespace "cluster" share the identity inventory/cluster/X; while the
other exists, the retraction is skipped with a CleanupSharedIdentity
warning. A scope the operator never reconciles (tenant mode, namespace
"cluster" outside --watch-namespaces), NotFound and Forbidden are not
shared; any other lookup error is transient and keeps the finalizer.
Git deletion hardening: the CLI engine commits only the cleanup's own
paths, so crashed-export dirt in the shared warm mirror never rides
along. A deletion commit stranded by a crash between commit and push is
delivered only as a fast-forward from a branch that existed before the
retry; in direct mode, a remote that advanced past it resets the local
branch to the remote tip and the deletion is redone on top. A
merge-request feature branch missing from a cold mirror is fetched
from the remote, so the deletion lands on it instead of on a branch
synthesized from the target, where the unmerged export never existed.
Untracked leftovers in the go-git worktree are removed without failing
the index removal.
K-29: a sink CR deleted before its inventory no longer wedges deletion;
cleanup completes with a CleanupSinkGone event.
K-30: terminal cleanup failures keep the finalizer, re-check every 5
minutes so a Secret-only credential fix self-heals, and count each
attempt in kollect_cleanup_terminal_total. The kollect.dev/force-cleanup
annotation (honoured only while deleting) drops the finalizer without
backend contact and records CleanupForced.
konih
force-pushed
the
fm/kollect-382-fix
branch
from
October 1, 2026 20:39
99a9215 to
273de93
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Intent
The captain wants the Kollect PR 382 review findings fixed before it can merge. The double independent review did not pass: the adversarial leg returned BLOCK with two reproduced CRITICALs (the CLI deletion path commits crashed-export staged dirt into the user repo; MR-mode leaves a stranded deletion commit silently orphaned) and two warnings (a silent false-clean tombstone when a git sink's pathTemplate or serialization format changed after the last export - consciously accepted for this PR per the captain's recorded decision, with persisting the last-exported path filed as a follow-up; and a terminal cleanup wedge that only heals at the 12-hour informer resync when the fix is a Secret edit); the differential leg returned REQUEST CHANGES with a merge blocker F2 (shared-mirror dirt wedges CLI git deletion forever and is invisible to the new terminal-cleanup alert) plus F1 (foreign staged state committed and pushed under the deletion commit) and F3 (the part-sibling cleanup matcher hardcodes four digits, so exports with 10000 or more parts are silently retained while reporting a clean tombstone). PR 382 (#382) is ':sparkles: feat(sink): retract exported objects on inventory deletion, un-wedge finalization (K-28/K-29/K-30)', branch fm/kollect-b6-deletion -> main.
What Changed
ExportCleaner/DeleteExportpath across the git, gitlab, s3, gcs, and local sinks that removes an inventory's exported objects (plus deterministic.part-NNNN-of-NNNNsiblings) at deletion time, and widen the part-sibling matcher to any four-or-more digit width so exports with 10,000+ parts are actually retracted instead of reporting a clean tombstone.CleanupSinkGoneand non-retractable backends asCleanupRetained(announced via Warning Events rather than blocking), addkollect_cleanup_terminal_totalplus a 5-minute re-check for terminal cleanups, and add thekollect.dev/force-cleanupannotation to drop the finalizer without backend contact.Risk Assessment
Testing
Stood up a real git http-backend CGI server and drove the actual
Backend.ExportFilesWithBranch/DeleteExportWithBranchcode (CLI and go-git engines) on a persistent warm mirror, asserting remote branch state with real git ls-remote/clone: crashed-export staged/untracked dirt is never committed or pushed under a deletion commit, stranded deletion commits are delivered on retry (including after another inventory moved HEAD), foreign/poisoned pre-existing branch tips are no-ops with no MR-worthy branch, and matched-candidate deletion commits base on the clone tip not the foreign tip. Also drove the real local object-store backend to confirm a ≥10000-part export is fully retracted. All 17 targeted integration scenarios passed; three pre-fix reverts reproduced the original defects (tracked-dirt CLI wedge, 5-digit part retention, go-git untracked error) and were restored. Controller K-28/K-29/K-30 behavior is exercised only by fake-client unit tests because envtest binaries are unavailable, so it is reported untested-live rather than guessed. Working tree is clean.Evidence: Final targeted integration run (all 17 git/objectstore delete scenarios PASS)
Evidence: First full git delete integration run
Evidence: Before/after reproduction transcripts and scenario-to-test mapping