Bug 1826766 - Operator registry loads the same dependencies twice in the database
Summary: Operator registry loads the same dependencies twice in the database
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: OLM
Version: 4.5
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
: 4.5.0
Assignee: Vu Dinh
QA Contact: kuiwang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-04-22 14:00 UTC by Vu Dinh
Modified: 2020-07-13 17:30 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-07-13 17:30:21 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github operator-framework operator-registry pull 289 0 None closed Bug 1826766: fix(types): Fix GetDependencies func that returns duplicate items 2020-09-03 09:04:35 UTC
Red Hat Product Errata RHBA-2020:2409 0 None None None 2020-07-13 17:30:39 UTC

Description Vu Dinh 2020-04-22 14:00:46 UTC
Description of problem:
When I load a bundle image with dependencies.yaml containing 2 dependencies into an index image, the `dependencies` table in the database list only of the two dependencies (missing one).

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

How reproducible:
100%

Steps to Reproduce:
1. Create a bundle image with dependencies.yaml in metadata with 2 dependencies such as:
```
dependencies:
  - type: olm.package
    packageName: testopertor
    version: 0.2.0
  - type: olm.gvk
    group: testapi.coreos.com
    kind: testapi
    version: v1alpha1
```
2. Push the image to a public registry.
3. Add the bundle image to an index using opm index add:
```
$ opm registry add -b "quay.io/test/test-operator" -d "test-registry.db"

```
4. Inspect the dependencies table in `test-registry.db`


Actual results:
See `type: olm.gvk` dependency entry (twice) and `type: olm.package` one is missing

Expected results:
See one entry for `olm.gvk` dependency and one for `olm.package` dependency.

Additional info:

Comment 4 kuiwang 2020-04-30 05:58:10 UTC
It is verified on 4.5. LGTM.

Here is the detailed:

[root@preserve-olm-env operator-registry]# git log
commit bf0c8f1590d21e54e97c1446b09fae72ade51280
Merge: 6e6a14d cfb8d0f
Author: OpenShift Merge Robot <openshift-merge-robot.github.com>
Date:   Tue Apr 28 02:59:56 2020 +0200

    Merge pull request #289 from dinhxuanvu/fix-dep-types

    Bug 1826766: fix(types): Fix GetDependencies func that returns duplicate items

commit cfb8d0f92c85b099a9f9ec16c99b08f640ebc019
Author: Vu Dinh <vdinh>
Date:   Mon Apr 20 13:58:48 2020 -0400

    fix(types): Fix GetDependencies func that returns duplicate items

    The iterator loop reuses item pointer which leads to duplicate of the
    same dependencies while other dependencies are missing out.

    Signed-off-by: Vu Dinh <vdinh>

[root@preserve-olm-env operator-registry]# go build ./cmd/opm/
[root@preserve-olm-env bin]# cd ../community-operators/
[root@preserve-olm-env community-operators]# cd community-operators/
[root@preserve-olm-env etcd]# pwd
/root/kuiwang/community-operators/community-operators/etcd

[root@preserve-olm-env etcd]# opm alpha bundle generate -d /root/kuiwang/community-operators/community-operators/etcd/0.9.0  -c alpha -p etcd
INFO[0000] Building annotations.yaml
INFO[0000] Building Dockerfile
[root@preserve-olm-env etcd]# ls
0.6.1  0.9.0  0.9.2  0.9.2-clusterwide  0.9.4  0.9.4-clusterwide  bundle.Dockerfile  etcd.package.yaml  metadata
[root@preserve-olm-env etcd]# cat bundle.Dockerfile
FROM scratch

LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=etcd
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha

COPY 0.9.0 /manifests/
COPY metadata /metadata/

[root@preserve-olm-env etcd]# cat metadata/annotations.yaml
annotations:
  operators.operatorframework.io.bundle.channel.default.v1: alpha
  operators.operatorframework.io.bundle.channels.v1: alpha
  operators.operatorframework.io.bundle.manifests.v1: manifests/
  operators.operatorframework.io.bundle.mediatype.v1: registry+v1
  operators.operatorframework.io.bundle.metadata.v1: metadata/
  operators.operatorframework.io.bundle.package.v1: etcd
[root@preserve-olm-env etcd]# mv 0.9.0/dependencies.yaml metadata/
[root@preserve-olm-env etcd]# cat metadata/dependencies.yaml
dependencies:
  - type: olm.package
    packageName: testopertor
    version: 0.2.0
  - type: olm.gvk
    group: testapi.coreos.com
    kind: testapi
    version: v1alpha1

[root@preserve-olm-env etcd]# docker build -f bundle.Dockerfile -t quay.io/kuiwang/etcd-bundle:1826766 .
Sending build context to Docker daemon 133.6 kB
Step 1/9 : FROM scratch
 --->
Step 2/9 : LABEL operators.operatorframework.io.bundle.mediatype.v1 registry+v1
 ---> Running in b8e9d511e577
 ---> 8cd96a9c7aca
Removing intermediate container b8e9d511e577
Step 3/9 : LABEL operators.operatorframework.io.bundle.manifests.v1 manifests/
 ---> Running in 52ce8b8d45ce
 ---> e7c240c1844f
Removing intermediate container 52ce8b8d45ce
Step 4/9 : LABEL operators.operatorframework.io.bundle.metadata.v1 metadata/
 ---> Running in d0fc7617d446
 ---> ad55f2fbedf2
Removing intermediate container d0fc7617d446
Step 5/9 : LABEL operators.operatorframework.io.bundle.package.v1 etcd
 ---> Running in 3555d4082cbf
 ---> 59fe7bbeef05
Removing intermediate container 3555d4082cbf
Step 6/9 : LABEL operators.operatorframework.io.bundle.channels.v1 alpha
 ---> Running in e7facea19931
 ---> 536fa6b051ee
Removing intermediate container e7facea19931
Step 7/9 : LABEL operators.operatorframework.io.bundle.channel.default.v1 alpha
 ---> Running in 894659cbb9ea
 ---> dba69940246d
Removing intermediate container 894659cbb9ea
Step 8/9 : COPY 0.9.0 /manifests/
 ---> f54aef3f7c27
Removing intermediate container 772b7027f1cc
Step 9/9 : COPY metadata /metadata/
 ---> 9a74e5122324
Removing intermediate container b58e1b4375ca
Successfully built 9a74e5122324
[root@preserve-olm-env etcd]# docker image ls
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
quay.io/kuiwang/etcd-bundle   1826766             9a74e5122324        20 seconds ago      18.6 kB
docker.io/registry            latest              708bc6af7e5e        3 months ago        25.8 MB

[root@preserve-olm-env etcd]# docker push quay.io/kuiwang/etcd-bundle:1826766
The push refers to a repository [quay.io/kuiwang/etcd-bundle]
7391b687fa18: Pushed
201d022cf6e5: Pushed
1826766: digest: sha256:f1a617c45d0ae6664f7fe28b5c49ed731706bc52cfb9efe0fbd65e30fc9d4fe0 size: 732


[root@preserve-olm-env etcd]# opm registry add -b "quay.io/kuiwang/etcd-bundle:1826766" -d "test-registry.db"
INFO[0000] adding to the registry                        bundles="[quay.io/kuiwang/etcd-bundle:1826766]"
INFO[0000] resolved name: quay.io/kuiwang/etcd-bundle:1826766
INFO[0000] fetched                                       digest="sha256:f1a617c45d0ae6664f7fe28b5c49ed731706bc52cfb9efe0fbd65e30fc9d4fe0"
INFO[0000] fetched                                       digest="sha256:000b44d5d842ca7c9acac0f0dbe0db0411cdd9975b87b3dc50479ca6c94bc738"
INFO[0000] fetched                                       digest="sha256:9a74e512232427a97cb018ea5d235769f51eeaa70f893b4ccd9a61ae6a7e3d99"
INFO[0000] fetched                                       digest="sha256:d76c7299ec538d477355de5202ce803a40c4427f8aaead494a56e6d49dd59677"
INFO[0000] unpacking layer: {application/vnd.docker.image.rootfs.diff.tar.gzip sha256:d76c7299ec538d477355de5202ce803a40c4427f8aaead494a56e6d49dd59677 8029 [] map[] <nil>}
INFO[0000] unpacking layer: {application/vnd.docker.image.rootfs.diff.tar.gzip sha256:000b44d5d842ca7c9acac0f0dbe0db0411cdd9975b87b3dc50479ca6c94bc738 396 [] map[] <nil>}
INFO[0000] found csv, loading bundle                     dir=bundle_tmp939033765 file=bundle_tmp939033765/manifests load=bundle
INFO[0000] loading bundle file                           dir=bundle_tmp939033765/manifests file=etcdbackups.etcd.database.coreos.com.crd.yaml load=bundle
INFO[0000] loading bundle file                           dir=bundle_tmp939033765/manifests file=etcdclusters.etcd.database.coreos.com.crd.yaml load=bundle
INFO[0000] loading bundle file                           dir=bundle_tmp939033765/manifests file=etcdoperator.v0.9.0.clusterserviceversion.yaml load=bundle
INFO[0000] loading bundle file                           dir=bundle_tmp939033765/manifests file=etcdrestores.etcd.database.coreos.com.crd.yaml load=bundle
[root@preserve-olm-env etcd]# ls
0.6.1  0.9.0  0.9.2  0.9.2-clusterwide  0.9.4  0.9.4-clusterwide  bundle.Dockerfile  etcd.package.yaml  metadata  test-registry.db
[root@preserve-olm-env etcd]# sqlite3 test-registry.db
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .table
api                channel            operatorbundle     schema_migrations
api_provider       channel_entry      package
api_requirer       dependencies       related_image
sqlite> .header on
sqlite> .mode column
sqlite> select * from dependencies;
type         value                                                                 operatorbundle_name  operatorbundle_version  operatorbundle_path
-----------  --------------------------------------------------------------------  -------------------  ----------------------  -----------------------------------
olm.package  {"packageName":"testopertor","type":"olm.package","version":"0.2.0"}  etcdoperator.v0.9.0  0.9.0                   quay.io/kuiwang/etcd-bundle:1826766
olm.gvk      {"group":"testapi.coreos.com","kind":"testapi","type":"olm.gvk","ver  etcdoperator.v0.9.0  0.9.0                   quay.io/kuiwang/etcd-bundle:1826766

Comment 5 errata-xmlrpc 2020-07-13 17:30:21 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, 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:2409


Note You need to log in before you can comment on or make changes to this bug.