Bug 1867848

Summary: Registry returns incorrect properties and dependencies for bundles without any properties or dependencies
Product: OpenShift Container Platform Reporter: Ben Luddy <bluddy>
Component: OLMAssignee: Ben Luddy <bluddy>
OLM sub component: OLM QA Contact: Jian Zhang <jiazha>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: high    
Version: 4.6   
Target Milestone: ---   
Target Release: 4.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-10-27 16:27:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ben Luddy 2020-08-11 01:42:46 UTC
Description of problem:

Responses from the registry "ListBundles" endpoint report {"properties":[{}],...} or {"dependencies":[{}]}, respectively, when a given bundle has no stored properties or dependencies.

Backwards compatibility for bundles that do not specify provided and required GVKs using properties and dependencies is not activated when a bundle reports at least one property or dependency (https://github.com/operator-framework/operator-lifecycle-manager/blob/master/pkg/controller/registry/resolver/operators.go#L259-L273), so dependency resolutions will not recognize the provided or required APIs for older bundles.

Version-Release number of selected component (if applicable):

4.6.0

How reproducible: always

Steps to Reproduce:
1. Extract the database from an image:

$ docker cp $(docker create quay.io/operator-framework/upstream-community-operators):/bundles.db .

2. Serve with opm:

$ opm registry serve -d bundles.db

2. Query the ListBundles endpoint:

$ grpcurl --plaintext localhost:50051 api.Registry/ListBundles | jq '{csvName,dependencies,properties}|select(.properties==[{}] or .dependencies==[{}])'

Actual results:

Many bundles in the response show [{}] for either properties or dependencies.


...
{
  "csvName": "infinispan-operator.v1.0.1",
  "dependencies": [
    {}
  ],
  "properties": [
    {
      "type": "olm.gvk",
      "value": "{\"group\":\"infinispan.org\",\"kind\":\"Infinispan\",\"version\":\"v1\"}"
    },
    {
      "type": "olm.package",
      "value": "{\"packageName\":\"infinispan\",\"version\":\"1.0.1\"}"
    }
  ]
}
...

Expected results:

No bundles in the response should have an empty entry -- {} -- in their dependencies or properties fields. Instead, those fields should be omitted, null, or [].

Comment 4 Jian Zhang 2020-08-18 01:33:17 UTC
[root@preserve-olm-env data]# opm version
Version: version.Version{OpmVersion:"v1.12.5-106-gd724d65", GitCommit:"d724d65", BuildDate:"2020-08-18T01:16:19Z", GoOs:"linux", GoArch:"amd64"}

[root@preserve-olm-env data]# docker cp $(docker create quay.io/operator-framework/upstream-community-operators):/bundles.db .
...

[root@preserve-olm-env data]# opm registry serve -d bundles.db
time="2020-08-17T21:23:01-04:00" level=info msg="Keeping server open for infinite seconds" database=bundles.db port=50051
time="2020-08-17T21:23:01-04:00" level=info msg="serving registry" database=bundles.db port=50051

In another terminal, 
[root@preserve-olm-env data]# grpcurl --plaintext localhost:50051 api.Registry/ListBundles | jq '{csvName,dependencies,properties}'
{
  "csvName": "hive-operator.v1.0.1",
  "dependencies": null,
  "properties": [
    {
      "type": "olm.gvk",
      "value": "{\"group\":\"hive.openshift.io\",\"kind\":\"Checkpoint\",\"version\":\"v1\"}"
    },
...

It returns nothing, LGTM, verify it.
[root@preserve-olm-env data]# grpcurl --plaintext localhost:50051 api.Registry/ListBundles | jq '{csvName,dependencies,properties}|select(.properties==[{}] or .dependencies==[{}])'
[root@preserve-olm-env data]#

Comment 6 errata-xmlrpc 2020-10-27 16:27:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (OpenShift Container Platform 4.6 GA Images), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:4196