Bug 1790785

Summary: `oc adm catalog build` should immediately error out if it can't find any data in appregistry
Product: OpenShift Container Platform Reporter: Jian Zhang <jiazha>
Component: OLMAssignee: Bowen Song <bsong>
OLM sub component: OLM QA Contact: Jian Zhang <jiazha>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: high CC: bsong, ecordell, nhale
Version: 4.4   
Target Milestone: ---   
Target Release: 4.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1796675 (view as bug list) Environment:
Last Closed: 2020-05-04 11:24:06 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:
Bug Depends On:    
Bug Blocks: 1804554    

Description Jian Zhang 2020-01-14 07:44:05 UTC
Description of problem:
No error report when the `oc adm catalog build` gets none data.


Version-Release number of selected component (if applicable):
Cluster version is: 4.3.0-0.nightly-2020-01-14-000626 
[jzhang@dhcp-140-36 ~]$ oc version
Client Version: 4.3.0-0.nightly-2020-01-14-000626
Server Version: 4.3.0-0.nightly-2020-01-14-000626
Kubernetes Version: v1.16.2

How reproducible:
always

Steps to Reproduce:
1. Create an OCP 4.3.

2. Enable the cluster registry.
[jzhang@dhcp-140-36 ~]$ oc patch configs.imageregistry.operator.openshift.io/cluster -p='{"spec":{"defaultRoute":true}}' --type=merge
config.imageregistry.operator.openshift.io/cluster patched
[jzhang@dhcp-140-36 ~]$ oc get images.config.openshift.io/cluster  -o jsonpath={.status.externalRegistryHostnames[0]} 
default-route-openshift-image-registry.apps.qe-jiazha-dis.qe.devcluster.openshift.com
[jzhang@dhcp-140-36 ~]$ oc get secret router-certs-default -n openshift-ingress -o json |jq -r '.data["tls.crt"]' | base64 -d | sudo tee /etc/pki/ca-trust/source/anchors/disconnected.crt
[jzhang@dhcp-140-36 ~]$ sudo update-ca-trust 
[jzhang@dhcp-140-36 ~]$ oc create serviceaccount registry
serviceaccount/registry created
[jzhang@dhcp-140-36 ~]$ oc adm policy add-cluster-role-to-user admin -z registry
clusterrole.rbac.authorization.k8s.io/admin added: "registry"
[jzhang@dhcp-140-36 ~]$ docker login default-route-openshift-image-registry.apps.qe-jiazha-dis.qe.devcluster.openshift.com -u reegistry -p `oc sa get-token registry`

3. Run "oc adm catalog build xxx", like below:
[jzhang@dhcp-140-36 ~]$ oc adm catalog build --appregistry-org=redhat-operators-art --to=default-route-openshift-image-registry.apps.qe-jiazha-dis.qe.devcluster.openshift.com/openshift/olm:v1 

Actual results:
The "oc adm catalog build" runs successfully, no errors out.
[jzhang@dhcp-140-36 ~]$ oc adm catalog build --appregistry-org=redhat-operators-art --auth-token="xxx"(replace real token with xxx) --to=default-route-openshift-image-registry.apps.qe-jiazha-dis.qe.devcluster.openshift.com/openshift/olm:v1 
INFO[0001] loading Bundles                               dir=/tmp/manifests-445659376
INFO[0001] directory                                     dir=/tmp/manifests-445659376 file=manifests-445659376 load=bundles
INFO[0001] loading Packages and Entries                  dir=/tmp/manifests-445659376
INFO[0001] directory                                     dir=/tmp/manifests-445659376 file=manifests-445659376 load=package
Uploading ... 471.6B/s
Uploading 3.405MB ...
Uploading 9.833MB ...
Pushed sha256:18958ad670fc84e93e4149b933eaa6173adb22a4e2dfc70f0db84b36ee0d1bb2 to default-route-openshift-image-registry.apps.qe-jiazha-dis.qe.devcluster.openshift.com/openshift/olm:v1


Expected results:
Since this redhat-operators-art is a private repo, the "oc adm catalog build" cannot get any data, but it should report errors immediately.

Additional info:

Comment 9 Jian Zhang 2020-03-10 02:30:30 UTC
oc version:
[jzhang@dhcp-140-36 ~]$ ./oc version -o yaml
clientVersion:
  buildDate: "2020-03-07T03:47:49Z"
  compiler: gc
  gitCommit: 8ce61268781d2074158d05ad11141792b94b1910
  gitTreeState: dirty
  gitVersion: openshift-clients-4.5.0-202003062301
  goVersion: go1.13.4
  major: ""
  minor: ""
  platform: linux/amd64
releaseClientVersion: 4.5.0-0.nightly-2020-03-09-225220
...

1, Build a local docker registry.
2, Run "oc adm catalog build xxx", like below:
[jzhang@dhcp-140-36 ~]$ ./oc adm catalog build --appregistry-org=redhat-operators-art --to=localhost:5000/olm/bug:v1
error: no manifests downloaded from appregistry https://quay.io/cnr/redhat-operators-art

The errors report timely, LGTM, verify it.

Comment 11 errata-xmlrpc 2020-05-04 11:24:06 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:0581