operator-sdk icon indicating copy to clipboard operation
operator-sdk copied to clipboard

fix: consider version when getting CRDs for validating descriptors

Open tthvo opened this issue 1 year ago • 4 comments
trafficstars

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:

Fixes #6781

tthvo avatar Jul 15 '24 10:07 tthvo

@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.

acornett21 avatar Jul 15 '24 14:07 acornett21

@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).

tthvo avatar Jul 15 '24 15:07 tthvo

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 (v1beta1 and v1beta2): 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.

tthvo avatar Jul 15 '24 15:07 tthvo

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.

ebaron avatar Aug 15 '24 18:08 ebaron

@tthvo Could you rebase your PR? thanks.

acornett21 avatar Oct 15 '24 21:10 acornett21

@tthvo Could you rebase your PR? thanks.

Hey @acornett21, I rebased it now (with a small cleanup). Thanks :D

tthvo avatar Oct 15 '24 23:10 tthvo

/override docs

acornett21 avatar Oct 16 '24 13:10 acornett21

@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.

openshift-ci[bot] avatar Oct 16 '24 13:10 openshift-ci[bot]