Bug 2073288

Summary: Should remove operatorhub resource when the marketplace-operator disabled
Product: OpenShift Container Platform Reporter: Jian Zhang <jiazha>
Component: Cluster Version OperatorAssignee: Over the Air Updates <aos-team-ota>
Status: CLOSED DUPLICATE QA Contact: Jian Zhang <jiazha>
Severity: medium Docs Contact:
Priority: high    
Version: 4.11CC: aos-bugs, aos-team-ota, wking
Target Milestone: ---Keywords: Reopened, Triaged
Target Release: ---   
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: 2022-05-08 05:48:22 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 2022-04-08 06:44:45 UTC
Description of problem:
OperatorHub resources still exist when disabling the marketplace-operator installation.

Version-Release number of selected component (if applicable):
Cluster version is 4.11.0-0.nightly-2022-04-07-053433

How reproducible:
always

Steps to Reproduce:
1. Set the below flag at the install time to disable the marketplace-operator installation. For example, https://mastern-jenkins-csb-openshift-qe.apps.ocp-c1.prod.psi.redhat.com/job/ocp-common/job/Flexy-install/92203/parameters/ 

baselineCapabilitySet: None

2. Check the operatorhub resource.


Actual results:
The operatorhub resource still exists.
mac:~ jianzhang$ oc get crd |grep operatorhub
operatorhubs.config.openshift.io                                  2022-04-08T02:41:10Z
mac:~ jianzhang$ oc get operatorhub
NAME      AGE
cluster   46m

Expected results:
The operatorhub resource should be remove since marketplace-operator disabled.

Additional info:
mac:~ jianzhang$ oc get operatorhub cluster -o yaml
apiVersion: config.openshift.io/v1
kind: OperatorHub
metadata:
  annotations:
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/single-node-developer: "true"
    release.openshift.io/create-only: "true"
  creationTimestamp: "2022-04-08T02:42:21Z"
  generation: 1
  name: cluster
  ownerReferences:
  - apiVersion: config.openshift.io/v1
    kind: ClusterVersion
    name: version
    uid: 7f981a4d-f74b-4f3f-99f0-0feff0a172e0
  resourceVersion: "1790"
  uid: 4a5d589c-73b0-4752-b855-58b662a6f1ae
spec: {}

mac:~ jianzhang$ oc get crd operatorhubs.config.openshift.io -o yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    api-approved.openshift.io: https://github.com/openshift/api/pull/470
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/single-node-developer: "true"
  creationTimestamp: "2022-04-08T02:41:10Z"
  generation: 1
  name: operatorhubs.config.openshift.io
  ownerReferences:
  - apiVersion: config.openshift.io/v1
    kind: ClusterVersion
    name: version
    uid: 7f981a4d-f74b-4f3f-99f0-0feff0a172e0
  resourceVersion: "692"
  uid: fd09cb44-da5b-47c8-ae9c-19166e065d94
spec:
  conversion:
    strategy: None
  group: config.openshift.io
  names:
    kind: OperatorHub
    listKind: OperatorHubList
    plural: operatorhubs
    singular: operatorhub
  scope: Cluster
  versions:
  - name: v1
    schema:
      openAPIV3Schema:
        description: "OperatorHub is the Schema for the operatorhubs API. It can be
          used to change the state of the default hub sources for OperatorHub on the
          cluster from enabled to disabled and vice versa. \n Compatibility level
          1: Stable within a major release for a minimum of 12 months or 3 minor releases
          (whichever is longer)."
        properties:
          apiVersion:
            description: 'APIVersion defines the versioned schema of this representation
              of an object. Servers should convert recognized schemas to the latest
              internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
            type: string
          kind:
            description: 'Kind is a string value representing the REST resource this
              object represents. Servers may infer this from the endpoint the client
              submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
            type: string
          metadata:
            type: object
          spec:
            description: OperatorHubSpec defines the desired state of OperatorHub
            properties:
              disableAllDefaultSources:
                description: disableAllDefaultSources allows you to disable all the
                  default hub sources. If this is true, a specific entry in sources
                  can be used to enable a default source. If this is false, a specific
                  entry in sources can be used to disable or enable a default source.
                type: boolean
              sources:
                description: sources is the list of default hub sources and their
                  configuration. If the list is empty, it implies that the default
                  hub sources are enabled on the cluster unless disableAllDefaultSources
                  is true. If disableAllDefaultSources is true and sources is not
                  empty, the configuration present in sources will take precedence.
                  The list of default hub sources and their current state will always
                  be reflected in the status block.
                items:
                  description: HubSource is used to specify the hub source and its
                    configuration
                  properties:
                    disabled:
                      description: disabled is used to disable a default hub source
                        on cluster
                      type: boolean
                    name:
                      description: name is the name of one of the default hub sources
                      maxLength: 253
                      minLength: 1
                      type: string
                  type: object
                type: array
            type: object
          status:
            description: OperatorHubStatus defines the observed state of OperatorHub.
              The current state of the default hub sources will always be reflected
              here.
            properties:
              sources:
                description: sources encapsulates the result of applying the configuration
                  for each hub source
                items:
                  description: HubSourceStatus is used to reflect the current state
                    of applying the configuration to a default source
                  properties:
                    disabled:
                      description: disabled is used to disable a default hub source
                        on cluster
                      type: boolean
                    message:
                      description: message provides more information regarding failures
                      type: string
                    name:
                      description: name is the name of one of the default hub sources
                      maxLength: 253
                      minLength: 1
                      type: string
                    status:
                      description: status indicates success or failure in applying
                        the configuration
                      type: string
                  type: object
                type: array
            type: object
        type: object
    served: true
    storage: true
    subresources:
      status: {}
status:
  acceptedNames:
    kind: OperatorHub
    listKind: OperatorHubList
    plural: operatorhubs
    singular: operatorhub
  conditions:
  - lastTransitionTime: "2022-04-08T02:41:10Z"
    message: no conflicts found
    reason: NoConflicts
    status: "True"
    type: NamesAccepted
  - lastTransitionTime: "2022-04-08T02:41:10Z"
    message: the initial names have been accepted
    reason: InitialNamesAccepted
    status: "True"
    type: Established
  storedVersions:
  - v1

Comment 1 Per da Silva 2022-04-08 12:38:22 UTC
It seems like we also need to update the operatorhub crd resource: https://github.com/openshift/api/blob/master/config/v1/0000_03_config-operator_01_operatorhub.crd.yaml

Comment 2 Per da Silva 2022-04-08 16:15:39 UTC
Actually, it seems it already has the capability annotation: https://github.com/openshift/api/blob/master/config/v1/0000_03_config-operator_01_operatorhub.crd.yaml#L9

Perhaps it hasn't made it downstream yet? Or could this be a CVO issue?

Comment 3 Per da Silva 2022-04-08 16:17:23 UTC
@jiazha could you check if the capability annotation shows up in the CRD on the cluster?

Comment 4 Jian Zhang 2022-04-11 03:52:17 UTC
Hi Per,

I retest it with the latest payload, there is the `capability.openshift.io/name: marketplace` in the operatorhub CRD, but the operatorhub still exists, as follows,

mac:~ jianzhang$ oc adm release info registry.ci.openshift.org/ocp/release:4.11.0-0.nightly-2022-04-10-231114 -a .dockerconfigjson --commits|grep olm
  operator-lifecycle-manager                     https://github.com/openshift/operator-framework-olm                         ed7cf0db6fe1f5e91990ca2c02593ba7d1e3cc2e
  operator-registry                              https://github.com/openshift/operator-framework-olm                         ed7cf0db6fe1f5e91990ca2c02593ba7d1e3cc2e

mac:~ jianzhang$ oc get clusterversion
NAME      VERSION                              AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.11.0-0.nightly-2022-04-10-231114   True        False         8m51s   Cluster version is 4.11.0-0.nightly-2022-04-10-231114
mac:~ jianzhang$ oc get operatorhub
NAME      AGE
cluster   28m

mac:~ jianzhang$ oc get crd operatorhubs.config.openshift.io -o yaml|grep capability
    capability.openshift.io/name: marketplace


mac:~ jianzhang$ oc get operatorhub cluster -o yaml
apiVersion: config.openshift.io/v1
kind: OperatorHub
metadata:
  annotations:
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/single-node-developer: "true"
    release.openshift.io/create-only: "true"
  creationTimestamp: "2022-04-11T01:28:45Z"
  generation: 1
  name: cluster
  ownerReferences:
  - apiVersion: config.openshift.io/v1
    kind: ClusterVersion
    name: version
    uid: 2f1bab64-5d57-4cf0-a5b5-f5ebb1711ac9
  resourceVersion: "1753"
  uid: 7291bdd4-e8fa-46d8-919f-d5993a1fe92c
spec: {}

mac:~ jianzhang$  oc get crd operatorhubs.config.openshift.io -o yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    api-approved.openshift.io: https://github.com/openshift/api/pull/470
    capability.openshift.io/name: marketplace
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/single-node-developer: "true"
  creationTimestamp: "2022-04-11T01:27:33Z"
  generation: 1
  name: operatorhubs.config.openshift.io
  resourceVersion: "242"
  uid: 6f42eee3-fb71-4078-9d34-7694ff214978
spec:
  conversion:
    strategy: None
  group: config.openshift.io
  names:
    kind: OperatorHub
    listKind: OperatorHubList
    plural: operatorhubs
    singular: operatorhub
  scope: Cluster
  versions:
  - name: v1
    schema:
      openAPIV3Schema:
        description: "OperatorHub is the Schema for the operatorhubs API. It can be
          used to change the state of the default hub sources for OperatorHub on the
          cluster from enabled to disabled and vice versa. \n Compatibility level
          1: Stable within a major release for a minimum of 12 months or 3 minor releases
          (whichever is longer)."
        properties:
          apiVersion:
            description: 'APIVersion defines the versioned schema of this representation
              of an object. Servers should convert recognized schemas to the latest
              internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
            type: string
          kind:
            description: 'Kind is a string value representing the REST resource this
              object represents. Servers may infer this from the endpoint the client
              submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
            type: string
          metadata:
            type: object
          spec:
            description: OperatorHubSpec defines the desired state of OperatorHub
            properties:
              disableAllDefaultSources:
                description: disableAllDefaultSources allows you to disable all the
                  default hub sources. If this is true, a specific entry in sources
                  can be used to enable a default source. If this is false, a specific
                  entry in sources can be used to disable or enable a default source.
                type: boolean
              sources:
                description: sources is the list of default hub sources and their
                  configuration. If the list is empty, it implies that the default
                  hub sources are enabled on the cluster unless disableAllDefaultSources
                  is true. If disableAllDefaultSources is true and sources is not
                  empty, the configuration present in sources will take precedence.
                  The list of default hub sources and their current state will always
                  be reflected in the status block.
                items:
                  description: HubSource is used to specify the hub source and its
                    configuration
                  properties:
                    disabled:
                      description: disabled is used to disable a default hub source
                        on cluster
                      type: boolean
                    name:
                      description: name is the name of one of the default hub sources
                      maxLength: 253
                      minLength: 1
                      type: string
                  type: object
                type: array
            type: object
          status:
            description: OperatorHubStatus defines the observed state of OperatorHub.
              The current state of the default hub sources will always be reflected
              here.
            properties:
              sources:
                description: sources encapsulates the result of applying the configuration
                  for each hub source
                items:
                  description: HubSourceStatus is used to reflect the current state
                    of applying the configuration to a default source
                  properties:
                    disabled:
                      description: disabled is used to disable a default hub source
                        on cluster
                      type: boolean
                    message:
                      description: message provides more information regarding failures
                      type: string
                    name:
                      description: name is the name of one of the default hub sources
                      maxLength: 253
                      minLength: 1
                      type: string
                    status:
                      description: status indicates success or failure in applying
                        the configuration
                      type: string
                  type: object
                type: array
            type: object
        type: object
    served: true
    storage: true
    subresources:
      status: {}
status:
  acceptedNames:
    kind: OperatorHub
    listKind: OperatorHubList
    plural: operatorhubs
    singular: operatorhub
  conditions:
  - lastTransitionTime: "2022-04-11T01:27:33Z"
    message: no conflicts found
    reason: NoConflicts
    status: "True"
    type: NamesAccepted
  - lastTransitionTime: "2022-04-11T01:27:33Z"
    message: the initial names have been accepted
    reason: InitialNamesAccepted
    status: "True"
    type: Established
  storedVersions:
  - v1

Comment 5 Per da Silva 2022-04-27 18:43:30 UTC
Marking as non-blocking. This could lead to bad UX (inert CR) but it shouldn't cause any problems, except confusion.

Comment 6 Nick Hale 2022-05-04 19:16:01 UTC
Jian,

Since the resources in the latest payload now have the correct annotation, I don't think we can consider this a bug against OLM. If the annotations aren't effective, that indicates an issue with either:

- CVO
- The installer being used

Closing this out. I suggest reopening this against CVO and/or the installer if the problem persists with the latest versions of either and the most recent payload.

Comment 8 W. Trevor King 2022-05-08 05:48:22 UTC
CRD is gone now, and bug 2082763 is tracking removing the empty CR too.

*** This bug has been marked as a duplicate of bug 2082763 ***