Bug 1866930

Summary: OPM can strand packages with no resolution
Product: OpenShift Container Platform Reporter: Kevin Rizza <krizza>
Component: OLMAssignee: Kevin Rizza <krizza>
OLM sub component: OLM QA Contact: Jian Zhang <jiazha>
Status: CLOSED ERRATA Docs Contact:
Severity: urgent    
Priority: unspecified CC: kuiwang
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:26:23 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 Kevin Rizza 2020-08-06 20:44:56 UTC
Description of problem:

It is possible to craft a set of bundle manifests and opm commands to strand a bundle. When that bundle is stranded, it cannot be removed via `opm index/registry rm` or any other method. Ideally, we should be able to remove all bundles from an index without having to the index back.

How reproducible:

Always.

Steps to Reproduce:
1. Build two bundle images with the same package. Insert both into the same channels, but do not set the second bundle as a replacement of the first.
2. `opm index rm` the package
3. Attempt to add both packages back into the index.

Actual results:

opm will throw an error preventing the bundle from being added

Expected results:

opm can reinsert the bundles into the now empty index

Comment 3 Jian Zhang 2020-08-10 06:44:50 UTC
LGTM, verify it. Test steps as follows:

[root@preserve-olm-env operator-registry]# ./bin/opm version
Version: version.Version{OpmVersion:"v1.12.5-104-g018a040", GitCommit:"018a040", BuildDate:"2020-08-10T02:53:22Z", GoOs:"linux", GoArch:"amd64"}

1. Build two bundle images with the same package. Insert both into the same channels, but do not set the second bundle as a replacement of the first.

[root@preserve-olm-env etcd]# tree 0.9.0/
0.9.0/
├── etcdbackups.etcd.database.coreos.com.crd.yaml
├── etcdclusters.etcd.database.coreos.com.crd.yaml
├── etcdoperator.v0.9.0.clusterserviceversion.yaml
└── etcdrestores.etcd.database.coreos.com.crd.yaml

0 directories, 4 files

Remove the `Replace` field from the etcdoperator.v0.9.2.clusterserviceversion.yaml.
[root@preserve-olm-env etcd]# tree 0.9.2/
0.9.2/
├── etcdbackups.etcd.database.coreos.com.crd.yaml
├── etcdclusters.etcd.database.coreos.com.crd.yaml
├── etcdoperator.v0.9.2.clusterserviceversion.yaml
└── etcdrestores.etcd.database.coreos.com.crd.yaml

0 directories, 4 files

[root@preserve-olm-env etcd]# opm alpha bundle build  -c 4.6 -e 4.6 -d ./0.9.2/ -p etcd -t quay.io/olmqe/etcd-bundle:0.9.2-1866930
...
Successfully tagged quay.io/olmqe/etcd-bundle:0.9.2-1866930

[root@preserve-olm-env etcd]# opm alpha bundle build  -c 4.6 -e 4.6 -d ./0.9.0/ -p etcd -t quay.io/olmqe/etcd-bundle:0.9.0-1866930 -o=true
...
Successfully tagged quay.io/olmqe/etcd-bundle:0.9.0-1866930


[root@preserve-olm-env etcd]# docker push quay.io/olmqe/etcd-bundle:0.9.0-1866930
The push refers to repository [quay.io/olmqe/etcd-bundle]
f48764a200ff: Pushed 
c65a27adc000: Pushed 
0.9.0-1866930: digest: sha256:2b3990cfb0917e62b76d0ceec4f3a3ebe4ef7f48da5622a028b8c6acc0fb31aa size: 732
[root@preserve-olm-env etcd]# docker push quay.io/olmqe/etcd-bundle:0.9.2-1866930
The push refers to repository [quay.io/olmqe/etcd-bundle]
fa5fa46c9f7d: Pushed 
e19d156a82f3: Pushed 
0.9.2-1866930: digest: sha256:a2040f42ed6abf44baed7ea6d36e8c630ca7b38ad17242ee0036b2d9aa475124 size: 732


[root@preserve-olm-env operator-registry]# ./bin/opm index add -b quay.io/olmqe/etcd-bundle:0.9.0-1866930 -t quay.io/olmqe/etcd-index:test-1866930 -c docker
INFO[0000] building the index                            bundles="[quay.io/olmqe/etcd-bundle:0.9.0-1866930]"
...
INFO[0001] [docker build -f index.Dockerfile573114636 -t quay.io/olmqe/etcd-index:test-1866930 .]  bundles="[quay.io/olmqe/etcd-bundle:0.9.0-1866930]"
[root@preserve-olm-env operator-registry]# docker push quay.io/olmqe/etcd-index:test-1866930
The push refers to repository [quay.io/olmqe/etcd-index]
412d5f461694: Pushed 
9e3f512ced9c: Layer already exists 
5658e440f799: Layer already exists 
d8a53ddb879b: Layer already exists 
3e207b409db3: Layer already exists 
test-1866930: digest: sha256:ee11cc057fe22b71eabbdc257991dff05dd9c08db40bbdf6a17c447db77e4ab9 size: 1371

[root@preserve-olm-env operator-registry]# ./bin/opm index add -b quay.io/olmqe/etcd-bundle:0.9.2-1866930 -f quay.io/olmqe/etcd-index:test-1866930 -c docker -t quay.io/olmqe/etcd-index:test-1866930 
INFO[0000] building the index                            bundles="[quay.io/olmqe/etcd-bundle:0.9.2-1866930]"
...
INFO[0002] [docker build -f index.Dockerfile297989043 -t quay.io/olmqe/etcd-index:test-1866930 .]  bundles="[quay.io/olmqe/etcd-bundle:0.9.2-1866930]"
[root@preserve-olm-env operator-registry]# docker push quay.io/olmqe/etcd-index:test-1866930
The push refers to repository [quay.io/olmqe/etcd-index]
69a58f5cad23: Pushed 
9e3f512ced9c: Layer already exists 
5658e440f799: Layer already exists 
d8a53ddb879b: Layer already exists 
3e207b409db3: Layer already exists 
test-1866930: digest: sha256:b8a9a9b66792be366e0f32bd399104c37312517f9e7790b4dd4eb79248a52b00 size: 1371

2. `opm index rm` the package

[root@preserve-olm-env operator-registry]# ./bin/opm index rm -f quay.io/olmqe/etcd-index:test-1866930 -c docker -o etcd -t quay.io/olmqe/etcd-index:rm
INFO[0000] building the index                            operators="[etcd]"
...
INFO[0002] [docker build -f index.Dockerfile736900445 -t quay.io/olmqe/etcd-index:rm .]  operators="[etcd]"
[root@preserve-olm-env operator-registry]# docker push quay.io/olmqe/etcd-index:rm
The push refers to repository [quay.io/olmqe/etcd-index]
e66521fafe06: Pushed 
9e3f512ced9c: Layer already exists 
5658e440f799: Layer already exists 
d8a53ddb879b: Layer already exists 
3e207b409db3: Layer already exists 
rm: digest: sha256:f8196aa8b21a686ccd1fedf5ef7cfc4ecbc62b3f9d3d4e4e4d0a478c73e37416 size: 1371

[root@preserve-olm-env operator-registry]# docker create quay.io/olmqe/etcd-index:rm
d5054afda4228e6a0df5223aec502cce6484b1e462d106b675c03f3b6bbaa93e
[root@preserve-olm-env operator-registry]# docker cp d5054afda4228e6a0df5223aec502cce6484b1e462d106b675c03f3b6bbaa93e:/database/index.db .
[root@preserve-olm-env operator-registry]# sqlite3 index.db 
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .header on
sqlite> .mode column
sqlite> .table
api                channel            operatorbundle     related_image    
api_provider       channel_entry      package            schema_migrations
api_requirer       dependencies       properties       
sqlite> select * from channel_entry;
sqlite> select * from operatorbundle;
sqlite> 
sqlite> .quit


3. Attempt to add both packages back into the index.
1) add the 0.9.0 version to the index image: quay.io/olmqe/etcd-index:rm 
[root@preserve-olm-env operator-registry]# ./bin/opm index add -b quay.io/olmqe/etcd-bundle:0.9.0-1866930 -f quay.io/olmqe/etcd-index:rm -c docker -t quay.io/olmqe/etcd-index:add
INFO[0000] building the index                            bundles="[quay.io/olmqe/etcd-bundle:0.9.0-1866930]"
...
INFO[0002] [docker build -f index.Dockerfile581059945 -t quay.io/olmqe/etcd-index:add .]  bundles="[quay.io/olmqe/etcd-bundle:0.9.0-1866930]"
[root@preserve-olm-env operator-registry]# 
[root@preserve-olm-env operator-registry]# docker push quay.io/olmqe/etcd-index:add
The push refers to repository [quay.io/olmqe/etcd-index]
fb585cdd5832: Pushed 
9e3f512ced9c: Layer already exists 
5658e440f799: Layer already exists 
d8a53ddb879b: Layer already exists 
3e207b409db3: Layer already exists 
add: digest: sha256:2e32321fd107d8518f49cedd93d236c499adbba2ff269d3668ad2370e192f0d3 size: 1371

2) add the 0.9.2 version to the index image: quay.io/olmqe/etcd-index:add 
[root@preserve-olm-env operator-registry]# ./bin/opm index add -b quay.io/olmqe/etcd-bundle:0.9.2-1866930 -f quay.io/olmqe/etcd-index:add -c docker -t quay.io/olmqe/etcd-index:add
INFO[0000] building the index                            bundles="[quay.io/olmqe/etcd-bundle:0.9.2-1866930]"
...
INFO[0002] [docker build -f index.Dockerfile232446836 -t quay.io/olmqe/etcd-index:add .]  bundles="[quay.io/olmqe/etcd-bundle:0.9.2-1866930]"
[root@preserve-olm-env operator-registry]# docker push quay.io/olmqe/etcd-index:add
The push refers to repository [quay.io/olmqe/etcd-index]
0d5f565889fa: Pushed 
9e3f512ced9c: Layer already exists 
5658e440f799: Layer already exists 
d8a53ddb879b: Layer already exists 
3e207b409db3: Layer already exists 
add: digest: sha256:363e8a1973facb0c47192dc8e3cc06c63ed6df3fe8cc089123504c7dabb3988a size: 1371

[root@preserve-olm-env operator-registry]# docker create quay.io/olmqe/etcd-index:add
abba807f9521f9202dbe1dfaa22f64ea75e598d17ac65c0b46e5fe5830567e1a
[root@preserve-olm-env operator-registry]# docker cp abba807f9521f9202dbe1dfaa22f64ea75e598d17ac65c0b46e5fe5830567e1a:/database/index.db .
[root@preserve-olm-env operator-registry]# sqlite3 index.db 
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .header on
sqlite> .mode column
sqlite> .table
api                channel            operatorbundle     related_image    
api_provider       channel_entry      package            schema_migrations
api_requirer       dependencies       properties       
sqlite> select * from channel_entry;
entry_id    channel_name  package_name  operatorbundle_name  replaces    depth     
----------  ------------  ------------  -------------------  ----------  ----------
1           4.6           etcd          etcdoperator.v0.9.2              0    
     
sqlite> select * from operatorbundle;
name                 csv         bundle      bundlepath                               skiprange   version     replaces    skips     
-------------------  ----------  ----------  ---------------------------------------  ----------  ----------  ----------  ----------
etcdoperator.v0.9.0                          quay.io/olmqe/etcd-bundle:0.9.0-1866930              0.9.0                             
etcdoperator.v0.9.2  {"apiVersi  {"apiVersi  quay.io/olmqe/etcd-bundle:0.9.2-1866930              0.9.2                             
sqlite> .quit

Comment 5 errata-xmlrpc 2020-10-27 16:26:23 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