Bug 1827723 - OPM fails to infer package
Summary: OPM fails to infer package
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: OLM
Version: 4.5
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 4.5.0
Assignee: Bowen Song
QA Contact: Bruno Andrade
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-04-24 15:58 UTC by Bruno Andrade
Modified: 2020-07-13 17:31 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: If a bundle in the package belongs to a set of channels that does not include the current default channel, the cmd would fail on verification. This was because after a bundle is released, the default channel may change or get created that is not part of the channels the old bundle belongs to. Consequence: Verification ensures that the default channel is also included in the set of channels a bundle belongs to. Since verification is triggered upon writing annotations.yaml file, the cmd would fail. Fix: The default channel is an optional field and since bundle's original default channel is no longer the correct one for the package and is the subject of inference, not specified by the user, the inference will leave the default channel blank since there is no way of getting this optional information. Result: Default Channel will be left blank for the bundle if the current default channel is not part of the channel set for the bundle.
Clone Of:
Environment:
Last Closed: 2020-07-13 17:31:25 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Etcd Manifest (9.53 KB, application/gzip)
2020-05-11 04:39 UTC, Bruno Andrade
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Github operator-framework operator-registry pull 318 0 None closed Bug 1827723: Make default channel optional 2020-06-23 10:23:33 UTC
Github operator-framework operator-registry pull 324 0 None closed Bug 1827723: Adding error message for more than one CSV in bundle dir 2020-06-23 10:23:33 UTC
Red Hat Product Errata RHBA-2020:2409 0 None None None 2020-07-13 17:31:42 UTC

Description Bruno Andrade 2020-04-24 15:58:47 UTC
Description of problem:

Given the structure of packages:

cat etcd.package.yaml                                                                                      
packageName: etcd
channels:
- name: alpha
  currentCSV: etcdoperator.v0.9.2
- name: beta
  currentCSV: etcdoperator.v0.9.0
- name: stable
  currentCSV: etcdoperator.v0.9.2
defaultChannel: alpha

 tree     
.
├── 0.6.1
│   ├── etcdcluster.crd.yaml
│   └── etcdoperator.clusterserviceversion.yaml
├── 0.9.2
│   ├── etcdbackup.crd.yaml
│   ├── etcdcluster.crd.yaml
│   ├── etcdoperator.v0.9.0.yaml
│   ├── etcdoperator.v0.9.2.clusterserviceversion.yaml
│   ├── etcdrestore.crd.yaml
├── etcd.package.yaml

When I run the following command, it returns the following errors:

opm alpha bundle generate --directory ./0.9.2 
INFO[0000] Bundle channels and package name information not provided, inferring from parent package directory 
INFO[0000] Inferred channels: beta                      
INFO[0000] Inferred package name: etcd                  
INFO[0000] Inferred default channel: alpha              
INFO[0000] Building annotations.yaml                    
Error: The channel list "beta" doesn't contain channelDefault "alpha"

If I change to only one channel, it fails as well:

cat etcd.package.yaml
packageName: etcd
channels:
- name: alpha
  currentCSV: etcdoperator.v0.9.2
defaultChannel: alpha

opm alpha bundle generate --directory ./0.9.2 
INFO[0000] Bundle channels and package name information not provided, inferring from parent package directory 
Error: error interpreting channels, please manually input channels instead
Usage:
  opm alpha bundle generate [flags]



Version-Release number of selected component (if applicable):
https://github.com/operator-framework/operator-registry
commit 2bdcd07e6f9ea23a35f1fdbb6a7c6584ec53a0a1

How reproducible:
Always

Steps to Reproduce:
Mentioned at description

Actual results:
The command fails to infer the proper information of the package.


Expected results:
Inference should work properly.

Additional info:

Comment 1 Bowen Song 2020-04-30 21:31:23 UTC
Uhmm... I uhhh. I know this is confusing. would you please provide your package directory?
[bowensong@red-bowen etcd]$ tree
.
├── 0.6.1
│   ├── etcdclusters.etcd.database.coreos.com.crd.yaml
│   └── etcdoperator-community.v0.6.1.clusterserviceversion.yaml
├── 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
└── etcd.package.yaml


[bowensong@red-bowen etcd]$ cat etcd.package.yaml 
channels:
- name: alpha
  currentCSV: etcdoperator.v0.9.2
- name: beta
  currentCSV: etcdoperator.v0.9.0
- name: stable
  currentCSV: etcdoperator.v0.9.2
defaultChannel: alpha
packageName: etcd

[bowensong@red-bowen operator-registry]$ ./bin/opm alpha bundle generate --directory ../community-operators/upstream-community-operators/etcd/0.9.2/
INFO[0000] Bundle channels and package name information not provided, inferring from parent package directory 
INFO[0000] Inferred channels: alpha,stable              
INFO[0000] Inferred package name: etcd                  
INFO[0000] Inferred default channel: alpha              
INFO[0000] Building annotations.yaml                    
INFO[0000] Building Dockerfile         

[bowensong@red-bowen etcd]$ cat metadata/annotations.yaml 
annotations:
  operators.operatorframework.io.bundle.channel.default.v1: alpha
  operators.operatorframework.io.bundle.channels.v1: alpha,stable
  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


My Git Log

[bowensong@red-bowen operator-registry]$ git log
commit 5c21e0f3b9b2f6b07ee1e08322199abd54475dd8 (HEAD -> bug/understandsingBundles1827723, upstream/master)
Merge: bf0c8f1 dc99201
Author: OpenShift Merge Robot <openshift-merge-robot.github.com>
Date:   Thu Apr 30 08:16:22 2020 +0200

    Merge pull request #312 from benluddy/deps-not-found-optional
    
    Bug 1827992: Clarify log message to indicate that dependencies.yaml is optional.

commit dc99201b1c7499cc2d7defd12345ea3158ead622
Author: Ben Luddy <bluddy>
Date:   Thu Apr 30 00:48:27 2020 -0400

    Clarify log message to indicate that dependencies.yaml is optional.

commit bf0c8f1590d21e54e97c1446b09fae72ade51280 (origin/master, origin/HEAD, master)
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

Comment 9 Bruno Andrade 2020-05-08 19:32:46 UTC
Hi Bowen, I'm using manifests from operator-registry at the latest version. Did the instructions as you requested, please let me know if you need something else from my side. Thanks

git log --pretty=format:'%h' -n 1
d21c6e7

rm -rf manifests/etcd/bundle.Dockerfile manifests/etcd/metadata/

git status
# On branch master
nothing to commit, working directory clean

cat 0.9.2/etcdoperator.v0.9.2.clusterserviceversion.yaml | grep "etcdoperator.v0.9.2"
  name: etcdoperator.v0.9.2


cd manifests/etcd

opm alpha bundle generate --directory ./0.9.2 
INFO[0000] Bundle channels and package name information not provided, inferring from parent package directory 
INFO[0000] Inferred channels: beta                      
INFO[0000] Inferred package name: etcd                  
INFO[0000] Inferred default channel:                    
INFO[0000] Building annotations.yaml                    
INFO[0000] Building Dockerfile                          


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=beta
LABEL operators.operatorframework.io.bundle.channel.default.v1=

COPY 0.9.2 /manifests/
COPY metadata /metadata/

Comment 10 Bowen Song 2020-05-08 20:23:49 UTC
could you please attach your directory on this bug? thanks.

Comment 11 Bruno Andrade 2020-05-11 04:39:11 UTC
Created attachment 1687131 [details]
Etcd Manifest

Comment 12 Bowen Song 2020-05-11 12:23:40 UTC
found the problem lies in this testing package directory:

[bowensong@red-bowen operator-registry]$ tree ~/Downloads/etcd_manifest/etcd/
/home/bowensong/Downloads/etcd_manifest/etcd/
├── 0.6.1
│   ├── etcdcluster.crd.yaml
│   └── etcdoperator.clusterserviceversion.yaml
├── 0.9.2
│   ├── etcdbackup.crd.yaml
│   ├── etcdcluster.crd.yaml
│   ├── etcdoperator.v0.9.0.yaml
│   ├── etcdoperator.v0.9.2.clusterserviceversion.yaml
│   └── etcdrestore.crd.yaml
└── etcd.package.yaml

In 0.9.2/ directory, both `etcdoperator.v0.9.0.yaml` and `etcdoperator.v0.9.2.clusterserviceversion.yaml` are CSVs. We have a hard assumption that each bundle has one CSV, in this case should be the one matching the operator version 0.9.2.

In etcdoperator.v0.9.2.clusterserviceversion.yaml, there is no `installMode` either which is required for CSV.

we expect the annotations.yaml for `0.9.2` to be: 
annotations:
  operators.operatorframework.io.bundle.channel.default.v1: alpha
  operators.operatorframework.io.bundle.channels.v1: alpha,stable
  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

Which i was able to generate after the change. Please let me know if you agree with the assumption and the outcome. Thank you

Comment 13 Bruno Andrade 2020-05-11 16:39:39 UTC
Got it, thanks, in that case, do you think we can add a warning/error informing the user that inference could not work due to that matter?

Comment 14 Bowen Song 2020-05-11 18:50:58 UTC
fair enough, adding it!

Comment 16 Bruno Andrade 2020-05-12 23:13:04 UTC
LGTM, marking as verified.

The following message is shown when more than one CSV in the directory if the command is run without package and default channel arguments.

opm alpha bundle generate --directory 0.9.2/
INFO[0000] Bundle channels and package name information not provided, inferring from parent package directory 
Error: please manually input channels and packageName, error interpreting bundle from directory /home/vagrant/operator-registry/manifests/etcd/0.9.2, error loading CSV from bundle directory, more than one ClusterServiceVersion is found in bundle

Thanks

Comment 17 errata-xmlrpc 2020-07-13 17:31:25 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.