-
Notifications
You must be signed in to change notification settings - Fork 615
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
Introduce Metal3 plugin for openshift console #1539
Conversation
frontend/public/kinds.ts
Outdated
? state.k8s.getIn(['RESOURCES', 'models']).get(plural) | ||
: _.find(k8sModels, model => model.plural === plural); | ||
? state.k8s.getIn(['RESOURCES', 'models', plural]) | ||
: state.k8s.getIn(['RESOURCES', 'models']).find(model => model.plural === plural); |
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 allows the models to be defined in the plugin rather than in common k8sModels module
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 think this will break some other cases. For instance, if there are multiple deployments
in different API versions, we might get the wrong one. We need to make sure we get the one defined in the static model.
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 agree that Console should keep referring to existing model definitions (public/models/index.ts
) while also allowing plugins to contribute new model definitions.
I think the best way to solve this is via auto-generated @console/plugin-models
module which exports additional model definitions for Console application to work with.
@jelkosz ^^ please create "Allow plugins to contribute new model definitions" task & assign it to me.
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 ok, done
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 think the best way to solve this is via auto-generated
@console/plugin-models
module which exports additional model definitions for Console application to work with.
I've re-thinked this and will avoid generating another virtual module in favor of collecting models from extension objects.
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.
#1586 should fix this.
/> | ||
</div> | ||
<div className={statusColumnClasses}> | ||
<WithResources resourceMap={machineName ? hostResourceMap : {}}> |
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 not be opening WebSockets for each individual table cell
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 remember addressing this kind of issue in our Console fork, @rawagner can you please share the details?
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 dealt with this on multiple places, i.e. to show VM status which depends on multiple referenced objects. Optimized by requesting larger dataset via lower count of WebSockets and filtering on UI.
}; | ||
|
||
/* | ||
* Firehose helper |
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 you explain what this does and why it's needed?
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.
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.
Yes, it is KubeVirt utility which simplifies work with Firehose and adds some features.
For example:
-
Firehose
wont render children if model does not exist in k8s.WithResources
will - both cases has their place -
Resources
accepts resourceMap which is object instend of array as in Firehose which brings us a few enhancements:-
you need to define key (which is used as firehose resource prop - just makes it easier if you have more queries for the same model, object forces you to use unique keys)
-
you can define if resource from resourceMap is required - if yes we wait with child rendering until the resource is loaded (or we can show Loading)
-
-
there is also way to define your own error handling
-
you no longer need to check firehose's loaded prop - when injected resource is undefined it means it is still loading
@spadgett @christianvogt @jelkosz
To clarify, the We're currently in a "transition" period, where new Console plugins are created while the
This is very important, thanks for putting it on the list. |
@@ -7,6 +7,7 @@ | |||
"dependencies": { | |||
"@console/internal": "0.0.0-fixed", | |||
"@console/plugin-sdk": "0.0.0-fixed", | |||
"@console/metal3": "0.0.0-fixed", |
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.
Committing this change to git means that Metal 3 plugin will be included in development and production builds by default.
Until the Metal 3 plugin leaves the experimental phase, I'd suggest to treat this as a local change and not commit to git.
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
@@ -0,0 +1,13 @@ | |||
{ | |||
"name": "@console/metal3", |
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 suggest to follow these conventions:
-
package path
- should include the
plugin
suffix to denote the purpose of the package - should not include the
console
prefix (console-xxx
is reserved for core Console packages) - proposed value:
packages/metal3-plugin
- should include the
-
package name
@console
scope is required due to monorepo and tooling- proposed value:
@console/metal3-plugin
Later on, Metal3 team could add & own other packages as necessary, e.g. packages/metal3-components
etc.
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
getResource, | ||
getSimpleHostStatus, | ||
getUid | ||
} from 'kubevirt-web-ui-components'; |
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 need to add this dependency into the appropriate package.json
file.
For now, all core Console dependencies are declared in the monorepo root package. These dependencies reflect the requirements of application code within the public
directory, to be moved into the @console/app
package in future.
As for kubevirt-web-ui-components
, this is a plugin-specific dependency so please add it to Metal3 plugin's package.json
file.
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
/> | ||
</div> | ||
<div className={statusColumnClasses}> | ||
<WithResources resourceMap={machineName ? hostResourceMap : {}}> |
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 remember addressing this kind of issue in our Console fork, @rawagner can you please share the details?
import { Icon } from 'patternfly-react'; | ||
import { | ||
canHostAddMachine, | ||
DASHES, |
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.
Nit: isn't there some constant that we can import from @console/internal
instead?
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 seems that simple '-' string is used frequently in the codebase.
namespaced: true, | ||
kind: 'BareMetalHost', | ||
id: 'baremetalhost', | ||
crd: true |
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.
Nit: missing trailing comma, you can run yarn lint
in the monorepo root to ensure there are no linting issues.
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
{ | ||
type: 'NavItem/ResourceNS', | ||
properties: { | ||
section: 'Compute', |
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 currently yields a TypeScript error since ExtensionProperties.NavItem.section
is hard-coded as:
'Home' | 'Workloads'
I'm working on a PR to fix this.
In the meantime, please update the packages/console-plugin-sdk/src/typings/nav.ts
module to include the sections you need.
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.
cc @jelkosz ^^ is related to the "Improve nav item extension capabilities" task.
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
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.
#1584 should fix this.
model: BaremetalHostModel, | ||
loader: () => | ||
import( | ||
'./components/host' /* webpackChunkName: "baremetalhost" */ |
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 webpackChunkName
value should reflect the name of your plugin for better traceability.
I'd suggest to start with a single split point, i.e. use webpackChunkName: "metal3"
for all async module requests.
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 typically use different chunk names for different pages for better code splitting. Then the JS is only loaded when you go to that page.
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, sounds reasonable 😃
Looking at public/components/resource-pages.ts
the convention seems to be to put both resource list and detail pages under the same split point, e.g. pod
for both PodsPage
and PodsDetailsPage
(group by resource).
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 used metal3-baremetalhost
@@ -0,0 +1,167 @@ | |||
import * as React from 'react'; |
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.
There doesn't seem to be a corresponding code removal in context of the public
directory, where does this code originate from?
@rawagner Is this code used in kubevirt/web-ui
fork?
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.
Right, the code is coming from kubevirt/web-ui, I had to add it as hosts listing depends on it. I am happy to split it into a separate PR and update this one to depend on it if needed.
FYI, the |
OK, we're doing that anyway in #1448 |
Thanks for the update. #1448 adds @rawagner @mareklibra ^^ we should fix outdated peer dependencies in |
FYI, #1448 merged and now has |
Rebased on top of #1586 |
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.
lgtm
I am curious to see how often we will be getting merge conflicts in yarn.lock
in practise.
type: 'FeatureFlag/Model', | ||
properties: { | ||
model: BaremetalHostModel, | ||
flag: 'METAL3', |
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.
nitpick: as this is repeatedly used key, we can introduce a constant for 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.
Done
There's one |
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.
Looks good, just a couple of comments.
Please make sure to run yarn lint
to catch any stylish issues.
approvers: | ||
- jtomasek | ||
- honza | ||
- flofuchs |
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.
Nit: sources should have one trailing newline by default.
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
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
Looks like it's still missing the final newline
{ | ||
type: 'ModelDefinition', | ||
properties: { | ||
models: [BaremetalHostModel], |
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 can also do
-import { BaremetalHostModel } from './models';
+import * as models from './models';
-models: [BaremetalHostModel],
+models: _.values(models),
like in #1592 to avoid manually importing individual models (if you expect to have lots of them).
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 don't expect there to be many more models, so I listed it explicitly 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.
OK, I'm fine with that.
name: 'Bare Metal Hosts', | ||
resource: 'baremetalhosts', | ||
required: METAL3_FLAG | ||
}, |
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.
If you want to put your nav link after an existing one, you can use mergeAfter
.
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
|
// getHostMachineName, | ||
getHostBmcAddress, | ||
getName, | ||
getNamespace, |
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.
Same comment as in #1592, these aren't kubevirt specific. They should be added somewhere that can be used generally across console.
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 happy to move this to console/shared in a subsequent PR and gradually reduce the dependency on web-ui-components. To unblock work depending on this PR. Would that be sufficient?
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 plan to move kubevirt-web-ui-components
to console/shared
or similar packages within one of the last steps of merging web-ui
. Until this happens, we would need to maintain these utility functions (or similar code) on two places - kubevirt-web-ui
is still in play until openshift-console
meets full feature parity.
See my response in #1592 for more details.
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 happy to move this to console/shared in a subsequent PR and gradually reduce the dependency on web-ui-components.
The idea was that @console/shared
contains code used by Console itself as well as other packages. The typical contribution workflow here would be moving code from public
or @console/app
to @console/shared
. Package owners should be inherited from monorepo root OWNERS
.
For code not needed by Console itself, we could add a dedicated package, e.g. @console/rhhi-shared
(or similar). Common kubevirt/web-ui
or kubevirt-web-ui-components
code (KubeVirt, Metal3, Storage) could be moved there. Package owners should be declared explicitly, including people who work on said projects.
We plan to move
kubevirt-web-ui-components
toconsole/shared
or similar packages within one of the last steps of mergingweb-ui
.
I'd create a dedicated package for that, e.g. @console/rhhi-shared
suggested above.
(kubevirt-web-ui-components
is not KubeVirt only, it also covers Metal3 and Storage.)
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 agree that for getting rid of kubevirt/web-ui-components dependency creating of a separate console/rhhi-shared package makes sense as it would contribute to speeding up the process.
On the other hand in ideal world it seems to me that package specific code can live in the package directly (e.g. metal3 specific components) and common ones should align to general use in console and therefore end up in console/shared. But I agree that we're not there yet and it will take time to get there, so the solution you propose is perfectly reasonable.
Regarding Sam's specific comment, these selectors can be used across the whole console codebase so I think it is quite reasonable to put it directly to console/shared.
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.
package specific code can live in the package directly (e.g. metal3 specific components) and common ones should align to general use in console and therefore end up in console/shared
Yes, that's an ideal solution - console-shared
changes should pass core team reviews, so any new code we pull from kubevirt/web-ui
fork or kubevirt-web-ui-components
library would be revisited and aligned with Console core.
We should aim for the best possible solution, so +1 on just going straight through console-shared
, bit by bit.
const addressColumnClasses = 'col-lg-2 visible-lg'; | ||
|
||
const HostHeader: React.FC<React.ComponentProps<typeof ColHead>> = props => ( | ||
<ListHeader> |
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.
return ( | ||
<ResourceRow obj={host}> | ||
<div className={nameColumnClasses}> | ||
<ResourceLink kind={BaremetalHostModel.kind} name={name} namespace={namespace} title={uid} /> |
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 remove title={uid}
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
<ResourceLink kind={BaremetalHostModel.kind} name={name} namespace={namespace} title={uid} /> | ||
</div> | ||
<div className={statusColumnClasses}> | ||
{/* <WithResources resourceMap={machineName ? hostResourceMap : {}}> |
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 remove the empty table columns and add them back when we're ready. We try to keep master as close to production quality as we can.
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
// }, | ||
// ]; | ||
|
||
/* eslint-disable no-unused-vars, no-undef */ |
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 be able to remove this comment.
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
// ]; | ||
|
||
/* eslint-disable no-unused-vars, no-undef */ | ||
export type BaremetalHostsPageProps = { |
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.
Unnecessary export
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
title={machineName} | ||
/> | ||
); | ||
} else if (canHostAddMachine(host)) { |
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.
Unnecessary else
since you return inside the if
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
const ref = referenceForModel(MachineModel); | ||
const href = `/k8s/ns/${namespace || 'default'}/${ref}/new`; | ||
return ( | ||
<Link to={href}> |
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 RequireCreatePermission
or another RBAC check.
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
/retest |
- jtomasek | ||
- honza | ||
- flofuchs | ||
|
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.
nit: extra newline
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.
ugh, @vojtechszocs suggested adding it in the last comment :) #1539 (comment)
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
// const statusColumnClasses = 'col-lg-2 col-md-4 hidden-sm hidden-xs'; | ||
const machineColumnClasses = 'col-lg-3 visible-lg'; | ||
// const roleColumnClasses = 'col-lg-2 visible-lg'; | ||
const addressColumnClasses = 'col-lg-2 visible-lg'; |
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 know this temporary, but columns no longer add up to 12. You might add a column like created to fill things out until we are able to add the others.
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 added common column class for the 3 current columns and will adjust it back once remaining columns are added.
export const isHostOnline = host => _.get(host, 'spec.online', false); | ||
export const getHostNics = host => _.get(host, 'status.hardware.nics', []); | ||
export const getHostStorage = host => _.get(host, 'status.hardware.storage', []); | ||
export const getHostCpus = host => _.get(host, 'status.hardware.cpus', []); |
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.
export const getHostCpus = host => _.get(host, 'status.hardware.cpus', []); | |
export const getHostCPUs = host => _.get(host, 'status.hardware.cpus', []); |
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
export const getHostMachineName = host => _.get(host, 'spec.machineRef.name'); | ||
export const getHostBmcAddress = host => _.get(host, 'spec.bmc.address'); | ||
export const isHostOnline = host => _.get(host, 'spec.online', false); | ||
export const getHostNics = host => _.get(host, 'status.hardware.nics', []); |
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.
export const getHostNics = host => _.get(host, 'status.hardware.nics', []); | |
export const getHostNICs = host => _.get(host, 'status.hardware.nics', []); |
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
export const getOperationalStatus = host => _.get(host, 'status.operationalStatus'); | ||
export const getProvisioningState = host => _.get(host, 'status.provisioning.state'); | ||
export const getHostMachineName = host => _.get(host, 'spec.machineRef.name'); | ||
export const getHostBmcAddress = host => _.get(host, 'spec.bmc.address'); |
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.
export const getHostBmcAddress = host => _.get(host, 'spec.bmc.address'); | |
export const getHostBMCAddress = host => _.get(host, 'spec.bmc.address'); |
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
export const getHostNics = host => _.get(host, 'status.hardware.nics', []); | ||
export const getHostStorage = host => _.get(host, 'status.hardware.storage', []); | ||
export const getHostCpus = host => _.get(host, 'status.hardware.cpus', []); | ||
export const getHostRam = host => _.get(host, 'status.hardware.ramGiB'); |
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.
export const getHostRam = host => _.get(host, 'status.hardware.ramGiB'); | |
export const getHostRAM = host => _.get(host, 'status.hardware.ramGiB'); |
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
/retest |
@@ -7,7 +7,8 @@ | |||
"dependencies": { | |||
"@console/internal": "0.0.0-fixed", | |||
"@console/plugin-sdk": "0.0.0-fixed", | |||
"@console/shared": "0.0.0-fixed" | |||
"@console/shared": "0.0.0-fixed", | |||
"@console/metal3-plugin": "0.0.0-fixed" |
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 needs to be removed
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
</ListHeader> | ||
); | ||
|
||
const HostRow = ({ obj: host }: React.ComponentProps<typeof ResourceRow>) => { |
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 had to switch from using React.FC as it did not satisfy react/prop-types lint rule.
(getting error 'obj' is missing in props validation react/prop-types
)
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 PR and #1592 both add kubevirt-web-ui-components
dependency (hopefully with the same version resolution) so there will likely be conflicts in yarn.lock
changes.
Jirka, please see my inline comments.
// getHostMachineName, | ||
getHostBmcAddress, | ||
getName, | ||
getNamespace, |
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 happy to move this to console/shared in a subsequent PR and gradually reduce the dependency on web-ui-components.
The idea was that @console/shared
contains code used by Console itself as well as other packages. The typical contribution workflow here would be moving code from public
or @console/app
to @console/shared
. Package owners should be inherited from monorepo root OWNERS
.
For code not needed by Console itself, we could add a dedicated package, e.g. @console/rhhi-shared
(or similar). Common kubevirt/web-ui
or kubevirt-web-ui-components
code (KubeVirt, Metal3, Storage) could be moved there. Package owners should be declared explicitly, including people who work on said projects.
We plan to move
kubevirt-web-ui-components
toconsole/shared
or similar packages within one of the last steps of mergingweb-ui
.
I'd create a dedicated package for that, e.g. @console/rhhi-shared
suggested above.
(kubevirt-web-ui-components
is not KubeVirt only, it also covers Metal3 and Storage.)
@@ -0,0 +1,14 @@ | |||
import { K8sKind } from '@console/internal/module/k8s'; | |||
|
|||
export const BaremetalHostModel: K8sKind = { |
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.
See my comment on KubeVirt models - shouldn't we use crd: true
here?
@spadgett In kubevirt/web-ui
fork, any additional models are declared without the crd
flag, which is a mistake IMO.
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 agree, although when I add the crd flag, I am getting kindObj: no model for kind BareMetalHost
in the console and the ListPage won't show up. It seems like there is a mismatch in keys of the resources in redux store and how crd resources are retrieved.
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.
Fixed the problem and added crd: true
flag to the model.
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 seems like there is a mismatch in keys of the resources in redux store and how crd resources are retrieved.
There's currently a duality in how Console references models. Non-CRD models are typically referenced only by their kind
, CRD models are referenced via referenceForModel
function that takes their apiGroup
, apiVersion
and kind
into account.
Getting kindObj: no model for kind BareMetalHost
could mean you aren't referencing your CRD model via referenceForModel
function.
{ | ||
type: 'ModelDefinition', | ||
properties: { | ||
models: [BaremetalHostModel], |
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'm fine with that.
/retest |
const ref = referenceForModel(MachineModel); | ||
const href = `/k8s/ns/${namespace || 'default'}/${ref}/new`; | ||
return ( | ||
<RequireCreatePermission model={MachineModel} namespace={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.
This doesn't handle the all namespaces case correctly
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
frontend/yarn.lock
Outdated
@@ -8021,6 +8085,21 @@ kind-of@^6.0.0, kind-of@^6.0.2: | |||
version "6.0.2" | |||
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" | |||
|
|||
kubevirt-web-ui-components@^0.1.34-2: |
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'm concerned with all the additional dependencies this is bringing in. It looks like it includes some alternative libraries to things we've already included in console. Is this only being used for the getName
/ getNamespace
/ getUid
helpers?
I realize you use it in the kubevirt fork for other things.
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.
As an alternative, we could move the code we need from kubevirt-web-ui-components
to console-shared
(or create another, more focused shared package) and align it with current Console dependencies, code (like Firehose
vs. WithResources
) etc.
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 this only being used for the
getName
/getNamespace
/getUid
helpers?
+ a couple of things in machine-cell.tsx
I can quite easily remove this dependency for metal3 plugin in general as it does not have large amount of parts implemented in web-ui-components. For kubevirt plugin It will be more difficult.
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.
With recent change I've removed the kubevirt/web-ui-components dependency and added required selectors to @console/shared package.
"dependencies": { | ||
"@console/plugin-sdk": "0.0.0-fixed", | ||
"@console/shared": "0.0.0-fixed", | ||
"kubevirt-web-ui-components": "^0.1.34-2" |
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.
Note: you can evaluate the impact of adding kubevirt-web-ui-components
on webpack-generated JS dist code by running yarn analyze
which runs the webpack-bundle-analyzer.
// getHostMachineName, | ||
getHostBmcAddress, | ||
getName, | ||
getNamespace, |
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.
package specific code can live in the package directly (e.g. metal3 specific components) and common ones should align to general use in console and therefore end up in console/shared
Yes, that's an ideal solution - console-shared
changes should pass core team reviews, so any new code we pull from kubevirt/web-ui
fork or kubevirt-web-ui-components
library would be revisited and aligned with Console core.
We should aim for the best possible solution, so +1 on just going straight through console-shared
, bit by bit.
Including basic Baremetal hosts listing page
Removed |
/retest |
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jtomasek, spadgett 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 |
This is the initial introduction of the metal3 plugin. Currently or testing purposes only.
Depends on #1586TODO:
remove web-ui-components dependency