Skip to content

✨ feat(sink): retract exports on inventory deletion via deletionPolicy - #383

Merged
konih merged 2 commits into
mainfrom
fm/kollect-382-fix
Oct 1, 2026
Merged

konih merged 2 commits into
mainfrom
fm/kollect-382-fix

Conversation

@konih

@konih konih commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Add an ExportCleaner/DeleteExport path across the git, gitlab, s3, gcs, and local sinks that removes an inventory's exported objects (plus deterministic .part-NNNN-of-NNNN siblings) 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.
  • Un-wedge finalization: treat an already-deleted bound sink as CleanupSinkGone and non-retractable backends as CleanupRetained (announced via Warning Events rather than blocking), add kollect_cleanup_terminal_total plus a 5-minute re-check for terminal cleanups, and add the kollect.dev/force-cleanup annotation to drop the finalizer without backend contact.
  • Harden the git deletion engine: clear shared warm-mirror dirt before checkout, scope the cleanup commit to only the removed paths so foreign staged state cannot ride along, key the export lock on mirror identity rather than push branch, base synthesized branches on the clone tip, and only deliver a stranded deletion commit when the remote push tip is fast-forwardable.

Risk Assessment

⚠️ Medium: The change is broad and operates on destructive deletion/push/finalizer paths, but every required intent constraint is satisfied and no concrete reachable residual defect could be substantiated after verifying the prior rounds' fixes.

Testing

Stood up a real git http-backend CGI server and drove the actual Backend.ExportFilesWithBranch/DeleteExportWithBranch code (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.

  • Live validation: ✅ go - 10 of 12 scenarios driven live against the product
Scenario Result Live Evidence
CLI engine: deleting inventory B on a shared warm mirror holding inventory A's crashed-export staged dirt must not commit/push A's files and must still retract B ✅ pass live TestDeleteExportWithBranch_CLISharedMirror_DoesNotSweepCrashedExportStagedAdds (integration, real git HTTP server + real git CLI), PASS in final-targeted-integration.log
go-git engine: deleting inventory B on a shared warm mirror holding inventory A's crashed-export staged dirt must not commit/push A's files ✅ pass live TestDeleteRemote_GoGitSharedMirror_DoesNotSweepCrashedExportStagedAdds (integration), PASS
CLI MR-mode: a deletion commit stranded locally by a crash before push is delivered on retry ✅ pass live TestDeleteExportWithBranch_CLIMRMode_DeliversStrandedDeletionCommit (integration), PASS
CLI MR-mode: a stranded deletion commit is still delivered after another inventory's export moved the mirror HEAD ✅ pass live TestDeleteExportWithBranch_CLIMRMode_DeliversStrandedDeletionAfterForeignExport (integration), PASS
go-git MR-mode: a deletion commit stranded locally by a crash before push is delivered on retry ✅ pass live TestDeleteRemote_MRMode_DeliversStrandedDeletionCommit (integration), PASS
Adversarial: a pre-existing local push branch pointing at another inventory's tip (foreign or crashed-export-poisoned) must produce a no-op with no push and no MR-worthy branch, on both engines ✅ pass live TestDeleteRemote_MRMode_ForeignTipIsNoOp, TestDeleteExportWithBranch_CLIMRMode_ForeignTipIsNoOp, TestDeleteRemote_MRMode_PoisonedForeignBranchIsNoOp, TestDeleteExportWithBranch_CLIMRMode_PoisonedForei…
When cleanup candidates match on disk, the deletion commit must base on the clone tip, never on another inventory's unmerged foreign tip, on both engines ✅ pass live TestDeleteRemote_MRMode_DeletionCommitBasesOnCloneTipNotForeignTip and TestDeleteExportWithBranch_CLIMRMode_DeletionCommitBasesOnCloneTipNotForeignTip (integration), both PASS
Adversarial merge-blocker F2: a shared warm mirror holding uncommitted tracked dirt absent from the target branch must not wedge a CLI deletion; the deletion completes and the dirt is discarded ✅ pass live TestDeleteExportWithBranch_CLISharedMirror_TrackedDirtDoesNotBlockDeletion (integration), PASS; pre-fix ordering reproduced the exact 'Your local changes ... would be overwritten by checkout' abort (r…
A shared mirror with untracked leftover candidate dirt produces a no-op, never a bogus deletion commit ✅ pass live TestDeleteExportWithBranch_CLISharedMirror_UntrackedDirtIsNoOp (integration), PASS
F3: deleting an inventory whose export has ≥10000 parts must retract all part siblings (not silently retain them while reporting a clean tombstone) ✅ pass live live probe of real local.Backend.DeleteExport: base plus part-0001-of-10000, part-10000-of-10000, part-12345-of-67890 all removed, hand-named part-1-of-3 and sibling inventory retained; pre-fix 4-digi…
G1: a go-git worktree removal must tolerate an untracked candidate leftover without erroring or producing an empty commit ⏸️ untested no No live-exercisable path: on pinned go-git v5.19.2 the live delete path's HardReset clears untracked files first, so the ErrEntryNotFound branch is version-robustness hardening only. The unit test is…
Operator/controller deletion finalization: missing sink no longer wedges (K-29), terminal cleanup self-heals within minutes via requeue (K-30), and retention is announced (K-28) ⏸️ untested no envtest binaries are absent (KUBEBUILDER_ASSETS unset, no bin/k8s or setup-envtest) and no Kubernetes cluster is available in this worktree, so the controller could not be driven against a real API se…
Evidence: Final targeted integration run (all 17 git/objectstore delete scenarios PASS)
=== RUN   TestDeleteExportWithBranch_CLISharedMirror_DoesNotSweepCrashedExportStagedAdds
--- PASS: TestDeleteExportWithBranch_CLISharedMirror_DoesNotSweepCrashedExportStagedAdds (8.23s)
=== RUN   TestDeleteExportWithBranch_CLISharedMirror_UntrackedDirtIsNoOp
--- PASS: TestDeleteExportWithBranch_CLISharedMirror_UntrackedDirtIsNoOp (5.70s)
=== RUN   TestDeleteRemote_MRMode_DeliversStrandedDeletionCommit
--- PASS: TestDeleteRemote_MRMode_DeliversStrandedDeletionCommit (3.18s)
=== RUN   TestDeleteRemote_MRMode_PointerOnlyBranchIsNoOp
--- PASS: TestDeleteRemote_MRMode_PointerOnlyBranchIsNoOp (2.20s)
=== RUN   TestDeleteRemote_MRMode_ForeignTipIsNoOp
--- PASS: TestDeleteRemote_MRMode_ForeignTipIsNoOp (2.46s)
=== RUN   TestDeleteExportWithBranch_CLIMRMode_ForeignTipIsNoOp
--- PASS: TestDeleteExportWithBranch_CLIMRMode_ForeignTipIsNoOp (4.93s)
=== RUN   TestDeleteRemote_MRMode_PoisonedForeignBranchIsNoOp
--- PASS: TestDeleteRemote_MRMode_PoisonedForeignBranchIsNoOp (3.65s)
=== RUN   TestDeleteExportWithBranch_CLIMRMode_PoisonedForeignBranchIsNoOp
--- PASS: TestDeleteExportWithBranch_CLIMRMode_PoisonedForeignBranchIsNoOp (8.96s)
=== RUN   TestDeleteExportWithBranch_CLIMRMode_DeliversStrandedDeletionCommit
--- PASS: TestDeleteExportWithBranch_CLIMRMode_DeliversStrandedDeletionCommit (12.90s)
=== RUN   TestDeleteRemote_GoGitSharedMirror_DoesNotSweepCrashedExportStagedAdds
--- PASS: TestDeleteRemote_GoGitSharedMirror_DoesNotSweepCrashedExportStagedAdds (4.27s)
=== RUN   TestDeleteRemote_MRMode_DeletionCommitBasesOnCloneTipNotForeignTip
--- PASS: TestDeleteRemote_MRMode_DeletionCommitBasesOnCloneTipNotForeignTip (10.23s)
=== RUN   TestDeleteExportWithBranch_CLIMRMode_DeletionCommitBasesOnCloneTipNotForeignTip
--- PASS: TestDeleteExportWithBranch_CLIMRMode_DeletionCommitBasesOnCloneTipNotForeignTip (13.80s)
=== RUN   TestDeleteExportWithBranch_CLIMRMode_DeliversStrandedDeletionAfterForeignExport
--- PASS: TestDeleteExportWithBranch_CLIMRMode_DeliversStrandedDeletionAfterForeignExport (7.93s)
=== RUN   TestDeleteExportWithBranch_CLISharedMirror_TrackedDirtDoesNotBlockDeletion
--- PASS: TestDeleteExportWithBranch_CLISharedMirror_TrackedDirtDoesNotBlockDeletion (9.69s)
=== RUN   TestDeleteExportWithBranch_RemovesDocumentAndPartSiblings
--- PASS: TestDeleteExportWithBranch_RemovesDocumentAndPartSiblings (5.07s)
=== RUN   TestDeleteExportWithBranch_NothingMatchedIsNoop
--- PASS: TestDeleteExportWithBranch_NothingMatchedIsNoop (2.69s)
=== RUN   TestDeleteRemote_GoGitEngineRemovesFiles
--- PASS: TestDeleteRemote_GoGitEngineRemovesFiles (2.38s)
=== RUN   TestRemoveWorktreeCandidates_UntrackedDirtIsTolerated
--- PASS: TestRemoveWorktreeCandidates_UntrackedDirtIsTolerated (0.02s)
=== RUN   TestRemoteBranchExists
--- PASS: TestRemoteBranchExists (1.53s)
=== RUN   TestRemoteBranchExists_rejectsInvalidRef
--- PASS: TestRemoteBranchExists_rejectsInvalidRef (1.11s)
PASS
ok  	github.com/platformrelay/kollect/internal/sink/git	111.974s
=== RUN   TestCleanupMatchers
=== PAUSE TestCleanupMatchers
=== CONT  TestCleanupMatchers
=== RUN   TestCleanupMatchers/default_json_path_matches_itself_and_part_siblings
=== PAUSE TestCleanupMatchers/default_json_path_matches_itself_and_part_siblings
=== RUN   TestCleanupMatchers/extensionless_path
=== PAUSE TestCleanupMatchers/extensionless_path
=== RUN   TestCleanupMatchers/custom_template_path_with_name_infix
=== PAUSE TestCleanupMatchers/custom_template_path_with_name_infix
=== RUN   TestCleanupMatchers/parquet_hive_partition_sweeps_generations_and_part_variants
=== PAUSE TestCleanupMatchers/parquet_hive_partition_sweeps_generations_and_part_variants
=== RUN   TestCleanupMatchers/five-digit_part_totals_and_indexes_match
=== PAUSE TestCleanupMatchers/five-digit_part_totals_and_indexes_match
=== RUN   TestCleanupMatchers/empty_path_yields_no_matchers
=== PAUSE TestCleanupMatchers/empty_path_yields_no_matchers
=== CONT  TestCleanupMatchers/default_json_path_matches_itself_and_part_siblings
=== CONT  TestCleanupMatchers/parquet_hive_partition_sweeps_generations_and_part_variants
=== CONT  TestCleanupMatchers/custom_template_path_with_name_infix
=== CONT  TestCleanupMatchers/extensionless_path
=== CONT  TestCleanupMatchers/five-digit_part_totals_and_indexes_match
=== CONT  TestCleanupMatchers/empty_path_yields_no_matchers
--- PASS: TestCleanupMatchers (0.00s)
    --- PASS: TestCleanupMatchers/default_json_path_matches_itself_and_part_siblings (0.00s)
    --- PASS: TestCleanupMatchers/custom_template_path_with_name_infix (0.00s)
    --- PASS: TestCleanupMatchers/parquet_hive_partition_sweeps_generations_and_part_variants (0.00s)
    --- PASS: TestCleanupMatchers/five-digit_part_totals_and_indexes_match (0.00s)
    --- PASS: TestCleanupMatchers/extensionless_path (0.00s)
    --- PASS: TestCleanupMatchers/empty_path_yields_no_matchers (0.00s)
PASS
ok  	github.com/platformrelay/kollect/internal/sink/objectstore	0.355s
Evidence: First full git delete integration run
=== RUN   TestDeleteExportWithBranch_CLISharedMirror_DoesNotSweepCrashedExportStagedAdds
--- PASS: TestDeleteExportWithBranch_CLISharedMirror_DoesNotSweepCrashedExportStagedAdds (16.79s)
=== RUN   TestDeleteExportWithBranch_CLISharedMirror_UntrackedDirtIsNoOp
--- PASS: TestDeleteExportWithBranch_CLISharedMirror_UntrackedDirtIsNoOp (6.44s)
=== RUN   TestDeleteRemote_MRMode_DeliversStrandedDeletionCommit
--- PASS: TestDeleteRemote_MRMode_DeliversStrandedDeletionCommit (3.66s)
=== RUN   TestDeleteRemote_MRMode_PointerOnlyBranchIsNoOp
--- PASS: TestDeleteRemote_MRMode_PointerOnlyBranchIsNoOp (1.91s)
=== RUN   TestDeleteRemote_MRMode_ForeignTipIsNoOp
--- PASS: TestDeleteRemote_MRMode_ForeignTipIsNoOp (2.82s)
=== RUN   TestDeleteExportWithBranch_CLIMRMode_ForeignTipIsNoOp
--- PASS: TestDeleteExportWithBranch_CLIMRMode_ForeignTipIsNoOp (4.95s)
=== RUN   TestDeleteRemote_MRMode_PoisonedForeignBranchIsNoOp
--- PASS: TestDeleteRemote_MRMode_PoisonedForeignBranchIsNoOp (4.17s)
=== RUN   TestDeleteExportWithBranch_CLIMRMode_PoisonedForeignBranchIsNoOp
--- PASS: TestDeleteExportWithBranch_CLIMRMode_PoisonedForeignBranchIsNoOp (5.46s)
=== RUN   TestDeleteExportWithBranch_CLIMRMode_DeliversStrandedDeletionCommit
--- PASS: TestDeleteExportWithBranch_CLIMRMode_DeliversStrandedDeletionCommit (6.09s)
=== RUN   TestDeleteRemote_GoGitSharedMirror_DoesNotSweepCrashedExportStagedAdds
--- PASS: TestDeleteRemote_GoGitSharedMirror_DoesNotSweepCrashedExportStagedAdds (3.08s)
=== RUN   TestDeleteRemote_MRMode_DeletionCommitBasesOnCloneTipNotForeignTip
--- PASS: TestDeleteRemote_MRMode_DeletionCommitBasesOnCloneTipNotForeignTip (5.43s)
=== RUN   TestDeleteExportWithBranch_CLIMRMode_DeletionCommitBasesOnCloneTipNotForeignTip
--- PASS: TestDeleteExportWithBranch_CLIMRMode_DeletionCommitBasesOnCloneTipNotForeignTip (11.08s)
=== RUN   TestDeleteExportWithBranch_CLIMRMode_DeliversStrandedDeletionAfterForeignExport
--- PASS: TestDeleteExportWithBranch_CLIMRMode_DeliversStrandedDeletionAfterForeignExport (8.29s)
=== RUN   TestDeleteExportWithBranch_CLISharedMirror_TrackedDirtDoesNotBlockDeletion
--- PASS: TestDeleteExportWithBranch_CLISharedMirror_TrackedDirtDoesNotBlockDeletion (9.01s)
=== RUN   TestDeleteExportWithBranch_RemovesDocumentAndPartSiblings
--- PASS: TestDeleteExportWithBranch_RemovesDocumentAndPartSiblings (4.11s)
=== RUN   TestDeleteExportWithBranch_NothingMatchedIsNoop
--- PASS: TestDeleteExportWithBranch_NothingMatchedIsNoop (1.35s)
=== RUN   TestDeleteRemote_GoGitEngineRemovesFiles
--- PASS: TestDeleteRemote_GoGitEngineRemovesFiles (1.35s)
PASS
ok  	github.com/platformrelay/kollect/internal/sink/git	96.949s
Evidence: Before/after reproduction transcripts and scenario-to-test mapping
# PR 382 deletion-fix validation — live reproductions and results

Target commit: `c64ef9136728568607ab77cf5f13b4ac6829d733` (branch `fm/kollect-382-fix`)
Base commit: `3919327ee377069e7f2aec3f88c3f798b3762913`

## Live drive: real git HTTP server + real git CLI/go-git + real Backend.DeleteExport

Command:

`` `
go test -tags=integration -count=1 -v \
  -run 'TestDelete|TestRemoveWorktreeCandidates_UntrackedDirtIsTolerated|TestCleanupMatchers|TestRemoteBranchExists' \
  ./internal/sink/git/ ./internal/sink/objectstore/
`` `

All PASS (see `final-targeted-integration.log`). Each test stands up a real
`git http-backend` CGI server, seeds a bare repo, runs the actual
`Backend.ExportFilesWithBranch` / `Backend.DeleteExportWithBranch` code against a
persistent warm mirror, and asserts the resulting remote branch state with real
`git ls-remote` / clone.

## Before/after reproductions (regression locks bite)

\### R3 / F2 — tracked mirror dirt must not wedge CLI deletion
`TestDeleteExportWithBranch_CLISharedMirror_TrackedDirtDoesNotBlockDeletion`

Temporarily restoring the pre-fix order (fetch+checkout before reset/clean in
`prepareCLIWorkdir`) makes it fail:

`` `
--- FAIL: TestDeleteExportWithBranch_CLISharedMirror_TrackedDirtDoesNotBlockDeletion (5.47s)
    delete_mirror_regression_test.go:870: DEFECT: tracked dirt wedged the CLI deletion: git checkout -B kollect/team-b/inv: error: Your local changes to the following files would be overwritten by checkout:
        	inventory/team-a/inv.json
        Please commit your changes or stash them before you switch branches.
        Aborting: exit status 1
`` `

With the fix (reset/clean before the branch switch): PASS.

\### F3 — ≥10000-part export must be retracted, not silently retained
Live drive of the real `local.Backend.DeleteExport` (temporary focused test):

Pre-fix matcher `(\.part-\d{4}-of-\d{4})?`:

`` `
--- FAIL: TestLive_F3_FiveDigitPartSiblingsRetracted (0.00s)
    zz_live_f3_test.go:39: deleted = [inventory/team-a/apps.json], want base + three >=4-digit part siblings
`` `

With the fix (`\d{4,}`): PASS — base file plus
`apps.part-0001-of-10000.json`, `apps.part-10000-of-10000.json`,
`apps.part-12345-of-67890.json` all removed; the hand-named `part-1-of-3` and the
sibling inventory's file retained.

\### G1 — untracked candidate tolerance (unit-level lock)
`TestRemoveWorktreeCandidates_UntrackedDirtIsTolerated`

Temporarily removing the `index.ErrEntryNotFound` tolerance makes it fail:

`` `
--- FAIL: TestRemoveWorktreeCandidates_UntrackedDirtIsTolerated (0.01s)
    delete_untracked_dirt_test.go:67: DEFECT: untracked dirt errored the go-git deletion: git remove "inventory/team-b/inv.json": entry not found
`` `

With the fix: PASS. This is a unit-level lock: on the pinned go-git the
`HardReset` in the live path removes untracked files, so the branch is
version-robustness hardening rather than a currently reachable live path.

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
konih force-pushed the fm/kollect-382-fix branch from 35f69d1 to 2c3385d Compare October 1, 2026 18:39
@konih konih changed the title feat(sink): retract exported objects on inventory deletion and harden git cleanup ✨ feat(sink): retract exported objects on inventory deletion and harden git cleanup Oct 1, 2026
@konih
konih force-pushed the fm/kollect-382-fix branch from 2c3385d to dc20d06 Compare October 1, 2026 19:58
@konih konih changed the title ✨ feat(sink): retract exported objects on inventory deletion and harden git cleanup ✨ feat(sink): retract exports on inventory deletion via deletionPolicy Oct 1, 2026
@konih
konih force-pushed the fm/kollect-382-fix branch from dc20d06 to 99a9215 Compare October 1, 2026 20:09
konih added 2 commits October 1, 2026 22:31
…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
konih force-pushed the fm/kollect-382-fix branch from 99a9215 to 273de93 Compare October 1, 2026 20:39
@sonarqubecloud

sonarqubecloud Bot commented Oct 1, 2026

Copy link
Copy Markdown

@konih
konih merged commit 577e265 into main Oct 1, 2026
40 checks passed
@konih
konih deleted the fm/kollect-382-fix branch October 1, 2026 20:49
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.

1 participant