operator-sdk
operator-sdk copied to clipboard
fix: consider version when getting CRDs for validating descriptors
Description of the change:
An additional condition is included for matching apiVersion of example CRs with CRD version when searching for the CRD in the CSV.
Motivation for the change:
Previously, the olm-spec-descriptors scorecard test failed when multiple versions of CRD are included in the CSV. The CRs specified in alm-examples annotations are validated only against the first matched CRD (by kind), which is incorrect. This ensures the CRD with correct kind and version is selected for descriptor scorecard test.
Checklist
If the pull request includes user-facing changes, extra documentation is required:
- [x] Add a new changelog fragment in
changelog/fragments(seechangelog/fragments/00-template.yaml) - [ ] Add or update relevant sections of the docs website in
website/content/en/docs
Fixes #6781
@tthvo At face value I don't think this PR works, since this info only comes from the alm-examples, and those do not have a versions. The code to get the CR from the bundle is here, maybe I'm missing something.
@tthvo At face value I don't think this PR works, since this info only comes from the alm-examples, and those do not have a versions. The code to get the CR from the bundle is here, maybe I'm missing something.
Hi @acornett21, I guess what I meant is to compare the apiVersion of the object in alm-examples annotations with the owned CRD's version field.
https://github.com/operator-framework/operator-sdk/blob/e95abdbd5ccb7ca0fd586e0c6f578e491b0a025b/testdata/go/v4/memcached-operator/bundle/manifests/memcached-operator.clusterserviceversion.yaml#L8
https://github.com/operator-framework/operator-sdk/blob/e95abdbd5ccb7ca0fd586e0c6f578e491b0a025b/testdata/go/v4/memcached-operator/bundle/manifests/memcached-operator.clusterserviceversion.yaml#L47
This is a very similar issue/fix to:
- https://issues.redhat.com/browse/OCPBUGS-34901.
- https://github.com/k8s-operatorhub/operatorhub.io/pull/60 (other way around).
Sorry I forgot to include a way to test these changes. You can try:
- Scorecard image:
quay.io/thvo/scorecard-test:dev - Bundle image with >= 2 owned CRD versions (
v1beta1andv1beta2):quay.io/thvo/cryostat-operator-bundle:4.0.0-olm. CSV is here: https://gist.github.com/tthvo/08402b93f8ef4e9a0dd6117b3253224a
Run: operator-sdk scorecard -n default -s default quay.io/thvo/cryostat-operator-bundle:4.0.0-olm --selector=suite=olm. That should succeed. Previously, if you use the scorecard image on quay.io/operator-framework, it fails.
Hi, any update on getting this fixed? Our workaround of removing the v1beta1 CRD from alm-examples is generating the following warning with each build/test:
Warning: Value operator.cryostat.io/v1beta1, Kind=Cryostat: provided API should have an example annotation
It would be nice to have clean test results, but that depends on this bug being fixed.
@tthvo Could you rebase your PR? thanks.
@tthvo Could you rebase your PR? thanks.
Hey @acornett21, I rebased it now (with a small cleanup). Thanks :D
/override docs
@acornett21: Overrode contexts on behalf of acornett21: docs
In response to this:
/override docs
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.