Bug 1771850 - The `bundle extract ` command should output errors when reading the wrong key/values
Summary: The `bundle extract ` command should output errors when reading the wrong key...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: OLM
Version: 4.3.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 4.3.0
Assignee: Anik
QA Contact: Jian Zhang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-11-13 06:52 UTC by Jian Zhang
Modified: 2020-01-23 11:12 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-01-23 11:12:28 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Github operator-framework operator-registry pull 125 'None' closed Bug 1771850: Error logging for opm alpha bundle extract command 2020-04-02 09:34:51 UTC
Red Hat Product Errata RHBA-2020:0062 None None None 2020-01-23 11:12:53 UTC

Description Jian Zhang 2019-11-13 06:52:30 UTC
Description of problem:
The `bundle extract ` command should output errors when reading the wrong key/values so that the users can trace it.

Version-Release number of selected component (if applicable):
mac:bin jianzhang$ git log
commit 237e0d77dd18fee42be455f29ed6b9191f9a6160 (HEAD -> master, origin/master, origin/HEAD)
Merge: 5d342b2 ab7034f
Author: OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>
Date:   Fri Nov 8 19:39:32 2019 +0100

    Merge pull request #121 from kevinrizza/fix-docker-image-unpack
    
    Make imagereader work for all layer paths

How reproducible:
always

Steps to Reproduce:
1. Create a wrong annotation data, like below:
mac:etcd-operator jianzhang$ cat metadata/annotations.yaml  annotations:   operators.coreos.com.bundle.resources: "manifests+metadata"   operators.coreos.com.bundle.mediatype: "operator-registry+v1"

3. Run the `bundle extract` command.
mac:bin jianzhang$ ./opm alpha bundle extract -c test -n test-cm -k `echo $KUBECONFIG` -m /Users/jianzhang/etcd-operator/ --debug
INFO[0000] Loading kube client config from path "/Users/jianzhang/43-kubeconfig" 
INFO[0005] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcd.package.yaml
INFO[0005] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdbackup.crd.yaml
INFO[0005] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdcluster.crd.yaml
INFO[0005] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdoperator.v0.9.4-clusterwide.clusterserviceversion.yaml
INFO[0005] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdoperator.v0.9.4.clusterserviceversion.yaml
INFO[0005] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdrestore.crd.yaml
INFO[0005] Reading file                                  file=/Users/jianzhang/etcd-operator/metadata/annotations.yaml
mac:bin jianzhang$ ./opm alpha bundle extract --debug -c test -n test-cm -k `echo $KUBECONFIG` -m /Users/jianzhang/etcd-operator/ 
INFO[0000] Loading kube client config from path "/Users/jianzhang/43-kubeconfig" 
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcd.package.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdbackup.crd.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdcluster.crd.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdoperator.v0.9.4-clusterwide.clusterserviceversion.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdoperator.v0.9.4.clusterserviceversion.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdrestore.crd.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/metadata/annotations.yaml

3, Check the CongfigMap data.

Actual results:
No data generated.
mac:bin jianzhang$ oc get cm test -o yaml ... metadata:   annotations:     operators.operatorframework.io.bundle.channel.default.v1: ""     operators.operatorframework.io.bundle.channels.v1: ""     operators.operatorframework.io.bundle.manifests.v1: ""     operators.operatorframework.io.bundle.mediatype.v1: ""     operators.operatorframework.io.bundle.metadata.v1: ""     operators.operatorframework.io.bundle.package.v1: ""

Expected results:
The `bundle extract` should output errors when reading the annotation data.

Additional info:

Comment 1 Anik 2019-11-14 00:00:07 UTC
Could you give an example of a working annotation yaml?

Comment 2 Jian Zhang 2019-11-18 06:45:23 UTC
Hi, Anik

Yes, sure. Here: https://github.com/jianzhangbjz/learn-operator/blob/multi-versions/manifests/learn/metadata/annotations.yaml
Actually, you can use the `opm alpha bundle generate` command to generate it.
mac:bin jianzhang$ ./opm alpha bundle generate --help
The "opm alpha bundle generate" command will generate operator
        bundle metadata if needed and a Dockerfile to build Operator bundle image.

        $ opm alpha bundle generate --directory /test/ --package test-operator \
		--channels stable,beta --default stable

Usage:
  opm alpha bundle generate [flags]

Flags:
  -c, --channels string    The list of channels that bundle image belongs to
  -e, --default string     The default channel for the bundle image
  -d, --directory string   The directory where bundle manifests are located.
  -h, --help               help for generate
  -p, --package string     The name of the package that bundle image belongs to

Comment 4 Jian Zhang 2019-11-19 10:33:56 UTC
mac:operator-registry jianzhang$ git log
commit 768dcf1c08cab0fbd784767344be036498325039 (HEAD -> master, origin/master, origin/HEAD)
Merge: 3f13ca1 02e2a97
Author: OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>
Date:   Tue Nov 19 00:34:16 2019 +0100

    Merge pull request #125 from anik120/opm-bundle-extract-bug
    
    Bug 1771850: Error logging for opm alpha bundle extract command

commit 02e2a97ae811ac94cacf47fde0048624821ffff0

1, Create wrong key/values:
mac:bin jianzhang$ cat /Users/jianzhang/etcd-operator/metadata/annotations.yaml 
annotations:
  operators.coreos.com.bundle.resources: "manifests+metadata"
  operators.coreos.com.bundle.mediatype: "operator-registry+v1"

mac:bin jianzhang$ ./opm alpha bundle extract -c test -n test-cm -k `echo $KUBECONFIG` -m /Users/jianzhang/etcd-operator/
INFO[0000] Loading kube client config from path "/Users/jianzhang/goproject/src/github.com/operator-framework/operator-registry/bin/kubeconfig" 
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/Dockerfile
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcd.package.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdbackup.crd.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdcluster.crd.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdoperator.v0.9.4-clusterwide.clusterserviceversion.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdoperator.v0.9.4.clusterserviceversion.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdrestore.crd.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/metadata/annotations.yaml
Error: error loading manifests from directory: annotation validation failed, missing or empty values: [operators.operatorframework.io.bundle.manifests.v1, operators.operatorframework.io.bundle.mediatype.v1, operators.operatorframework.io.bundle.metadata.v1, operators.operatorframework.io.bundle.package.v1, operators.operatorframework.io.bundle.channels.v1, operators.operatorframework.io.bundle.channel.default.v1]
Usage:
...

2, Add the correct key/values:
mac:bin jianzhang$ cat /Users/jianzhang/etcd-operator/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: plain
  operators.operatorframework.io.bundle.metadata.v1: metadata/
  operators.operatorframework.io.bundle.package.v1: learn-operator
  operators.coreos.com.bundle.resources: "manifests+metadata"
  operators.coreos.com.bundle.mediatype: "operator-registry+v1"

mac:bin jianzhang$ ./opm alpha bundle extract -c test -n test-cm -k `echo $KUBECONFIG` -m /Users/jianzhang/etcd-operator/
INFO[0000] Loading kube client config from path "/Users/jianzhang/goproject/src/github.com/operator-framework/operator-registry/bin/kubeconfig" 
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/Dockerfile
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcd.package.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdbackup.crd.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdcluster.crd.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdoperator.v0.9.4-clusterwide.clusterserviceversion.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdoperator.v0.9.4.clusterserviceversion.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/manifests/etcdrestore.crd.yaml
INFO[0001] Reading file                                  file=/Users/jianzhang/etcd-operator/metadata/annotations.yaml

3, Check the results of the configmap, only the below fields can be added into the ConfigMap object.
That means other annotations cannot be added into the ConfigMap object. @Anik Is it as expected?

mac:bin jianzhang$ oc get cm -n test-cm test -o yaml |grep annotation -A 7
...
  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: plain
    operators.operatorframework.io.bundle.metadata.v1: metadata/
    operators.operatorframework.io.bundle.package.v1: learn-operator

Comment 5 Anik 2019-11-19 14:54:18 UTC
@Jia you can add other key/value pairs in your annotations.yaml, they just wont be used by operator-registry while updating the configmap. We're just making sure that the set of key/value pairs we expect are definitely there. You could always have more key/value pairs in your annotations.yaml, they just won't be used, or update the configmap manually after it has been updated to add your own annotations.

Comment 6 Jian Zhang 2019-11-20 02:16:44 UTC
Anik,

Got it, thanks! Verify it per comment 4, 5.

Comment 8 errata-xmlrpc 2020-01-23 11:12:28 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:0062


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