OLM is unable to generate new install plans

The Operator Lifecycle Manager (OLM) is unable to generate new installation plans for updates or new installations.

Symptom

OLM is leaving Subscription objects without an InstallPlanRef and InstallPlan resulting in any future updates of existing operators or installations of new operators being able to generate install plans.

Looking at the catalog-operator log, you see the following:

$ oc logs -n openshift-operator-lifecycle-manager <catalog-operator-pod> | grep "unable to get installplan from cache"

2022-02-16T18:02:32.250375793Z time="2022-02-16T18:02:32Z" level=warning msg="unable to get installplan from cache" channel=stable id=7HkBf installplan=install-lhmkp namespace=ibm-common-services pkg=cloud-native-postgresql source=ibm-operator-catalog sub=cloud-native-postgresql-stable-ibm-operator-catalog-openshift-marketplace

Resolution

To resolve this issue, you can either delete the Subscription or delete the metadata.annotations.olm.generated-by field.

Deleting the Subscription

The deletion of previous Subscription and CSV from the namespace of that operator which need to be upgraded fixes the missing InstallPlan generation:

$ oc get subs -n [namespace_name]
[...]
$ oc delete subs [subs_names_separated_by_spaces] -n [namespace_name] --wait
subscription.operators.coreos.com "old-operator-subscription" deleted
$ oc get csv -n [namespace_name]
[...]
$ oc delete csv [cvs_names_separated_by_spaces] -n [namespace_name] --wait
clusterserviceversion.operators.coreos.com "old-operator.v2.4.2" deleted
$ oc describe subs/new-operator-subscription -n <namespace_name>

 Install Plan Generation:  1
  Install Plan Ref:
    API Version:       operators.coreos.com/v1alpha1
    Kind:              InstallPlan
    Name:              install-mxw59
    Namespace:         <namespace_name>
    Resource Version:  215607
    UID:               43162fc6-c91e-4394-a836-1399c7465a11
  Installplan:
    API Version:  operators.coreos.com/v1alpha1
    Kind:         InstallPlan
    Name:         install-mxw59
    Uuid:         43162fc6-c91e-4394-a836-1399c7465a11
  Last Updated:   2022-04-25T08:24:08Z
  State:          UpgradePending

Deleting the metadata.annotations.olm.generated-by field

Simply delete the metadata.annotations.olm.generated-by field:

apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  annotations:
    olm.generated-by: install-zs6p2 <----------------- this annotation
  name: >-
    ibm-common-service-operator-v4.2-opencloud-operators-v4-2-openshift-marketplace
  namespace: bawent