Bug 1836447

Summary: Operator update is failing due to missing replace field in Operator CSV
Product: OpenShift Container Platform Reporter: OpenShift BugZilla Robot <openshift-bugzilla-robot>
Component: OLMAssignee: Alexander Greene <agreene>
OLM sub component: OLM QA Contact: Jian Zhang <jiazha>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: high CC: bsong, ecordell, krizza
Version: 4.3.zKeywords: UpcomingSprint
Target Milestone: ---   
Target Release: 4.2.z   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: If an operator is being upgraded that provides a required API whose GVK has not changed since the previous version of the operator and the operator that depends on the API uses a skipRange instead of the Spec.Replaces field, OLM fails to generate the "upgraded CSV" with the correct replaces field. Specifically, OLM would: 1. Add the new operator to the generation, and marking the APIs it provides as "present". 2. Remove the old operator from the generation, marking the APIs it provides as "absent", despite being provided by the new version of the operator. 3. Attempt to resolve the "missing" apis, overwriting the the new version of the operator with a copy that does not have its Spec.Replaces field set. Consequence: Certain operators would fail to upgrade to new versions. Fix: OLM was updated to remove the old operator from the current generation before adding the new operator to the generation. Result: The upgrade will succeed as expected.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-07-01 16:08:20 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: 1827822    
Bug Blocks:    

Comment 6 Jian Zhang 2020-06-22 02:29:32 UTC
mac:~ jianzhang$ oc get clusterversion
NAME      VERSION                             AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.2.0-0.nightly-2020-06-21-204910   True        False         19m     Cluster version is 4.2.0-0.nightly-2020-06-21-204910

mac:~ jianzhang$ oc  -n openshift-operator-lifecycle-manager   exec catalog-operator-5794779d76-r8nzc -- olm --version
OLM version: 0.11.0
git commit: 724678af9fae43bb638f2f65edfdf4b02cb5730c

1, installed a catsrc that pointed to the catalog image that only contained the 1.0.0 versions of the operator
mac:~ jianzhang$ oc create -f cs-bug.yaml 
catalogsource.operators.coreos.com/bug-operator created
mac:~ jianzhang$ cat cs-bug.yaml 
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: bug-operator
  namespace: openshift-marketplace
spec:
  sourceType: grpc
  image: quay.io/agreene/busybox-dependencies:old
  displayName: Agreene Operators
  publisher: Agreene

mac:~ jianzhang$ oc get catalogsource -n openshift-marketplace
NAME                  DISPLAY               TYPE   PUBLISHER   AGE
bug-operator          Agreene Operators     grpc   Agreene     40s
certified-operators   Certified Operators   grpc   Red Hat     31m
community-operators   Community Operators   grpc   Red Hat     31m
redhat-operators      Red Hat Operators     grpc   Red Hat     31m
mac:~ jianzhang$ oc get packagemanifest|grep busy
busybox-dependency                           Agreene Operators     64s
busybox                                      Agreene Operators     64s

2, created an OperatorGroup and a subscription 
mac:~ jianzhang$ oc create -f og.yaml 
operatorgroup.operators.coreos.com/test-og created
mac:~ jianzhang$ cat og.yaml 
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
  name: test-og
  namespace: openshift-marketplace
spec:
  targetNamespaces:
  - openshift-marketplace

mac:~ jianzhang$ oc create -f sub-busybox.yaml 
subscription.operators.coreos.com/busybox created
mac:~ jianzhang$ cat sub-busybox.yaml 
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: busybox
  namespace: openshift-marketplace
spec:
  channel: "alpha"
  installPlanApproval: Automatic
  name: busybox
  source: bug-operator
  sourceNamespace: openshift-marketplace
  startingCSV: busybox.v1.0.0

mac:~ jianzhang$ oc get sub
NAME                                                          PACKAGE              SOURCE         CHANNEL
busybox                                                       busybox              bug-operator   alpha
busybox-dependency-alpha-bug-operator-openshift-marketplace   busybox-dependency   bug-operator   alpha
mac:~ jianzhang$ oc get csv
NAME                        DISPLAY              VERSION   REPLACES   PHASE
busybox-dependency.v1.0.0   busybox-dependency   1.0.0                Succeeded
busybox.v1.0.0              busybox              1.0.0                Succeeded

3, Update this CatalogSource image(quay.io/agreene/busybox-dependencies:old) to the new one: quay.io/agreene/busybox-dependencies:new(contains 2.0.0 version)

mac:~ jianzhang$ oc edit catalogsource bug-operator
catalogsource.operators.coreos.com/bug-operator edited

mac:~ jianzhang$ oc get csv
NAME                        DISPLAY              VERSION   REPLACES                    PHASE
busybox-dependency.v2.0.0   busybox-dependency   2.0.0     busybox-dependency.v1.0.0   Succeeded
busybox.v2.0.0              busybox              2.0.0     busybox.v1.0.0              Succeeded
mac:~ jianzhang$ oc get pods
NAME                                   READY   STATUS        RESTARTS   AGE
bug-operator-5pz7x                     1/1     Running       0          88s
busybox-d6f5b984c-8rtdw                1/1     Running       0          55s
busybox-dependency-786669d4cd-jz2r9    0/1     Terminating   0          4m12s
busybox-dependency-79c5ddf6f-6r2r6     1/1     Running       0          52s
certified-operators-8455cfc6b6-5wbkn   1/1     Running       0          42m
community-operators-9b6dd597f-h7twm    1/1     Running       0          42m
marketplace-operator-69d75d9b4-p97tc   1/1     Running       0          42m
redhat-operators-6c85db9fff-5g8s8      1/1     Running       0          42m

The operator has been upgraded to "2.0.0" version successfully. LGTM, verify it.

Comment 8 errata-xmlrpc 2020-07-01 16:08:20 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:2589