Bug 1921227

Summary: Fix issues related to consuming new extensions in Console static plugins
Product: OpenShift Container Platform Reporter: Vojtech Szocs <vszocs>
Component: Management ConsoleAssignee: Vojtech Szocs <vszocs>
Status: CLOSED ERRATA QA Contact: Yadan Pei <yapei>
Severity: medium Docs Contact:
Priority: high    
Version: 4.7CC: aos-bugs, jokerman, spadgett, tjelinek, yapei
Target Milestone: ---   
Target Release: 4.8.0   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-07-27 22:36:45 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:

Description Vojtech Szocs 2021-01-27 18:38:41 UTC
There are two technical issues that prevent us from using new extension types via `console-extensions.json` file in Console static plugins:

(1) generated code ref functions are missing the `CodeRef` symbol, which is used to differentiate between regular functions vs. executable code refs

(2) validation of code refs based on Node.js `require()` breaks the build when the exposed module isn't strictly plain JavaScript

Comment 2 Vojtech Szocs 2021-02-02 18:58:58 UTC
This bug does not affect existing code in 4.7 so re-targeting to 4.8 release.

Comment 5 Yadan Pei 2021-02-25 09:41:14 UTC
1. clone latest 'master' branch of console code

# build a one-time development build of Console web app
cd frontend ; yarn dev-once

Build bridge command and run console bridge server
# cd /path/to/console_repo
# ./build-backend.sh
# oc login -u kubeadmin -p $(cat /path/to/install-dir/auth/kubeadmin-password)
# source ./contrib/oc-environment.sh
# ./bin/bridge

2. Open browser console and execute 
> window.pluginStore.getAllExtensions().filter((e) => e.pluginID === '@console/kubevirt-plugin') 

// this returns all extensions contributed by the existing Kubevirt plugin. At the end of the array, there is extension with type console.page/route/standalone 

> inspect the last element in array, Symbol(CodeRef): true is there

{type: "console.page/route/standalone", properties: {…}, flags: {…}, pluginID: "@console/kubevirt-plugin", pluginName: "@console/kubevirt-plugin", …}
flags: {required: Array(0), disallowed: Array(0)}
pluginID: "@console/kubevirt-plugin"
pluginName: "@console/kubevirt-plugin"
component: () => {…}
Symbol(CodeRef): true
arguments: (...)
caller: (...)
length: 0
name: ""
__proto__: ƒ ()
[[FunctionLocation]]: active-plugins.js:92
[[Scopes]]: Scopes[2]
exact: false
path: "/standalone/k8s/ns/:ns/virtualmachineinstances/:name/console"
constructor: ƒ Object()
hasOwnProperty: ƒ hasOwnProperty()
isPrototypeOf: ƒ isPrototypeOf()
propertyIsEnumerable: ƒ propertyIsEnumerable()
toLocaleString: ƒ toLocaleString()
toString: ƒ toString()
valueOf: ƒ valueOf()
__defineGetter__: ƒ __defineGetter__()
__defineSetter__: ƒ __defineSetter__()
__lookupGetter__: ƒ __lookupGetter__()
__lookupSetter__: ƒ __lookupSetter__()
get __proto__: ƒ __proto__()
set __proto__: ƒ __proto__()
type: "console.page/route/standalone"
uid: "@console/kubevirt-plugin[37]"
__proto__: Object

also run `yarn build` within frontend directory succeeded without errors

Moving to VERIFIED

Comment 8 errata-xmlrpc 2021-07-27 22:36:45 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.