Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-35728

[OLMv1] failed to remove the BD owned CRD resource

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Normal Normal
    • None
    • 4.16.0
    • OLM
    • Important
    • No
    • Rejected
    • False
    • Hide

      None

      Show
      None

      Description of problem:

      The owner `BundleDeployment` pipelines-operator was deleted before deleting `tektonaddons.operator.tekton.dev`. Seems like the `blockOwnerDeletion: true` didn't work. And failed to remove `tektonaddons.operator.tekton.dev` CRD since it had been changed to the orphan resource. 

      - lastTransitionTime: "2024-06-18T06:51:36Z"
          message: 'bundledeployment not ready: Unable to continue with install: CustomResourceDefinition
            "tektonaddons.operator.tekton.dev" in namespace "" exists and cannot be imported
            into the current release: invalid ownership metadata; annotation validation
            error: key "meta.helm.sh/release-name" must equal "pipelines-operator-1.11":
            current value is "pipelines-operator"
      
      jiazha-mac:~ jiazha$ oc delete crd tektonaddons.operator.tekton.dev --force
      Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
      customresourcedefinition.apiextensions.k8s.io "tektonaddons.operator.tekton.dev" force deleted
      
      ^Cjiazha-mac:~ jiazha$ oget crd|grep tektonaddons
      tektonaddons.operator.tekton.dev                                  2024-06-18T02:59:36Z
      
      jiazha-mac:~ jiazha$ oc get crd tektonaddons.operator.tekton.dev -o yaml
      apiVersion: apiextensions.k8s.io/v1
      kind: CustomResourceDefinition
      metadata:
        annotations:
          meta.helm.sh/release-name: pipelines-operator
          meta.helm.sh/release-namespace: test
        creationTimestamp: "2024-06-18T02:59:36Z"
        deletionGracePeriodSeconds: 0
        deletionTimestamp: "2024-06-18T06:50:15Z"
        finalizers:
        - customresourcecleanup.apiextensions.k8s.io
        generation: 1
        labels:
          app.kubernetes.io/managed-by: Helm
          core.rukpak.io/owner-kind: BundleDeployment
          core.rukpak.io/owner-name: pipelines-operator
          operator.tekton.dev/release: v0.70.3
          version: 1.14.4
        name: tektonaddons.operator.tekton.dev
        ownerReferences:
        - apiVersion: core.rukpak.io/v1alpha2
          blockOwnerDeletion: true
          controller: true
          kind: BundleDeployment
          name: pipelines-operator
          uid: 73cd3e1d-d739-4c76-a57c-7867af40b06e
        resourceVersion: "304232"
        uid: 592b97db-1f0a-451d-b96b-de4e8e753649
      spec:
        conversion:
          strategy: None
        group: operator.tekton.dev
        names:
          kind: TektonAddon
          listKind: TektonAddonList
          plural: tektonaddons
          singular: tektonaddon
        scope: Cluster
        versions:
        - additionalPrinterColumns:
          - jsonPath: .status.version
            name: Version
            type: string
          - jsonPath: .status.conditions[?(@.type=="Ready")].status
            name: Ready
            type: string
          - jsonPath: .status.conditions[?(@.type=="Ready")].message
            name: Reason
            type: string
          name: v1alpha1
          schema:
            openAPIV3Schema:
              description: Schema for the tektonaddons API
              type: object
              x-kubernetes-preserve-unknown-fields: true
          served: true
          storage: true
          subresources:
            status: {}
      status:
        acceptedNames:
          kind: TektonAddon
          listKind: TektonAddonList
          plural: tektonaddons
          singular: tektonaddon
        conditions:
        - lastTransitionTime: "2024-06-18T02:59:36Z"
          message: no conflicts found
          reason: NoConflicts
          status: "True"
          type: NamesAccepted
        - lastTransitionTime: "2024-06-18T02:59:36Z"
          message: the initial names have been accepted
          reason: InitialNamesAccepted
          status: "True"
          type: Established
        - lastTransitionTime: "2024-06-18T06:50:15Z"
          message: CustomResource deletion is in progress
          reason: InstanceDeletionInProgress
          status: "True"
          type: Terminating
        storedVersions:
        - v1alpha1
      
      jiazha-mac:~ jiazha$ oc get bd 
      No resources found

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

       

      How reproducible:

      always

      Steps to Reproduce:

      1. Install a catalog resource.
      jiazha-mac:~ jiazha$ cat catalog-rh2.yaml 
      apiVersion: catalogd.operatorframework.io/v1alpha1
      kind: Catalog
      metadata:
        name: redhat-test
      spec:
        source:
          type: image
          image:
            ref: registry.redhat.io/redhat/redhat-operator-index:v4.16
            pullSecret: catalog-rh2
      
      jiazha-mac:~ jiazha$ oc get catalog  redhat-operators -o yaml
      apiVersion: catalogd.operatorframework.io/v1alpha1
      kind: Catalog
      metadata:
        creationTimestamp: "2024-06-18T02:56:23Z"
        finalizers:
        - catalogd.operatorframework.io/delete-server-cache
        generation: 1
        name: redhat-operators
        resourceVersion: "126819"
        uid: 7199a898-73df-45e4-8e35-4cc7655104e9
      spec:
        source:
          image:
            pullSecret: catalog-rh2
            ref: registry.redhat.io/redhat/redhat-operator-index:v4.16
          type: image
      status:
        conditions:
        - lastTransitionTime: "2024-06-18T02:56:52Z"
          message: ""
          reason: UnpackSuccessful
          status: "True"
          type: Unpacked
        contentURL: http://catalogd-catalogserver.openshift-catalogd.svc/catalogs/redhat-operators/all.json
        observedGeneration: 1
        phase: Unpacked
        resolvedSource:
          image:
            lastPollAttempt: "2024-06-18T02:56:45Z"
            ref: registry.redhat.io/redhat/redhat-operator-index:v4.16
            resolvedRef: registry.redhat.io/redhat/redhat-operator-index@sha256:b559f853675f4506646581340ff2652b5cf456e646c676993856ec69ae7d2784
          type: image
       
      2. Install clusterextension pipelines-operator with the latest version.
      jiazha-mac:~ jiazha$ cat ce-pipeline.yaml 
      apiVersion: olm.operatorframework.io/v1alpha1
      kind: ClusterExtension
      metadata:
        name: pipelines-operator
      spec:
        packageName: openshift-pipelines-operator-rh
        installNamespace: test
        channel: latest
      
      It works well.
      3. remove it and reinstall pipelines-operator with version 1.11.1
      jiazha-mac:~ jiazha$ cat ce-pipeline-1.11.yaml 
      apiVersion: olm.operatorframework.io/v1alpha1
      kind: ClusterExtension
      metadata:
        name: pipelines-operator-1.11
      spec:
        packageName: openshift-pipelines-operator-rh
        installNamespace: test
        version: 1.11.1
      
      
      
      

      Actual results:

      failed to install the 1.11.1 version due to the legacy CRD `tektonaddons.operator.tekton.dev` and I cannot remove that orphan CRD resource

      jiazha-mac:~ jiazha$ oc get clusterextension pipelines-operator-1.11 -o yaml
      apiVersion: olm.operatorframework.io/v1alpha1
      kind: ClusterExtension
      metadata:
        creationTimestamp: "2024-06-18T07:50:24Z"
        generation: 1
        name: pipelines-operator-1.11
        resourceVersion: "334680"
        uid: e4797caf-27ba-4c47-95ed-ac57c208dd61
      spec:
        installNamespace: test
        packageName: openshift-pipelines-operator-rh
        upgradeConstraintPolicy: Enforce
        version: 1.11.1
      status:
        conditions:
        - lastTransitionTime: "2024-06-18T07:50:33Z"
          message: resolved to "registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:e09d37bb1e754db42324fd18c1cb3e7ce77e7b7fcbf4932d0535391579938280"
          observedGeneration: 1
          reason: Success
          status: "True"
          type: Resolved
        - lastTransitionTime: "2024-06-18T07:50:54Z"
          message: 'bundledeployment not ready: Unable to continue with install: CustomResourceDefinition
            "tektonaddons.operator.tekton.dev" in namespace "" exists and cannot be imported
            into the current release: invalid ownership metadata; annotation validation
            error: key "meta.helm.sh/release-name" must equal "pipelines-operator-1.11":
            current value is "pipelines-operator"'
          observedGeneration: 1
          reason: InstallationFailed
          status: "False"
          type: Installed
        - lastTransitionTime: "2024-06-18T07:50:33Z"
          message: ""
          observedGeneration: 1
          reason: Deprecated
          status: "False"
          type: Deprecated
        - lastTransitionTime: "2024-06-18T07:50:33Z"
          message: ""
          observedGeneration: 1
          reason: Deprecated
          status: "False"
          type: PackageDeprecated
        - lastTransitionTime: "2024-06-18T07:50:33Z"
          message: ""
          observedGeneration: 1
          reason: Deprecated
          status: "False"
          type: ChannelDeprecated
        - lastTransitionTime: "2024-06-18T07:50:33Z"
          message: ""
          observedGeneration: 1
          reason: Deprecated
          status: "False"
          type: BundleDeprecated
        resolvedBundle:
          name: openshift-pipelines-operator-rh.v1.11.1
          version: 1.11.1
      
      jiazha-mac:~ jiazha$ oc delete crd tektonaddons.operator.tekton.dev --force
      Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
      customresourcedefinition.apiextensions.k8s.io "tektonaddons.operator.tekton.dev" force deleted
      
      ^Cjiazha-mac:~ jiazha$ oget crd|grep tektonaddons
      tektonaddons.operator.tekton.dev                                  2024-06-18T02:59:36Z

      Expected results:

      The tektonaddons.operator.tekton.dev resource should be deleted before deleting the pipelines-operator BD since the `blockOwnerDeletion: true`.

        ownerReferences:
        - apiVersion: core.rukpak.io/v1alpha2
          blockOwnerDeletion: true
          controller: true
          kind: BundleDeployment
          name: pipelines-operator
          uid: 73cd3e1d-d739-4c76-a57c-7867af40b06e

      Additional info:

      This orphan CRD resource cannot be deleted and blocked the following pipeline-operator installation.

      jiazha-mac:~ jiazha$ oc delete  crd tektonaddons.operator.tekton.dev 
      customresourcedefinition.apiextensions.k8s.io "tektonaddons.operator.tekton.dev" deleted --force
      ...

              lmohanty@redhat.com Lalatendu Mohanty
              rhn-support-jiazha Jian Zhang
              Jian Zhang Jian Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: