Bug 1973565 - Dynamic plugin routes should be evaluated before static plugin routes
Summary: Dynamic plugin routes should be evaluated before static plugin routes
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Management Console
Version: 4.8
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.9.0
Assignee: Rastislav Wagner
QA Contact: Yadan Pei
URL:
Whiteboard:
Depends On:
Blocks: 1985193
TreeView+ depends on / blocked
 
Reported: 2021-06-18 07:49 UTC by Rastislav Wagner
Modified: 2021-10-18 17:35 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
: 1985193 (view as bug list)
Environment:
Last Closed: 2021-10-18 17:35:34 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift console pull 9395 0 None open Bug 1973565: Add create resource extension 2021-07-13 14:28:56 UTC
Red Hat Product Errata RHSA-2021:3759 0 None None None 2021-10-18 17:35:36 UTC

Description Rastislav Wagner 2021-06-18 07:49:25 UTC
Description of problem:
When a dynamic plugin adds a route via extension point but there already is one from static plugin, it is never matched because static plugin routes are evaluated first.
We need it to work the other way around

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


How reproducible:
always

Steps to Reproduce:
1. create dynamic plugin, add route which is already taken by some static plugin
2. access the route in console

Actual results:
a component from static plugin is rendered instead of the dynamic one

Expected results:
a component from dynamic plugin is rendered

Comment 4 Yadan Pei 2021-07-30 09:39:24 UTC
1. Build a dynamic plugin who has defined create resource extension via two steps
- Add following code into frontend/dynamic-demo-plugin/console-extensions.json

  {
    "type": "console.resource/create",
    "properties": {
      "model": {
        "group": "operator.tekton.dev",
        "version": "v1alpha1",
        "kind": "TektonConfig"
      },
      "component": { "$codeRef": "fooComp" }
    }
  }

- Add reference code into exposedModules of frontend/dynamic-demo-plugin/package.json


/**
 * This file declares all extensions contributed by the plugin.
 *
 * Depending on extension 'type', the 'properties' object may contain code references, encoded
 * as object literals { $codeRef: string }. The '$codeRef' value should be formatted as either
 * 'moduleName.exportName' (referring to a named export) or 'moduleName' (referring to the
 * 'default' export). Only the plugin's exposed modules may be used in code references.
 */
[
  {
    "type": "console.flag",
    "properties": {
      "handler": { "$codeRef": "barUtils.testHandler" }
    }
  },
  {
    "type": "console.flag/model",
    "properties": {
      "flag": "EXAMPLE",
      "model": {
        "group": "kubevirt.io",
        "version": "v1alpha3",
        "kind": "ExampleModel"
      }
    }
  },
  {
    "type": "console.telemetry/listener",
    "properties": {
      "listener": {
        "$codeRef": "telemetry.eventListener"
      }
    }
  },
  {
    "type": "console.page/route",
    "properties": {
      "path": "/test-consumer",
      "component": { "$codeRef": "extensionConsumer.default" }
    }
  },
  {
    "type": "console.resource/create",
    "properties": {
      "model": {
        "group": "monitoring.coreos.com",
        "version": "v1",
        "kind": "PrometheusRule"
      },
      "component": { "$codeRef": "fooComp" }
    }
  }  
]

$ jq .consolePlugin.exposedModules package.json 
{
  "barUtils": "./utils/bar",
  "telemetry": "./utils/telemetry",
  "extensionConsumer": "./components/ExtensionConsumer.tsx",
  "fooComp": "./components/Foo.tsx"
}
2. Build dynamic plugin image with command `docker build -f Dockerfile.plugins.demo -t quay.io/yapei/console-demo-plugin:createresoure .`

3. update the referenced image to quay.io/yapei/console-demo-plugin:createresoure in oc-manifest.yaml and deploy plugin manifests to the cluster
$ oc apply -f oc-manifest.yaml 
namespace/console-demo-plugin created
deployment.apps/console-demo-plugin created
service/console-demo-plugin created

4. Make sure plugin is running successfully and enable it in console config
$ oc get console.operator cluster -o json | jq .spec.plugins
[
  "console-demo-plugin"
]

5. Install Prometheus Operator into one project, try to create a new PrometheusRule resource via Operators -> Installed Operators ->  Prometheus Operator ->  Prometheus Rule -> click on 'Create PrometheusRule' button, we can see the customized component loaded, it shows "Hello Component!"

6. Goes to /api-resource/ns/default/monitoring.coreos.com~v1~PrometheusRule page, click on 'Instance' tab, click on 'Create PrometheusRule' button, it shows 'Hello Component!' which is the message defined in customized component

Verified on 4.9.0-0.nightly-2021-07-29-103526

Comment 7 errata-xmlrpc 2021-10-18 17:35:34 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 4.9.0 bug fix and security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:3759


Note You need to log in before you can comment on or make changes to this bug.