Bug 1932002

Summary: Only one of multiple subscriptions to the same package is honored
Product: OpenShift Container Platform Reporter: Ben Luddy <bluddy>
Component: OLMAssignee: Ben Luddy <bluddy>
OLM sub component: OLM QA Contact: Tom Buskey <tbuskey>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: high CC: bluddy, jiazha
Version: 4.6Keywords: Triaged
Target Milestone: ---   
Target Release: 4.7.z   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1932001
: 1934637 (view as bug list) Environment:
Last Closed: 2021-03-16 08:42:49 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: 1932001    
Bug Blocks: 1934637    

Description Ben Luddy 2021-02-23 18:28:35 UTC
+++ This bug was initially created as a clone of Bug #1932001 +++

Description of problem:

In dependency resolution, Subscription uniqueness is currently based on the subscribed package name. If two Subscriptions in a namespace subscribe to the same package, they are treated as a single Subscription internally, resulting in some surprising behaviors.

Version-Release number of selected component (if applicable): 4.6

How reproducible: Always

Steps to Reproduce:
1. Subscribe to an operator:

$ cat << EOF | kubectl create -f-
apiVersion: v1
kind: Namespace
metadata:
  name: test-namespace
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
  name: test-operatorgroup
  namespace: test-namespace
spec:
  targetNamespaces:
  - test-namespace
---
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: test-catalog
  namespace: test-namespace
spec:
  displayName: Community Operators
  image: quay.io/operatorhubio/catalog:latest
  sourceType: grpc
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: test-subscription-stable
  namespace: test-namespace
spec:
  name: redis-operator
  source: test-catalog
  sourceNamespace: test-namespace
  channel: stable
  startingCSV: redis-operator.v0.4.0
EOF

namespace/test-namespace created
operatorgroup.operators.coreos.com/test-operatorgroup created
catalogsource.operators.coreos.com/test-catalog created
subscription.operators.coreos.com/test-subscription-stable created

2. Wait for the operator to be installed:

$ kubectl -n test-namespace get csv -w

NAME                    DISPLAY          VERSION   REPLACES                PHASE
redis-operator.v0.4.0   Redis Operator   0.4.0     redis-operator.v0.3.0   
redis-operator.v0.4.0   Redis Operator   0.4.0     redis-operator.v0.3.0   Pending
redis-operator.v0.4.0   Redis Operator   0.4.0     redis-operator.v0.3.0   InstallReady
redis-operator.v0.4.0   Redis Operator   0.4.0     redis-operator.v0.3.0   Installing
redis-operator.v0.4.0   Redis Operator   0.4.0     redis-operator.v0.3.0   Installing
redis-operator.v0.4.0   Redis Operator   0.4.0     redis-operator.v0.3.0   Succeeded

3. Create a conflicting subscription to the same package:

$ cat << EOF | kubectl create -f-
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: test-subscription-alpha
  namespace: test-namespace
spec:
  name: redis-operator
  source: test-catalog
  sourceNamespace: test-namespace
  channel: alpha
  startingCSV: redis-operator.v0.0.1
EOF

subscription.operators.coreos.com/test-subscription-alpha created

Expected results:

Resolution should warn about a conflict between the installed v0.4.0 CSV and the requested v0.0.1 operator from the same package, something like this:

$ kubectl logs -n openshift-operator-lifecycle-manager deploy/catalog-operator | grep ResolutionFailed | tail -1

I0223 18:08:32.095488       1 event.go:282] Event(v1.ObjectReference{Kind:"Namespace", Namespace:"", Name:"test-namespace", UID:"59f61254-01b3-4309-9ecc-3ff29f1d979f", APIVersion:"v1", ResourceVersion:"851", FieldPath:""}): type: 'Warning' reason: 'ResolutionFailed' constraints not satisfiable: subscription test-subscription-stable requires @existing/test-namespace//redis-operator.v0.4.0, subscription test-subscription-stable exists, subscription test-subscription-alpha requires test-catalog/test-namespace/alpha/redis-operator.v0.0.1, subscription test-subscription-alpha exists, @existing/test-namespace//redis-operator.v0.4.0 and test-catalog/test-namespace/alpha/redis-operator.v0.0.1 originate from package redis-operator

Actual results:

The conflict between the two subscriptions is not indicated in the catalog-operator log. There may be some warnings that occur before the CatalogSource becomes available. Those would not indicate that there are two subscriptions to the redis-operator package, and may look something like this:

$ kubectl logs -n openshift-operator-lifecycle-manager deploy/catalog-operator | grep ResolutionFailed | tail -1

I0223 18:03:02.611310       1 event.go:282] Event(v1.ObjectReference{Kind:"Namespace", Namespace:"", Name:"test-namespace", UID:"27194bfe-65ee-4d24-86b0-6384fb6fb1a6", APIVersion:"v1", ResourceVersion:"855", FieldPath:""}): type: 'Warning' reason: 'ResolutionFailed' constraints not satisfiable: no operators found matching the subscription criteria for redis-operator, a subscription to package redis-operator exists in the namespace

--- Additional comment from Ben Luddy on 2021-02-23 18:26:41 UTC ---

A patch for this already merged into release-4.8 (https://github.com/operator-framework/operator-lifecycle-manager/pull/2005), but before this BZ was created.

Comment 1 Ben Luddy 2021-03-01 17:26:15 UTC
Increasing priority to high because a backport of a high priority issue depends on this.

Comment 3 Jian Zhang 2021-03-04 02:43:08 UTC
The latest payload is 4.7.0-0.nightly-2021-03-04-004412, but it doesn't contain the fixed PR. Change the status to MODIFIED first.
[jzhang@dhcp-140-36 ~]$ oc adm release info registry.ci.openshift.org/ocp/release:4.7.0-0.nightly-2021-03-04-004412 --commits |grep lifecycle
  operator-lifecycle-manager                     https://github.com/operator-framework/operator-lifecycle-manager            4b67acc560a790caa37fdff2f2c1a1eb50a4949f

[jzhang@dhcp-140-36 ~]$ oc -n openshift-operator-lifecycle-manager  exec catalog-operator-5764d5d9cf-j5c4j -- olm --version
OLM version: 0.17.0
git commit: 4b67acc560a790caa37fdff2f2c1a1eb50a4949f

Comment 6 Tom Buskey 2021-03-05 17:11:39 UTC
kubectl logs -n openshift-operator-lifecycle-manager deploy/catalog-operator | grep ResolutionFailed  | tail -1
I0305 17:10:07.975136       1 event.go:282] Event(v1.ObjectReference{Kind:"Namespace", Namespace:"", Name:"test-namespace", UID:"39de1bf7-48ff-4e0b-bed8-08535d25ef25", APIVersion:"v1", ResourceVersion:"40579", FieldPath:""}): type: 'Warning' reason: 'ResolutionFailed' constraints not satisfiable: subscription test-subscription-stable requires @existing/test-namespace//redis-operator.v0.4.0, subscription test-subscription-stable exists, subscription test-subscription-alpha requires test-catalog/test-namespace/alpha/redis-operator.v0.0.1, subscription test-subscription-alpha exists, @existing/test-namespace//redis-operator.v0.4.0 and test-catalog/test-namespace/alpha/redis-operator.v0.0.1 originate from package redis-operator

oc version
Client Version: 4.7.0-202103010125.p0-c66c03f
Server Version: 4.7.0-0.nightly-2021-03-05-105959
Kubernetes Version: v1.20.0+5fbfd19

Comment 9 errata-xmlrpc 2021-03-16 08:42:49 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 (OpenShift Container Platform 4.7.2 bug fix update), 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-2021:0749