Bug 1986753

Summary: It fails to block the cluster upgrade when have an empty value in olm.maxOpenShiftVersion
Product: OpenShift Container Platform Reporter: Jian Zhang <jiazha>
Component: OLMAssignee: Nick Hale <nhale>
OLM sub component: OLM QA Contact: Jian Zhang <jiazha>
Status: CLOSED DUPLICATE Docs Contact:
Severity: medium    
Priority: medium CC: nhale
Version: 4.9   
Target Milestone: ---   
Target Release: 4.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-08-03 18:35:18 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:

Description Jian Zhang 2021-07-28 09:40:02 UTC
Description of problem:
I create an etcd operator that contains the olm.properties: '[{"type": "olm.maxOpenShiftVersion", "value": " "},{"type": "olm.maxOpenShiftVersion", "value": "4.1.0"}]', here: https://github.com/jianzhangbjz/community-operators/blob/OLM-2074/etcd/0.9.2-clusterwide/etcdoperator.v0.9.2-clusterwide.clusterserviceversion.yaml#L23

The semver treats " " as "0.0.0" that lower than "4.1.0",
And, "4.1.0" lower than the next version "4.10.0-0.nightly-2021-07-27-125952", so, it should block the cluster(4.9.0-0.nightly-2021-07-27-125952) upgrade, but it didn't. The status of the Upgradeable should be "False", not "True".

[cloud-user@preserve-olm-env jian]$ oc get csv -o yaml|grep "maxOpenShiftVersion"
      olm.properties: '[{"type": "olm.maxOpenShiftVersion", "value": " "},{"type":
        "olm.maxOpenShiftVersion", "value": "4.1.0"}]'

[cloud-user@preserve-olm-env jian]$ oc get co operator-lifecycle-manager -o=jsonpath={.status.conditions[?(@.type==\"Upgradeable\")].status}
True

Version-Release number of selected component (if applicable):
4.9.0-0.nightly-2021-07-27-125952
[cloud-user@preserve-olm-env jian]$ oc -n openshift-operator-lifecycle-manager exec deploy/catalog-operator -- olm --version
OLM version: 0.18.3
git commit: 3475b1d5d8d481394ba90b2823645bed0fb2b076

How reproducible:
always

Steps to Reproduce:
1. Install OCP 4.9.

2. Create a CatalogSource that consumes the index image: quay.io/olmqe/etcd-index:upgrade-max

[cloud-user@preserve-olm-env jian]$ cat cs-max.yaml 
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: max-operators
  namespace: openshift-marketplace
spec:
  displayName: Jian Operators
  image: quay.io/olmqe/etcd-index:upgrade-max
  priority: -200
  publisher: Jian
  sourceType: grpc
  updateStrategy:
    registryPoll:
      interval: 10m0s
[cloud-user@preserve-olm-env jian]$ oc create -f cs-max.yaml 
catalogsource.operators.coreos.com/max-operators created

3. Subscribe to etcd-operator v0.9.2-cluster
[cloud-user@preserve-olm-env jian]$ cat sub-etcd-cluster.yaml 
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: etcd
  namespace: openshift-operators
spec:
  channel: clusterwide-alpha
  installPlanApproval: Manual
  name: etcd
  source: max-operators
  sourceNamespace: openshift-marketplace
  startingCSV: etcdoperator.v0.9.2-clusterwide

[cloud-user@preserve-olm-env jian]$ oc create -f sub-etcd-cluster.yaml 
subscription.operators.coreos.com/etcd created

[cloud-user@preserve-olm-env jian]$ oc get sub
NAME   PACKAGE   SOURCE          CHANNEL
etcd   etcd      max-operators   clusterwide-alpha
[cloud-user@preserve-olm-env jian]$ oc get ip
NAME            CSV                               APPROVAL   APPROVED
install-l2pbv   etcdoperator.v0.9.4-clusterwide   Manual     false
install-tnb4x   etcdoperator.v0.9.2-clusterwide   Manual     true
[cloud-user@preserve-olm-env jian]$ oc get csv
NAME                              DISPLAY   VERSION             REPLACES   PHASE
etcdoperator.v0.9.2-clusterwide   etcd      0.9.2-clusterwide              Succeeded


4, check the status of the Upgradeable.

Actual results:
The status is `True`. It should be `False`.
[cloud-user@preserve-olm-env jian]$ oc get csv -o yaml|grep "maxOpenShiftVersion"
      olm.properties: '[{"type": "olm.maxOpenShiftVersion", "value": " "},{"type":
        "olm.maxOpenShiftVersion", "value": "4.1.0"}]'

[cloud-user@preserve-olm-env jian]$ oc get co operator-lifecycle-manager -o=jsonpath={.status.conditions[?(@.type==\"Upgradeable\")].status}
True

Expected results:
The Upgradeable status shoule be False.

Additional info:
Ideally, if the version of the operator's olm.maxOpenShiftVersion is lower than the current cluster version, OLM should alert a warning and fail to install this operator. But, anyway, once this operator is installed, the upgrade status should be `False`.