Uploaded image for project: 'Red Hat Developer Hub Bugs'
  1. Red Hat Developer Hub Bugs
  2. RHDHBUGS-2781

Operator inadvertently deletes user-created resources when corresponding features are disabled in CR

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • 1.10.0
    • 1.8.0, 1.9.0
    • Operator
    • None
    • 2
    • False
    • Hide

      None

      Show
      None
    • False

      Description of problem:

      When a Feature is disabled in the CR, like route, localDB or monitoring, the Operator attempts to delete any resources that would have been created if this feature was enabled in the CR:

      The problem is that the user might have purposely created such resources, for example in an attempt to override some behavior that is not possible yet via the CR.

      Noticed this for example when trying to use an external Database with the Orchestrator enabled, but still having the SonataflowPlatform resource managed by the Operator.. For this, we tried to manually create a DB Service named "backstage-psql-<backstage-name>" (and pointing to the external DB domain) and a DB Secret named "backstage-psql-secret-<backstage-name>". The Operator would automatically delete such resources upon reconciliation.

      Prerequisites (if any, like setup, operators/versions):

      Tried against main and release-1.9 branches.

      Steps to Reproduce

      Example with Route disabled, but we have the same issue with local DB and Monitoring features when they are disabled.

      apiVersion: route.openshift.io/v1
      kind: Route
      metadata: 
        # This is the name of the resource the Operator would have created if the Route Feature was enabled in the CR
        name: backstage-bs-route-disabled
        labels: 
          com.example/label: "my-label"
      spec: 
        path: /
        port: 
          targetPort: http-backend
        tls: 
          insecureEdgeTerminationPolicy: Redirect
          termination: edge
        to: 
          kind: Service
          name: backstage-bs-route-disabled
          weight: 100
        wildcardPolicy: None
      
      ---
      apiVersion: rhdh.redhat.com/v1alpha5
      kind: Backstage
      metadata: 
        name: bs-route-disabled
      spec: 
        application: 
          route: 
            enabled: false
      

      Actual results:

      Right after CR reconciliation, the Route "backstage-bs-route-disabled" is deleted from the cluster:

      ❯ oc get route
      No resources found in my-ns namespace.
      
      ❯ oc get backstage            
      NAME                AGE
      bs-route-disabled   25m
      
      ❯ oc get po   
      NAME                                           READY   STATUS    RESTARTS   AGE
      backstage-bs-route-disabled-5b49b96576-tx6d5   1/1     Running   0          24m
      backstage-psql-bs-route-disabled-0             1/1     Running   0          24m
      

      Expected results:

      We should be extremely careful with such resource deletion. Maybe not delete anything (but I guess this might be confusing), or make sure the resources we are deleting were really created by the Operator.

      Reproducibility (Always/Intermittent/Only Once):

      Always

      Build Details:

      Additional info (Such as Logs, Screenshots, etc):

              Unassigned Unassigned
              rh-ee-asoro Armel Soro
              RHDH Install
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: