-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
kubernetes: Virtual machines side tab added #7830
Conversation
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.
Nice start, have a couple questions and comments.
pkg/kubernetes/scripts/main.js
Outdated
@@ -44,6 +44,7 @@ | |||
require('./nodes'); | |||
require('./topology'); | |||
require('./volumes'); | |||
require('./virtual-machines.es6'); |
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.
Can we stick to standard js in the module? Or is there a reason we need to use es6?
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.
done
'$routeProvider', | ||
function($routeProvider) { | ||
$routeProvider | ||
// .when('/vms/:vm_namespace/:vm_name', { |
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's not commit commented out code.
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.
done
'kubeLoader', | ||
'kubeSelect', | ||
function($scope, loader, select) { | ||
console.log('controller arguments', arguments); |
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.
debug log statements here.
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.
done
@@ -38,6 +38,7 @@ | |||
|
|||
var KUBE = "/api/v1"; | |||
var OPENSHIFT = "/oapi/v1"; | |||
var KUBEVIRT = "/apis/kubevirt.io/v1alpha1"; |
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.
Is there a way we can discover this instead having to hard code 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.
I guess prefix/apis/kubevirt.io
is ok. v1alpha1
could be in theory extracted from response to GET /apis/kubevirt.io
as value of preferredVersion
field.
But that's probably not what we want. All the kubevirt related code relies on v1alpha1
and is not guarantied to work with other versions (since there is currently no other version). I case of api update (and related api prefix update) we would need most probably update the code as well.
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 seen a lot of use cases where users use a new version of this (usually the container) with an older kubernetes version. So if we hard code this then in the future when we bump to v1
this code will no longer be usable with older versions.
But it's also possible that the API will change so much that we'll never be able to support any other version in the same js code base. So I guess it makes sense to leave it like this for now and we can make the decision about continuing to support v1alpha1
once we know what the differences are.
1e4595c
to
33e1d6b
Compare
Widening of vertical navigation bar got broken, so this is still WIP. |
33e1d6b
to
92f67b5
Compare
92f67b5
to
c9a11eb
Compare
ready for next review |
</thead> | ||
|
||
<tbody ng-repeat="vm in vms track by vm.metadata.uid"> | ||
<tr class="listing-ct-item"> |
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.
Can we provide an initial expanded version. Even if it's just the same info for now, just for completeness?
This is looking good. Before we can merge we need to figure out testing. So we can test that the nav item comes and goes correctly. I can help with that. How are you going about installing now? I'm guessing this is not packaged for any distro yet. Are there containers we can use? Or how would you recommend we set kubevirt up on our test machines? |
AFAIK, there's recently no packaging for any distro. There's Vagrant image wrapping all together but this might be complicated to use in the test environment. Deployment of development environment on openshift is in progress, we might be able to reuse that once/if finished [1]. Or we can explore how to install kubevirt [2] on top of existing cocpit's k8s test image. Local configuration [3] will be probably needed to set master node name, kubevirt expects
To build and deploy docker images:
[1] https://github.com/petrkotas/openshift-env/ |
So I looked into adding kubevirt to one of our test images. While i did manage to get it working its' not super reproducable right now. My concern is that it will break every time we rebuild the image. I talked to @fabiand on IRC and he was going to see if he can refactor the scripts a little so that they can be use with both minikube and standard kube so we don't have to invent and support our manifests. |
The user shall be able to see additional details of the virtual machine and modify it. It would be great to reuse existing As the datasource, The view is cluster-level and not host- (node-) level (compared to pkg/machines or pkg/ovirt). For discussion/decision is the way how to achieve that. In all options bellow, new To use #7830 list of virtual machines list as it is (so written in angular):
Or still keep the list of virtual machines under
In all cases, code shared from My prefference is on the last option with integrating react tree into existing angular code. Any other idea how to provide pkg/machines functionality for kubevirt virtual machines? |
We don't need to override the machines package. It's easy to have this link refer to a different page. The angular / react thing is a little more complicated. All the code that interacts with the kubernetes API is in angular. So I'm not sure we can get completely away from that. I also imagine there might also be quite a few differences in how you would configure machines using kubevirt. You'll probably leave networking to kubernetes, use PVs for storage etc... So i think we will only want to reuse certain parts of the machines code and not the entire package the way ovirt does. |
Just head's up that this is not forgotten. |
Yes, it's not exactly straightforward to use react components in angular environment. Let's give it a try. I'll create a POC utilizing angular kubernetes bindings.
Exactly. The Kubevirt extension is supposed to be similar to machines plugin from the user perspective so we'd like to reuse mainly UI components to avoid code duplication and easily achieve similar look and feel. And at the same time the Kubevirt api is pretty different from libvirt/oVirt apis so this area will require new code. |
c9a11eb
to
7bc923e
Compare
This fails on semaphore: |
@martinpitt no point in triggering yet, tests still need to be written. |
7bc923e
to
43e1159
Compare
as for kubevirt deployment, with kubevirt/kubevirt#602 we're getting even more close to a reasonable state. |
43e1159
to
787bd44
Compare
I've just updated the kubevirt demo, which now uses the improved manifests. Cockpit can use the demo approach to deploy kubevirt in minikube: See https://github.com/kubevirt/demo/blob/64357903f6a83fb687d05c6f47b687e98b196f3d/README.md for details. |
@fabiand awesome. To uninstall is deleting everything in kubevirt-infra good enough? Or are there other steps we would need to take? |
@petervo In an ideal world, yes. I'd recommed to run a kubectl delete -f kubevirt.yaml in order to cleanup. but this is not really reliable, there are a few bugs about deleting deployments etc. However, try this, and if it doesn't work the way we expect then we can fix further bugs. |
f188fdb
to
042ea4c
Compare
@jniederm anything missing? |
042ea4c
to
d3b5f8b
Compare
@michalskrivanek We need to make tests passing and then reviews. |
d3b5f8b
to
22744a5
Compare
There's new Kubevirt 0.2.0 in the meantime: #8414 |
LGTM, @petervo , @martinpitt , can you please review? |
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.
Aside from a few nitpicks and questions this looks good to me; it's rather clear code - although a little over-abstracted for my taste, it could be much denser; but I know you guys like redux and you will maintain it, so no complaints.
ATM this is informational, and I suppose this will grow some more features in the future for actually interacting with the VMs? Similar to the containers page, where you can delete them, get a console, etc.?
Can you please also post some up to date screenshots with a "General" details pane opened, for the release notes? If you rather want to have a quick video demo, that's much appreciated too, of course!
Thanks!
/* | ||
* This file is part of Cockpit. | ||
* | ||
* Copyright (C) 2015 Red Hat, Inc. |
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 should be bumped :-)
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.
done
return ( | ||
<Listing title={_("Virtual Machines")} | ||
emptyCaption={_("No virtual machines")} | ||
columnTitles={[_("Name"), namespaceLabel, _("Node"), _("Phase")]}> |
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.
"phase" might be the kubevirt-internal term for this, but the docker and libvirt pages (Containers and Machines) call them "State". Can we use that same label for consistency?
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.
done
*/ | ||
function init($scope, kubeLoader, kubeSelect) { | ||
initReduxStore() | ||
sagaMiddleware.run(rootSaga) |
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.
Are you actually using sagas anywhere? At least to my ignorant eye it just looks like you have the skeleton here, but it doesn't do anything (yet?). I may sound like an old man, but I find it a bit hard to follow all that boilerplate in reducers, action-types, and action-creators (particularly as this page does not actually have any user-visible actions, it's just displaying state). It's mostly "your" code, so I don't object, but I'm at least trying to understand what's happening :-)
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.
Your sharp eye correctly recognized that there are no sagas yet. If it's a problem it can be removed from this pull. Commit 'kubernetes: Virtual Machines view - infra' is meant to set up complete react-redux-saga environment. Sagas will be used in future patches performing "write" operations.
I agree it's not exactly concise. However AFAIK it's the best of structuring state management for React.
Action is unfortunately overloaded expression here. In context of redux it's used to describe an event changing the state.
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.
It's okay if you are going to use them soon, I just wanted to confirm that it's not just some leftover boilerplate. Thanks! (Going to review the rest of the updated PR on Monday, thanks for the cleanups!)
result.push(propertyName) | ||
} | ||
return result | ||
} |
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.
How is that different from Object.keys(object)
?
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.
Removed. It was similar to Object.keys(object)
but also went down the prototype chain. Verified by experiment that kubeSelect()
returns results only in own properties. If it's not always true please let me know.
export function getValues(object) { | ||
return getKeys(object).map(key => object[key]) | ||
} | ||
|
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.
Likewise, what's different from Object.values(object)
?
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.
Likewise, removed.
test/verify/check-openshift
Outdated
b.wait_present("#vms-menu-link") | ||
b.click("#vms-menu-link") | ||
b.wait_present("tr[data-row-id='vm-testvm']") | ||
self.assertTrue(b.is_present("tr[data-row-id='vm-testvm']")) |
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.
Not important, but this is redundant: The wait_present before already asserts the presence.
Could this also check some actual content of the VM, like that it has a reasonable name and node? Clicking on it should reveal the details pane, which should have some contents asserted.
Are kubevirt nodes the same as "normal" container nodes in openshift? There is no particular implementation of a "nodes" view here, so I assume the nodes link will just lead to the existing pages?
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.
Kubevirt is just an extension to k8s, nodes
are same with or without kubevirt. The idea is to implement click-through in a follow-up patch.
Oh, and I suppose the commits should be squashed together when we merge this, as they are rather incremental. This makes incremental reviews easier, so it's a good thing; just want to confirm that you are okay with this. |
Infrastructure change supporting adding Virtual Machines (KubeVirt) view to kubernetes package. Changed dependencies: * react-redux, redux-saga - React state management dependencies * babel-plugin-transform-regenerator - support for JS generator functions * eslint-plugin-flowtype, flow-bin, flow-webpack-plugin - JS type annotation * htmlparser - alphabetical order fixed
It lists VMs of Kubevirt. The tab is only shown if connected cluster has Kubevirt installed. Navigation vertical bar extended to be able to show "Virtual Machines" label. It uses standard React + Redux + Saga approach. Nested in angular environment. Redux store is garbage collected when Virtual Machines view is left.
React event handlers were receiving click events on local links (<a href="#...">) with `defaultPrevented` flag set. Navigation was performed despite of that flag. Fixed by disabling Angular links rewriting for Virtual Machines angular module.
22744a5
to
4eae2fa
Compare
... since it is breaking GitHub CI, error message: Unhandled exception: Unix.Unix_error(Unix.EACCES, "ftruncate", "")
4eae2fa
to
2526ff4
Compare
I wasn't meant that way originally. I find detailed git history useful. But yes, I confirm I'm ok with that. |
Yes, this patch just lists VMs. We'd like Cockpit to be the main low level GUI for Kubevirt so there is plan to provide full set of CRUD operations, support for Offline VMs, console and other. There's already pull #8434 adding new VM dialog (WIP). |
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.
Thanks for the fixups!
node_name = b.text("tr[data-row-id='vm-testvm'] + tr.listing-ct-panel .vm-node").strip() | ||
if node_name != node_not_assigned: | ||
b.click("tr[data-row-id='vm-testvm'] + tr.listing-ct-panel .vm-node a") | ||
b.wait_js_cond('window.location.hash === "#/nodes/%s"' % (node_name,)) |
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.
The setup cost of these tests is very high, so I'd like to merge these into one test. But this can happen in a follow-up.
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.
Done in #8465.
It lists VMs of Kubevirt. The tab is only shown if connected cluster
has Kubevirt installed.
Navigation vertical bar extended to be able to show "Virtual Machines"
label.