Repository navigation
Conversation
The operator-crds Helm release was at about 97.6% of the 1 MiB limit on the Secret Helm stores each release in. Once it crosses the limit, helm install and upgrade fail. Every CRD serves the deprecated v1alpha1 next to v1beta1 with a full copy of the schema, and the field descriptions are most of that text and compress badly. The chart templates are now generated from a copy of the CRDs in which the descriptions of deprecated versions are removed. This brings the release to about 61% of the limit. Schemas, validation, defaults and the v1beta1 descriptions that kubectl explain shows by default are unchanged. files/crds keeps the full CRDs, so the release tarball and the API compatibility check are unaffected. A CI step now fails when the release goes above 90% of the limit, and a test checks against the real CRDs that the tool changes nothing besides descriptions of deprecated versions. The CRDs keep growing, so this buys headroom rather than removing the limit; the lasting fix is to stop serving v1alpha1. Closes stacklok#7456 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7466 +/- ##
==========================================
+ Coverage 82.98% 83.04% +0.05%
==========================================
Files 955 956 +1
Lines 99170 99426 +256
==========================================
+ Hits 82300 82564 +264
+ Misses 16865 16857 -8
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rdimitrov
left a comment
There was a problem hiding this comment.
The approach looks right to me: working on the typed schema, the byte-identical round-trip test over the real CRDs, and the CI size check. One issue before this goes in, inline below.
| func stripDeprecated(crd *apiextv1.CustomResourceDefinition) { | ||
| for i := range crd.Spec.Versions { | ||
| v := &crd.Spec.Versions[i] | ||
| if !v.Deprecated || v.Schema == nil { |
There was a problem hiding this comment.
deprecated: true doesn't only mean "the old copy of the schema". MCPRegistry is deprecated as a whole kind, so both v1alpha1 and v1beta1 carry deprecated: true, and v1beta1 is its storage version. This strips every description from MCPRegistry: the template goes from 60 description: lines on main to 0 on this branch, and kubectl explain mcpregistry loses all field docs.
That contradicts the PR body ("the v1beta1 descriptions are unchanged") and the user-facing section, which only mentions v1alpha1. TestProcessRealCRDs doesn't catch it because it only compares non-deprecated versions. The same thing will happen silently to any kind that gets deprecated as a whole later.
Suggest skipping the storage version as well, and asserting the same in the test:
if !v.Deprecated || v.Storage || v.Schema == nil {
continue
}if !v.Deprecated || v.Storage {
assert.Equal(t, v, dst.Spec.Versions[i], "version %s changed", v.Name)
}MCPRegistry is small, so this gives up very little of the savings. If dropping MCPRegistry's docs is intended because the kind is going away, please say so in the PR body and the user-facing section instead.
There was a problem hiding this comment.
Good catch, thanks. MCPRegistry was losing every description, and the test couldn't see it.
Fixed in 59db14e, with one change from your suggestion: the tool now keeps descriptions on the preferred version (the highest served version by version priority, which is what discovery advertises and kubectl explain shows by default) instead of the storage version. For today's CRDs that gives exactly the same output, and MCPRegistry's v1beta1 has its 30 descriptions back. The two only differ during a migration to v1, when the deprecated v1beta1 would still be the storage version. A storage rule would then keep a second full copy of the docs nobody reads by default, and a kind deprecated as a whole while storing its older version would lose the docs kubectl explain shows.
The real-CRD test now checks that the preferred version is unchanged, and works it out by sorting instead of calling the tool's helper. There are also fixtures for a kind deprecated as a whole and for the v1 migration; both fail if I swap the storage rule back in.
MCPRegistry is deprecated as a whole kind, so both of its versions are marked deprecated. Stripping every deprecated version removed all of its field docs, and kubectl explain mcpregistry showed none. Keep the descriptions of the preferred version: the served version with the highest version priority, which API discovery advertises and kubectl explain shows by default. Strip only the other deprecated versions. Keying on the storage version would give the same result today, but not during a migration to v1, when an older, deprecated version is still stored: it would keep docs nobody reads by default, and a kind deprecated as a whole could lose the docs users do read. The test over the real CRDs now checks that the preferred version is unchanged, and two fixtures cover a kind deprecated as a whole and a v1 migration. Also cover run() with tests. Co-authored-by: Mecatl <noreply@mecatl.dev>
|
@rdimitrov, following up since this has been quiet since our reply on the MCPRegistry thread this morning. We kept the descriptions on the preferred version rather than the storage version, and the thread has the reasoning. If you still think the storage rule is the better one, tell us why and we'll switch it. Could you take another look when you get a chance? |
Summary
The
operator-crdsHelm release was at about 97.6% of the 1 MiB limit on the Secret Helm stores each release in (#7456). Any change adding about 25 KB, such as a few new auth fields, breakshelm installandhelm upgradeof the chart. Most CRDs serve the deprecatedv1alpha1next tov1beta1with a full copy of the schema, and the field descriptions are most of that text and compress badly.task operator-manifestsstill writes the full CRDs tofiles/crds. The chart templates are now built from a copy in which the schema descriptions are removed from every deprecated version except the preferred one, by a small tool incmd/thv-operator/crd-strip-descriptions. The preferred version is the served version with the highest version priority: the one API discovery advertises andkubectl explainshows by default.v1beta1descriptions are unchanged. That includes MCPRegistry, which is deprecated as a whole kind: itsv1beta1is preferred, so it keeps its docs.files/crdskeeps every description, so the release tarball and the API compatibility check are unaffected.v1in which a deprecatedv1beta1is still the storage version. CI's existing templates diff can't catch a lossy tool on its own, because the tool produces both sides of that diff.Closes #7456
Type of change
Test plan
Unit tests (
task test)E2E tests (
task test-e2e)Linting (
task lint-fix)Manual testing (describe below)
Ran the
crd-strip-descriptionspackage tests with-race, including the new test over the real CRDs, andgolangci-linton that package.Swapped in a storage-version rule instead of the preferred-version rule (through a Go build overlay). The kind-deprecated-as-a-whole and
v1migration cases fail, so the tests tell the two rules apart.Regenerated the templates from
files/crdsand diffed them against the committed ones: no differences.Rendered the chart before and after with
helm template. After removing only schema description strings from the deprecated versions of the old output, the two are identical across all 14 CRDs.On a kind cluster, with the first commit (before MCPRegistry's
v1beta1docs were kept):check-release-size.shcomes within 0.1-0.5% above the real size.v1alpha1deprecation warning is still shown.kubectl explain:v1beta1keeps its descriptions, andv1alpha1has none.API Compatibility
v1beta1API, OR theapi-break-allowedlabel is applied and the migration guidance is described above.Changes
cmd/thv-operator/crd-strip-descriptions/cmd/thv-operator/Taskfile.ymloperator-manifestsbuilds the templates from a stripped copy offiles/crdsdeploy/charts/operator-crds/templates/v1alpha1removed)deploy/charts/operator-crds/hack/check-release-size.sh.github/workflows/helm-charts-test.ymldeploy/charts/operator-crds/CONTRIBUTING.md,.helmignorehack/out of the packaged chart.github/workflows/api-compat.yml,secrets_admission_test.goDoes this introduce a user-facing change?
Yes, small.
kubectl explain --api-version=toolhive.stacklok.dev/v1alpha1 <kind>showed field descriptions.The default
kubectl explain(v1beta1) is unchanged, and so is the behaviour of every resource.Special notes for reviewers
v1alpha1, whichCONTRIBUTING.mdnow says.v1: the deprecatedv1beta1would still be the storage version, so a storage rule would keep a second full copy of the docs thatkubectl explaindoesn't show by default.crd:maxDescLen=0would save more, but it also removes thev1beta1docs.crds/directory stops Helm from upgrading them.v1alpha1schemas have no descriptions, while thethv-crds.tar.gzrelease asset keeps them. Applying the tarball withkubectl apply --server-sideover a Helm-managed install now conflicts on.spec.versionseven at the same release (--force-conflictsresolves it). Mixing the two methods already conflicted across releases, and the docs only describe Helm.