🐛 fix(olm): give every owned CRD an alm-examples entry - #311
Merged
Conversation
The CSV declared 11 owned CRDs but shipped only 2 alm-examples, so the OperatorHub hosted validator warned "provided API should have an example annotation" for the other 9, and the OpenShift console offered a blank YAML editor for most of the operator surface. Add the 9 missing examples, reusing config/samples/ specs where one exists, and make dist_olm_bundle_test.sh compare the alm-examples kind set against spec.customresourcedefinitions.owned on both the template and the generated bundle CSV. Both sides are asserted non-empty so a mistyped yq/jq path cannot pass vacuously, and duplicate kinds cannot mask a missing one. The two grep assertions this replaces matched the plain-YAML owned list, not the JSON annotation, so they never tested alm-examples at all. All 11 examples pass kubectl apply --dry-run=server --validate=strict against a cluster with config/crd/bases installed, and the set is mutually consistent under the scope admission floor.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
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.



Why
The upstream OperatorHub hosted validator warns
provided API should have an example annotationfor every owned CRD that has no entry inmetadata.annotations["alm-examples"]. Nine of the eleven owned kinds had none, so the OpenShift console and operatorhub.io "Create instance" flow handed users a blank YAML editor for all nine.What changed
All 11 owned CRDs now carry an
alm-examplesentry inconfig/olm/template/manifests/kollect.clusterserviceversion.yaml:KollectClusterInventory,KollectClusterScope,KollectClusterTarget,KollectConnectionTest,KollectDatabaseSink,KollectEventSink,KollectInventory,KollectProfile,KollectScope,KollectSnapshotSink,KollectTarget.Every example was validated two ways:
--validate=strict, so no field is misspelled or unknown to the CRD schema;The assertions this replaces were vacuous
hack/test/dist_olm_bundle_test.shpreviously asserted alm-examples coverage with two greps:Both search for the unquoted
kind: KollectProfileform, which only ever matched the plain-YAMLspec.customresourcedefinitions.ownedlist (line 349 of the CSV) — never the JSON inside the annotation, where the kind appears as"kind": "KollectProfile". Deleting the entirealm-examplesannotation left both greps passing. They never tested alm-examples at all.They are replaced by a set-comparison gate (
check_alm_examples) that:alm-examplesJSON and the kind set fromspec.customresourcedefinitions.owned, and requires them to be equal — so a newly owned CRD cannot ship without an example;yq/jqpath fails loudly instead of comparing two empty sets and passing vacuously;sedpass, so a template-only assertion would not prove the annotation survives it.jqis now asserted as a hard requirement alongsideyq, so a missing tool fails the gate rather than silently skipping it.Verification
The independent reviewer confirmed the new gate is non-vacuous with 10 perturbations plus a positive control — removing the annotation, emptying it, corrupting the JSON, duplicating a kind, dropping a single kind, and breaking each extraction path all fail the gate; the unmodified tree passes.
Local gate matrix on the rebased head: all
hack/test/dist_*.sh,task verify,task lint,task test, andpre-commitgreen. ADRY_RUN=1bundle generation produces a CSV whosealm-examplescontains exactly 11 entries, 11 distinct kinds, matching the 11 owned CRDs exactly.