Skip to content

👷 fix(chart,ci): ship CRDs that match the API, and gate the drift - #299

Merged
konih merged 2 commits into
mainfrom
fix/perf-fix-08-chart-crd-drift-gate
Aug 16, 2026
Merged

konih merged 2 commits into
mainfrom
fix/perf-fix-08-chart-crd-drift-gate

Conversation

@konih

@konih konih commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

PERF-FIX-08

The publishable Helm chart carries its own copy of the CRDs in charts/kollect/crds/, and nothing on the merge path regenerated it. hack/helm-sync-crds.sh is called only by hack/release-assets.sh — so drift could only surface at release time, by which point it is already baked into whatever is being cut.

Found while implementing PERF-FIX-05, verified independently on main.

The drift — 71 lines of real schema

CRD Missing
kollectclusterinventories +27
kollectinventories +27
kollecttargets +9 — extractionFailures, lastExtractionError
kollectclusterscopes +8

The kollecttargets gap shows why it matters. The operator writes status.extractionFailures and status.lastExtractionError. A chart whose CRD does not declare them means the API server prunes both on write — so the operator appears to simply never report extraction failures. No error, no event, no clue. It fails quietly, which is the worst way for a schema to be wrong.

Fix — and the half that lasts

  1. Sync the four CRDs, repairing the shipped chart.
  2. Gate it. hack/verify.sh already regenerates and diffs config/crd/bases, config/rbac/role.yaml, and the deepcopy files. The chart copy now gets the same treatment. That is the natural home: task verify runs it, and preflight runs that — a required check. Drift now fails on the PR that introduces it, naming hack/helm-sync-crds.sh in the failure message.

Proven in that order

  • Red first: with the drift present, hack/verify.sh exits non-zero and prints the missing extractionFailures/lastExtractionError block.
  • Green after: post-sync it exits 0.
  • task helm-test — 9 suites, 40 tests, passing.

PERF-FIX-08. The publishable Helm chart carries its own copy of the CRDs in
`charts/kollect/crds/`, and nothing on the merge path regenerated it.
`hack/helm-sync-crds.sh` is called only by `hack/release-assets.sh`, so drift
could only surface at release time -- long after it was introduced, and by then
already baked into whatever was being cut.

Four chart CRDs had drifted behind `config/crd/bases`, 71 lines of real schema:

  kollectclusterinventories  +27
  kollectinventories         +27
  kollecttargets             +9   (extractionFailures, lastExtractionError)
  kollectclusterscopes       +8

The `kollecttargets` gap is the one that shows why this matters. The operator
writes `status.extractionFailures` and `status.lastExtractionError`; a chart
whose CRD does not declare them means the API server prunes both on write. The
operator then looks like it simply never reports extraction failures -- no error,
no event, no clue. It fails quietly, which is the worst way for a schema to be
wrong.

So the fix is two halves, and the gate is the half that lasts:

- Sync the four CRDs, repairing the shipped chart.
- Extend `hack/verify.sh` -- which already regenerates and diffs `config/crd/bases`,
  `config/rbac/role.yaml` and the deepcopy files -- to do the same for the chart
  copy. It is the natural home: `task verify` runs it, and `preflight` runs that,
  which is a required check. Drift now fails on the PR that introduces it and
  names `hack/helm-sync-crds.sh` in the failure.

Proven in that order: with the drift present `hack/verify.sh` exits non-zero and
prints the missing `extractionFailures`/`lastExtractionError` block; after the
sync it exits 0. `task helm-test` stays green (9 suites, 40 tests).
@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…gate

Independent review found the drift gate had a blind spot large enough to ship
through. `hack/helm-sync-crds.sh` did `cp -f`, which only ever adds and
overwrites. A CRD renamed or removed upstream would linger in
`charts/kollect/crds/` forever -- and because the stale file is present both in
the pre-sync snapshot and after the sync, `diff -ru` sees no difference and the
new gate reports clean. Reproduced: copying an existing CRD to `zz-orphan.yaml`
left `hack/verify.sh` exiting 0 while the chart carried a phantom CRD.

Clearing the destination first makes the copy a true mirror, so deletions
propagate and the gate can see them. Same reproduction now fails correctly with
`Only in .../charts/kollect/crds: zz-orphan.yaml`.

The review also flagged that AGENTS.md's two enumerations of what `task verify`
gates are wrong in both directions -- they list "mocks", which `hack/verify.sh`
has never checked, and omit the chart CRD copy. That file is gitignored
(.gitignore:12), so it is a local operator note rather than a shipped contract;
corrected locally, deliberately not part of this commit.
@konih
konih force-pushed the fix/perf-fix-08-chart-crd-drift-gate branch from dbfbe5f to f14d342 Compare August 16, 2026 07:55
@sonarqubecloud

Copy link
Copy Markdown

@konih
konih merged commit 39d4cff into main Aug 16, 2026
34 checks passed
@konih
konih deleted the fix/perf-fix-08-chart-crd-drift-gate branch August 16, 2026 08:05
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