Skip to content

🐛 fix(export): stop silent oversize drops and torn relational snapshots (K-01/K-02/K-03/K-31) - #378

Merged
konih merged 1 commit into
mainfrom
fm/kollect-b1-export
Oct 1, 2026
Merged

konih merged 1 commit into
mainfrom
fm/kollect-b1-export

Conversation

@konih

@konih konih commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

TL;DR

  • What: Batch B1 of the review-unification fix plan — export correctness.
  • Why: A CRITICAL silent-data-loss path (K-01) and a destructive multipart path (K-02), plus a docs-truth fix (K-03).
  • Risk: Operator-visible behaviour change — exports above the 1 MiB inline cap now fail loudly instead of silently succeeding. Documented.
  • Reviewer action: Verify the inline-cap semantics in docs/crds/index.md; see the K-31 note below.

Summary

Closes the headline CRITICAL from the six-review unification (data/kollect-unify/report.md §4/§6), batch B1.

  • K-01 — RunExportEnvelope returned nil when a non-object-store backend could not take an envelope above the 1 MiB inline cap. The controller recorded Exported/Ready and suppressed re-export for up to 24 h: silent data loss with green telemetry. It now returns a terminal sink.ErrSpillRequired, mapped to Degraded/SpillRequired and kollect_sink_errors_total{reason="spill_required"}; the coalesce checksum is not recorded, so a later reconcile can retry.
  • K-02 — PartitionEnvelopes ran for every binding family. Postgres/Mongo/BigQuery diff-delete per part and event sinks stream per part, so part N erased/shadowed part N-1. Multipart now applies only to SinkFamilySnapshot; database and event sinks get one complete payload. Their per-binding maxExportBytes becomes a soft bound, surfaced by a new ExportCeilingExceeded Warning event.
  • K-03 — docs no longer describe an object-store "spill" mechanism that does not exist; they describe the inline cap and the loud skip (captain call C-3b).
  • K-31 — register gap. The findings register (§4) contains no K-31 entry; the ID appears only in the batch table (§6). IDs K-27/K-31/K-43 are absent while the report claims 82 findings (79 present + 3 gaps). The fix covers the whole export surface — sink boundary plus both controller call sites — and the gap is recorded in specs/001-export-correctness/evidence/K-31.md. The register owner should either define or drop K-31.

Test lock (end-to-end size band)

internal/controller/export_size_band_test.go:

  1. TestExportSizeBand_gitOnlyOversizeDegrades — git-only 1.2 MiB → Degraded/SpillRequired, sink receives nothing, never Exported.
  2. TestExportSizeBand_gitPostgresMixedNotSilentlyGreen — mixed binding, no sink reads green.
  3. TestExportSizeBand_postgresCeilingKeepsAllRows — postgres-only, 500 KiB per-binding ceiling, ~700 KiB snapshot → exactly one complete payload, all rows survive.

Plus TestRunExportEnvelope_oversizedNonObjectStoreFailsLoudly, ..._oversizedObjectStoreExports, TestWarnSoftCeilingExceeded, and the spill_required metric-label assertion.

Risk / behaviour change

  • Oversize payloads to non-object-store sinks now degrade instead of silently succeeding. This is the point of K-01; documented in REQUIREMENTS.md, ADR-0103, ADR-0405, crds/index.md, and operator docs.
  • A Git binding carrying more than 1 MiB in total should set its per-binding maxExportBytes at or below 1 MiB so every multipart part stays under the cap; otherwise the oversize part fails SpillRequired.

Testing

  • go test ./internal/sink/ ./internal/export/ — pass
  • KUBEBUILDER_ASSETS=bin/k8s/1.36.2-darwin-arm64 go test ./internal/controller/ — pass
  • bin/golangci-lint run ./internal/sink/... ./internal/export/... ./internal/controller/... — 0 issues

Scope

Only batch B1 findings are touched. Total-failure per-sink status persistence is deliberately left to B8 (status truth); noted in the test comments.

@codecov

codecov Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/controller/export_spill.go 83.33% 1 Missing and 1 partial ⚠️
...l/controller/kollectclusterinventory_controller.go 75.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

K-01: a non-object-store sink asked to deliver an envelope above the 1 MiB
inline cap returned success while writing nothing, so the controller recorded
Exported/Ready and suppressed re-export. RunExportEnvelope now returns a
terminal ErrSpillRequired, mapped to Degraded/SpillRequired and the
kollect_sink_errors_total{reason="spill_required"} label; the coalesce checksum
is not recorded on failure.

K-02: PartitionEnvelopes ran for every family, so database/event sinks got
parts whose diff-delete/stream erased each other. Multipart now applies only to
snapshot-family bindings; database and event sinks receive one complete payload.
Their per-binding maxExportBytes becomes a soft bound, surfaced by an
ExportCeilingExceeded Warning event.

K-03: docs describe the inline cap and the loud skip instead of an object-store
spill mechanism that does not exist (captain call C-3b).

K-31: the findings register has no K-31 entry (ID appears only in the batch
table; K-27/K-31/K-43 are absent while the report claims 82 findings). The fix
covers both export call sites; the gap is recorded in specs/evidence/K-31.md.

Test lock: internal/controller/export_size_band_test.go covers git-only 1.2 MiB
-> Degraded/SpillRequired, git+postgres mixed (no sink green), and postgres-only
500 KiB ceiling -> all rows survive.
@konih
konih force-pushed the fm/kollect-b1-export branch from 534dd10 to c4a810d Compare October 1, 2026 16:00
@konih
konih merged commit 79b841c into main Oct 1, 2026
38 of 39 checks passed
@konih
konih deleted the fm/kollect-b1-export branch October 1, 2026 16:09
@sonarqubecloud

sonarqubecloud Bot commented Oct 1, 2026

Copy link
Copy Markdown

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