Bug 1953726

Summary: Fix issues related to loading dynamic plugins
Product: OpenShift Container Platform Reporter: Vojtech Szocs <vszocs>
Component: Management ConsoleAssignee: Vojtech Szocs <vszocs>
Status: CLOSED ERRATA QA Contact: Yadan Pei <yapei>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.8CC: aos-bugs, jokerman, spadgett, yapei
Target Milestone: ---   
Target Release: 4.8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1953728 (view as bug list) Environment:
Last Closed: 2021-07-27 23:04:01 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:
Bug Depends On:    
Bug Blocks: 1953728    

Description Vojtech Szocs 2021-04-26 18:21:12 UTC
Description of problem:

Some fixes are needed to ensure Console dynamic plugins are loaded properly in the browser.

Issue details:

(1) loadPluginFromURL function should wait until the plugin is loaded
(2) generated plugin-entry.js file should use /api/plugins/{PluginName}/ to load plugin-specific assets
(3) extension validation should not fail upon plugin's production build (due to webpack module concatenation)

Tech docs reference:

https://github.com/openshift/console/blob/master/frontend/packages/console-dynamic-plugin-sdk/README.md

Comment 1 Yadan Pei 2021-04-29 11:14:01 UTC
1) Clone Console repo and make sure you're on the right branch:
git checkout -b release-4.x origin/release-4.x
For 4.7 branch, apply the changes in PR 8780. (For 4.8 branch, these changes are already there.)
2) Build Bridge backend & Console web frontend:
./build.sh
3) Build Console dynamic demo plugin:
( cd frontend/dynamic-demo-plugin ; yarn ; yarn build )
4) Start local demo plugin asset server:
( cd frontend/dynamic-demo-plugin ; yarn http-server )
5) Start local Bridge server and connect it with above plugin:
source ./contrib/oc-environment.sh && ./bin/bridge -plugins console-demo-plugin=http://localhost:9001/
6) visit localhost:9000

We can see logs in browser console: 
Dynamic plugins: [console-demo-plugin]
Loading plugin manifest from http://localhost:9000/api/plugins/console-demo-plugin/plugin-manifest.json
Loading entry script for plugin console-demo-plugin.0 from http://localhost:9000/api/plugins/console-demo-plugin/plugin-entry.js
Added plugin console-demo-plugin.0
Plugin console-demo-plugin.0 is now enabled


The plugin is loaded and enabled successfully


In another way

1) follow steps in https://github.com/openshift/console/tree/master/frontend/dynamic-demo-plugin#docker-image to build a docker image 2) 2) replace the image in oc-manifest.yaml https://github.com/openshift/console/tree/master/frontend/dynamic-demo-plugin#deployment-on-cluster and create resources defined
3) enable plugin https://github.com/openshift/console/tree/master/frontend/dynamic-demo-plugin#enabling-the-plugin
at last check browser console logs, we should see the same log with above 


Verified on 4.8.0-0.nightly-2021-04-26-151924

Comment 4 errata-xmlrpc 2021-07-27 23:04:01 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.8.2 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:2438