Bug 1782837

Summary: Can't install operator unless I install the dependency operator first
Product: OpenShift Container Platform Reporter: Evan Cordell <ecordell>
Component: OLMAssignee: Evan Cordell <ecordell>
OLM sub component: OLM QA Contact: Jian Zhang <jiazha>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: high CC: bandrade, ecordell, jiazha, jmatthew, jmontleo, lgallett, scolange, tbuskey, xjiang
Version: 4.3.0   
Target Milestone: ---   
Target Release: 4.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1781366 Environment:
Last Closed: 2020-01-23 11:18:56 UTC Type: ---
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: 1781366    
Bug Blocks:    

Comment 2 Xin jiang 2020-01-09 03:33:56 UTC
OCS 'pv pools' not ready, unable to verify it. set it back to POST.

Comment 4 Jian Zhang 2020-01-09 10:39:42 UTC
Cluster version is 4.3.0-rc.0
mac:manifest jianzhang$ oc exec catalog-operator-6f887bc6fb-pqzrc -- olm --version
OLM version: 0.13.0
git commit: c74333dbe61d92e1a75b09f74c0dc2c99b05405a

1, Create the CatalogSource image.

1) Copy the OCS and CAM operators manifest.
mac:cam jianzhang$ cp -r ocs-operator/deploy/olm-catalog/ocs-operator manifests/
mac:cam jianzhang$ cp -r /Users/jianzhang/cam/mig-operator/deploy/olm-catalog/mig-operator ./manifests 

Remove the "replaces" fields from their CSV.
And, remove unnecessary channels. Like below:
mac:cam jianzhang$ cat manifests/mig-operator/mig-operator.package.yaml 
packageName: mig-operator
channels:
- name: release-v1
  currentCSV: mig-operator.v1.0.1
defaultChannel: release-v1
mac:cam jianzhang$ cat manifests/ocs-operator/ocs-operator.package.yaml 
packageName: ocs-operator
channels:
- name: alpha
  currentCSV: ocs-operator.v4.3.0
defaultChannel: alpha

2) Add the "required" field in the CAM CSV file. Like below:
mac:manifest jianzhang$ vim v1.0.1/mig-operator.v1.0.1.clusterserviceversion.yaml
...
  version: 1.0.1
  customresourcedefinitions:
    required:
    - name: noobaas.noobaa.io
      version: v1alpha1
      kind: NooBaa
      displayName: NooBaa
      description: NooBaa System
    owned:
...

3) Create a Docker file, like below:
mac:cam jianzhang$ cat Dockerfile 
FROM registry.redhat.io/openshift4/ose-operator-registry:v4.2.8 AS builder

COPY manifests manifests

RUN /bin/initializer -o ./bundles.db

FROM openshift/origin-base

COPY --from=builder /registry/bundles.db /bundles.db
COPY --from=builder /usr/bin/registry-server /registry-server
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe

EXPOSE 50051

ENTRYPOINT ["/registry-server"]

CMD ["--database", "bundles.db"]
mac:cam jianzhang$ pwd
/Users/jianzhang/cam
mac:cam jianzhang$ ls
Dockerfile manifestsv

4) Create a new image called "quay.io/aosqe4/cam-catalog:bug2-1782837" and push it to the Quay(make it public).
mac:cam jianzhang$ docker build -t quay.io/aosqe4/cam-catalog:bug2-1782837 .
Sending build context to Docker daemon  153.1kB
Step 1/10 : FROM registry.redhat.io/openshift4/ose-operator-registry AS builder
 ---> 398b172db5a7
Step 2/10 : COPY manifests manifests
 ---> bd7b2fc9b4b6
Step 3/10 : RUN /bin/initializer -o ./bundles.db
 ---> Running in 49c945cf91e8
...
Successfully built 6fd3eb04f5ba
Successfully tagged quay.io/aosqe4/cam-catalog:bugSuccessfully built 6fd3eb04f5ba
Successfully tagged quay.io/aosqe4/cam-catalog:bug

mac:cam jianzhang$ docker push quay.io/aosqe4/cam-catalog:bug2-1782837
...

2, Create a CatalogSource object to consume this image. Like below:
mac:cam jianzhang$ cat cs.yaml 
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: cam-operator
  namespace: openshift-marketplace
spec:
  sourceType: grpc
  image: quay.io/aosqe4/cam-catalog:bug2-1782837
  displayName: Jian Operators
  publisher: jian

mac:cam jianzhang$ oc create -f cs.yaml 
catalogsource.operators.coreos.com/cam-operator created
mac:cam jianzhang$ oc get catalogsource
NAME                  DISPLAY               TYPE   PUBLISHER   AGE
cam-operator          Jian Operators        grpc   jian        3m24s
mac:cam jianzhang$ oc get pods
NAME                                    READY   STATUS    RESTARTS   AGE
cam-operator-jr4jw                      1/1     Running   0          6m40s

3, Check the OCS and CAM operators.
mac:cam jianzhang$ oc get packagemanifest |grep mig
mig-operator                                 Jian Operators        8m53s
mac:cam jianzhang$ oc get packagemanifest |grep ocs
ocs-operator                                 Jian Operators        9m24s

4, Subscribe to this CAM operator in the default project. See screenshot: https://user-images.githubusercontent.com/15416633/72060309-af30ef80-330e-11ea-9bb0-f7858768b945.png

5, Check if the dependent OCS can be installed automatically.

mac:cam jianzhang$ oc get sub -n default
NAME                                                                      PACKAGE                   SOURCE                CHANNEL
mig-operator                                                              mig-operator              cam-operator          release-v1
ocs-operator-alpha-cam-operator-openshift-marketplace                     ocs-operator              cam-operator          alpha
mac:cam jianzhang$ oc get csv -n default
NAME                                        DISPLAY                          VERSION              REPLACES                  PHASE
mig-operator.v1.0.1                         Migration Operator               1.0.1                                          Succeeded
ocs-operator.v4.3.0                         OpenShift Container Storage      4.3.0                                          Succeeded

mac:cam jianzhang$ oc get pods -n default
NAME                                            READY   STATUS    RESTARTS   AGE
aws-s3-provisioner-5c7bd499ff-bfk5r             1/1     Running   0          2m38s
migration-operator-5b87f7fc8f-59ckg             2/2     Running   0          2m43s
noobaa-operator-855bd56d6-x8qxx                 1/1     Running   0          2m38s
ocs-operator-67b989cc66-t4kgg                   1/1     Running   0          2m38s
rook-ceph-operator-696d8c4f47-98gtp             1/1     Running   0          2m38s


It works! This dependent OCS operator can be installed automatically. Verify it.

Comment 6 errata-xmlrpc 2020-01-23 11:18:56 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