-
Notifications
You must be signed in to change notification settings - Fork 644
KubeVirt extension PoC #888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Can one of the admins verify this patch? |
1 similar comment
Can one of the admins verify this patch? |
cc @jelkosz @mareklibra @rawagner @ohadlevy after talking with @spadgett, the current plan for KubeVirt integration with Console UI is through minimum necessary changes to application code. This approach is also used in kubevirt-web-ui fork, which should be discontinued in the long term. The goal of this PR is to have some initial KubeVirt support in Console UI, which leaves a more formal extension mechanism up to follow-up discussion, taking both Console and KubeVirt goals into consideration. |
frontend/package.json
Outdated
@@ -85,6 +86,7 @@ | |||
"react-tagsinput": "3.19.x", | |||
"react-transition-group": "2.3.x", | |||
"react-virtualized": "9.x", | |||
"reactabular-dnd": "8.x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should track down why this is needed. I don't think anything you've added should need this dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, declaring an explicit dependency on reactabular-dnd
shouldn't be necessary from target application's perspective. Adding only the kubevirt-web-ui-components
one should be enough.
Please note that:
patternfly-react
declaresreactabular-table
as a regular dependency (it's used to implement PF-ReactTable
component)kubevirt-web-ui-components
usesreactabular-dnd
which adds drag'n'drop support to Reactabular tables (to be used with PF-ReactTable
component)
However, kubevirt-web-ui-components
package currently doesn't declare reactabular-dnd
as its dependency, which is a problem we're going to fix (along with some other dependency issues). See here for more details.
So with kubevirt-web-ui-components
, we'll try not to introduce any additional peer dependencies (on top of existing ones that come from PF-React).
Currently, your dependency tree includes reactabular-table
. After adding kubevirt-web-ui-components
, it will also include reactabular-dnd
. With webpack, code for reactabular-dnd
should be (lazy) loaded only as part of KubeVirt specific chunk (assuming the main application doesn't use reactabular-dnd
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PRs for patternfly-react
and kubevirt-web-ui-components
projects posted, these should clean up dependencies and reduce warnings when calling yarn install
.
@spadgett In order to eliminate unmet peer dependency warnings on lodash
(coming mostly from patternfly-react
's transitive deps), I'm planning to add "lodash": "npm:lodash-es"
custom alias.
const buildConfigs = this.getBuildConfigsForResource(vm); | ||
const services = this.getServicesForResource(vm); | ||
const routes = this.getRoutesForServices(services); | ||
const pods = this.getPodsForResource(vm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will VMs have these resources?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not too sure. For now, I simply wanted to comply with the OverviewItem
contract.
@jelkosz @mareklibra can you please share your thoughts here?
Also note that I've changed
@@ -1008,7 +1040,7 @@ export type OverviewItem = {
obj: K8sResourceKind;
pods?: K8sResourceKind[];
previous?: PodControllerOverviewItem;
- readiness: OverviewItemReadiness;
+ readiness?: OverviewItemReadiness;
routes: K8sResourceKind[];
services: K8sResourceKind[];
};
in order to avoid rendering "X of Y pods" label on the right side of object list row.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, there is an initiative to make the VMs to be completely native. It means they should play well with all the features of kubernetes/openshift such as deployments, replica sets etc. We are not there yet but we are getting there.
For this particular objects:
buildconfig - there has been no effort yet to make this work nor to test it. So I would go with "it does not work" for this case
services: yes, plays well with VMs
routes: yes, plays well with VMs
pods: if the VM is running, there is a pod associated with it in which the qemu process is actually living. So yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buildconfig - there has been no effort yet to make this work nor to test it. So I would go with "it does not work" for this case
@jelkosz I can set buildConfigs
to an empty array (i.e. remove the call to getBuildConfigsForResource
function).
Still, OverviewItem.buildConfigs
is currently not optional, so we'll end up with "No Build Configs found for this resource." item in the overview details pane anyway:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vojtechszocs how big change it would be to enrich the infra to support conditionally not to render the particular resources?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jelkosz It shouldn't be a big change, I'll try to do that as part of this PR.
|
||
const K8S_CREATION_TIMEOUT = 15000; | ||
|
||
const getKindForCRD = (model: K8sKind) => `${model.apiGroup}~${model.apiVersion}~${model.kind}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use referenceForModel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importing the referenceForModel
function here:
import { referenceForModel } from '../../public/module/k8s';
and calling it causes the following error:
E/launcher - Error: /home/vszocs/go/src/github.com/openshift/console/frontend/node_modules/lodash-es/lodash.js:10
export { default as add } from './add.js';
^^^^^^
SyntaxError: Unexpected token export
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Object.require.extensions.(anonymous function) [as .js] (/home/vszocs/go/src/github.com/openshift/console/frontend/node_modules/ts-node/src/index.ts:392:14)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
In public/module/k8s/k8s
we do import * as _ from 'lodash-es'
and in lodash-es/lodash.js
there's ES6 style export:
export { default as add } from './add.js'
which causes this error. This is the reason why didn't use the referenceForModel
function.
I can look into this problem and try to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, with Jest you're white-listing node_modules/lodash-es/*
for module transformation (transformIgnorePatterns
). Anything else in node_modules
is expected to be already pre-compiled and is therefore excluded from transformation by ts-jest
.
I guess we'll need to apply a similar approach when running Protractor. This issue is basically Protractor unable to parse node_modules/lodash-es/lodash.js
which is referenced by application code (public/module/k8s/k8s.ts
) that we're trying to reuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I see now that integration tests actually use lodash
instead of lodash-es
😃
I've tried to use -I 'node_modules/(?!lodash-es/.*)'
(custom ignore pattern) argument for ts-node
within the test-suite
script, but ran into some weird issues.
So for integration tests specifically, we'll need to map lodash-es
to lodash
in terms of TypeScript module resolution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've solved the issue of aliasing lodash-es
to lodash
in context of integration tests.
Doing that, I've run into another issue - access to window
global which is undefined
when being evaluated in context of integration tests (Jasmine) as part of the import process, for example:
// public/module/k8s/k8s.ts
export const k8sBasePath = `${(window as any).SERVER_FLAGS.basePath}api/kubernetes`;
I've solved that issue as well, mocking window.SERVER_FLAGS
object as necessary.
It's now possible to import
any code from public
directory within integration test code, so I'll go ahead and use the referenceForModel
function as suggested by @spadgett.
@@ -0,0 +1,2 @@ | |||
export const startStopVmModal = (props) => import('./start-stop-vm-modal' /* webpackChunkName: "start-stop-vm-modal" */) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeps acronyms capitalized
export const startStopVmModal = (props) => import('./start-stop-vm-modal' /* webpackChunkName: "start-stop-vm-modal" */) | |
export const startStopVMModal = (props) => import('./start-stop-vm-modal' /* webpackChunkName: "start-stop-vm-modal" */) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, will do.
import { createModalLauncher, ModalTitle, ModalBody, ModalSubmitFooter } from '../../../../components/factory/modal'; | ||
import { k8sPatch } from '../../../../module/k8s'; | ||
|
||
class StartStopVmModal extends PromiseComponent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class StartStopVmModal extends PromiseComponent { | |
class StartStopVMModal extends PromiseComponent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, will do.
if (props.loaded) { | ||
const data = props.flatten(props.resources); | ||
if (data) { | ||
let resource = data[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let resource = data[0]; | |
const resource = props.filter ? props.filter(data) : data[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do in case we keep our custom filter
prop function here.
const title = resource.metadata.uid; | ||
const kind = resource.kind || PodModel.kind; | ||
// TODO: if `kind` refers to CRD object, use `referenceForModel` function | ||
return <ResourceLink kind={kind} name={name} namespace={namespace} title={title} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave off title here. UID is not helpful to show on hover. (I know we do it other places).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (and a lot of other code) was taken from existing code, I'll remove the title
as suggested.
} | ||
if (resource) { | ||
const name = resource.metadata.name; | ||
const namespace = resource.metadata.namespace; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer ES6 destructuring
const { name, namespace } = resource.metadata;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, will do.
<ColHead {...props} className="col-lg-2 col-md-2 col-sm-2 hidden-xs" sortField="spec.running">State</ColHead> | ||
<ColHead {...props} className="col-lg-2 col-md-2 col-sm-2 hidden-xs" sortField="metadata.phase">Phase</ColHead> | ||
<ColHead {...props} className="col-lg-2 col-md-2 col-sm-2 hidden-xs">Virtual Machine Instance</ColHead> | ||
<ColHead {...props} className="col-lg-2 col-md-2 col-sm-2 hidden-xs">Pod</ColHead> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should only need to say col-sm-2
on each of these if md and lg are the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, will do.
<ColHead {...props} className="col-lg-2 col-md-2 col-sm-2 col-xs-6" sortField="metadata.name">Name</ColHead> | ||
<ColHead {...props} className="col-lg-2 col-md-2 col-sm-2 col-xs-6" sortField="metadata.namespace">Namespace</ColHead> | ||
<ColHead {...props} className="col-lg-2 col-md-2 col-sm-2 hidden-xs" sortField="spec.running">State</ColHead> | ||
<ColHead {...props} className="col-lg-2 col-md-2 col-sm-2 hidden-xs" sortField="metadata.phase">Phase</ColHead> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sort field looks wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which column are you referring to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one. I don't think metadata.phase
exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. As @mareklibra wrote, the Phase
column was removed in kubevirt-web-ui
so I'll remove it here as well. Updated PR should reflect latest kubevirt-web-ui
modifications.
We'll look at setting up approvals and an OWNERS file for your component. |
@vojtechszocs: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Thanks again @spadgett for your quick review, I'll update the PR accordingly. @mareklibra @rawagner please take a look at Sam's comments where I've mentioned you and provide your feedback.
Thanks, I can add a One more note - for now, I didn't add the |
/hold |
@jelkosz @mareklibra Once this PR gets merged, KubeVirt-wise, we should bring The |
067e876
to
a95bac1
Compare
Hi @spadgett and @jelkosz, PR is now rebased, all review comments should be addressed (see below for details). Please let me know if you see anything that needs further changes. Recent changes impacting this PR
Notes on PR review comments
@spadgett I'd prefer to do above TODO items (backports) via follow-up PR, is that OK with you? What's coming in very near future
As soon as this PR gets merged, we can start working on reconciling code between Once we reach parity, our primary PR target should shift from I really hope the transition period where every KubeVirt-related Console PR has a fork PR equivalent won't be too long, so we can discontinue the fork. (For the short term, our fork gives us the flexibility to quickly deliver new features.) |
Added commit with UI integration tests for basic VM actions, based on Radim's PR for Note that the yarn test-suite --suite kubevirt Also note that CRUD test suite now supports KubeVirt objects: yarn test-suite --suite crud --params.kubevirt true |
/refresh |
cb71560
to
32eb996
Compare
/retest |
#1290 will pick up the latest test fixes /hold cancel |
@vojtechszocs sorry, needs rebase now that i updated master-next |
No problem. Thank you for helping us with this PR. Edit: just realized I need to rebase 😄 will do that shortly. |
2914460
to
0be1d81
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mareklibra, rawagner, vojtechszocs If they are not already assigned, you can assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
PR rebased on latest |
@vojtechszocs: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@openshift/team-ux-review It would be great to hear what you all have to say on where the KubeVirt extension is heading. Here is a demo video that @mareklibra created. There have been some minor UX tweaks since then, but this covers all of the major features: |
@openshift/team-ux-review |
Update: initial frontend monorepo support has been added into This PR will be updated to utilize the static plugin mechanism once it lands into the codebase. |
@vojtechszocs whats the status of this PR? also a rebase is required. thanks |
PR that adds initial support for static plugins is ready for review: #1499 Once #1499 is merged, I'll address the remaining extension gaps required for initial KubeVirt UI integration:
Once above mentioned gaps are closed, I'll rework this PR to utilize the new extension system together with @mareklibra and @rawagner. This will mark a point of transition from working with our fork to working with the Console repo. @jelkosz Please review above mentioned extension gaps and let me know if there's anything missing. |
@vojtechszocs I agree with the list just want to mention that those things do not block the development - e.g. this PR can be adapted even if it was always shown. We can not merge like that but we can prepare it. |
I wanted to add screenshots of the latest and greatest around the KubeVirt functionality. FYI @beanh66 @matthewcarleton |
@lizsurette thank you for sharing those screenshots! |
@vojtechszocs: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@lizsurette These look great, thanks for updating the screenshots! The only big thing that jumps out as being inconsistent with the rest of the console is the VM details overview page. Remaining tabs seem consistent with the rest of the console, but the Overview tab typically uses a 1 or 2 column format. I know we have discussed this on the design side, but curious if there are any plans to revisit this page? We are also in the process of converting to PF4 tables so we should be using PF4 tables for the VM summary view as well to match other resources for 4.2. With that said, we do not currently have a wizard in the console, so wondering if we introduce the wizard back in, should we use the PF4 version here? FYI @alimobrem |
@lizsurette @beanh66 The styling of the tables on the Create VM - Networking and Create VM - Storage don't look to me like the rest of the console or like PF. |
@beanh66 Looking at Marek's recent import video it seems that the columns reflow to a two-column layout on smaller screens, but staying consistent with other pages for now makes sense.
I'd be in favor of PF4's (better) wizard, but the form inputs within it would still be PF3, right? Should we wait until we start converting form inputs to PF4 as well?
@ncameronbritt Agreed, I believe the plan is to convert these to PF4 tables which offer the functionality we need, but until then these tables are a bit custom. |
@andybraren It might be a while before Forms are ready in PF4. They have the basic work done but I believe there is still work to be completed. We should reach out to the PF side to align. If the time line is pretty far out we could update the wizard (since it's a separate effort anyway) and then do the forms afterwards. That would also get us the updated PF4 table for the storage/network tabs 🤞 |
I think based on the additional UXD review comments we should:
What do you think @beanh66 @alimobrem @jelkosz ? |
@lizsurette just to clarify the wizard should be ready to go just not forms (entirely). forms might be in a good enough place to move forward I think we could investigate that a bit further. https://www.patternfly.org/v4/documentation/react/components/wizard/ |
I'm assuming this should be closed in favor of the static plugin PRs which are beginning to come in. @vojtechszocs let me know if I'm wrong /close |
@spadgett: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
This is a work in progress. Changes will be made based on received feedback.
Summary
This PR introduces KubeVirt extension of Console UI.
To avoid complexity and time spent on designing a formal extension mechanism, the current form of integration is through minimum necessary changes to application code. This PR therefore contains two types of code:
public/extend/kubevirt
directorypublic/extend/kubevirt/components/vm-list.jsx
public/components/resource-pages.ts
Code in
public/extend/kubevirt
directory contains program elements necessary for the integration, like the list and details page for theVirtualMachine
resource. KubeVirt specific UI elements, like the "Create VM" wizard, are maintained in a separate repository and consumed via npm package:React components in
kubevirt-web-ui-components
package generally follow Console UI dependency requirements, including PatternFly 3 and the corresponding PatternFly-React implementation. Files contained in this package include Babel-processed JavaScript and Sass partials.Scope
VM list page
VM details page
KubeVirt version on all-projects overview page
VM list and details on project overview page
VM actions
What's missing from kubevirt-web-ui fork
Below features have been skipped on purpose in order to reduce initial PR complexity:
Environment setup
Here are the steps I've used to prepare a local development environment with KubeVirt enabled:
download the
oc
binary distributed viaopenshift-origin-client-tools
archive for OKD v3.10.0 and put it on yourPATH
kubectl
symlink tooc
make sure your cluster is up, note the cluster up configuration directory:
ocBaseDir="/path/to/openshift.local.clusterup"
put your cluster down and update
node/node-config.yaml
:put your cluster up and login as admin user:
prepare your cluster for KubeVirt installation:
install KubeVirt v0.9.1 and CDI v1.2.0
add sample VM resource
Related resources
Action items necessary for PR completion
main-chunk
) is not impacted by KubeVirt codevirtual-machine-chunk
) and try to reduce their footprint