Skip to content
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

Merged
merged 1 commit into from
Jun 6, 2019
Merged

Introduce Metal3 plugin for openshift console #1539

merged 1 commit into from
Jun 6, 2019

Conversation

jtomasek
Copy link

@jtomasek jtomasek commented May 7, 2019

This is the initial introduction of the metal3 plugin. Currently or testing purposes only.

Depends on #1586

TODO:

  • remove web-ui-components dependency
  • split into multiple PRs
  • add OWNERS file

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 7, 2019
? 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);
Copy link
Author

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

Copy link
Member

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.

Copy link
Contributor

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vojtechszocs ok, done

Copy link
Contributor

@vojtechszocs vojtechszocs May 13, 2019

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1586 should fix this.

frontend/packages/console-metal3/src/components/host.tsx Outdated Show resolved Hide resolved
/>
</div>
<div className={statusColumnClasses}>
<WithResources resourceMap={machineName ? hostResourceMap : {}}>
Copy link
Member

@spadgett spadgett May 7, 2019

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

Copy link
Contributor

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?

Copy link
Contributor

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
Copy link
Member

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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

@vojtechszocs
Copy link
Contributor

@spadgett @christianvogt @jelkosz

remove web-ui-components dependency

To clarify, the kubevirt-web-ui-components library provides React components for KubeVirt, Metal3 and Storage related extensions (despite its name, it's not KubeVirt-only). This library was created to reduce the amount of changes in kubevirt/web-ui fork of Console, while also allowing us to test & UXD-review such components in isolation.

We're currently in a "transition" period, where new Console plugins are created while the kubevirt/web-ui fork is still maintained. For now, I'd suggest to continue using kubevirt-web-ui-components as an external dependency in both fork and Console (due to plugins). Once the fork is discontinued, we can move it into the Console monorepo, alongside plugins that depend on it.

add OWNERS file

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",
Copy link
Contributor

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.

Copy link
Author

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",
Copy link
Contributor

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
  • 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.

Copy link
Author

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';
Copy link
Contributor

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.

Copy link
Author

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 : {}}>
Copy link
Contributor

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,
Copy link
Contributor

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?

Copy link
Author

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
Copy link
Contributor

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.

Copy link
Author

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',
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

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" */
Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

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).

Copy link
Author

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';
Copy link
Contributor

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?

Copy link
Author

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.

@vojtechszocs
Copy link
Contributor

FYI, the kubevirt-web-ui-components dependency also implies adding @patternfly/react-charts.

@spadgett
Copy link
Member

spadgett commented May 7, 2019

FYI, the kubevirt-web-ui-components dependency also implies adding @patternfly/react-charts.

OK, we're doing that anyway in #1448

@vojtechszocs
Copy link
Contributor

FYI, the kubevirt-web-ui-components dependency also implies adding @patternfly/react-charts.

OK, we're doing that anyway in #1448

Thanks for the update.

#1448 adds "@patternfly/react-charts": "^3.4.2", however the latest kubevirt-web-ui-components release has a peer dependency on "@patternfly/react-charts": "2.x" which should be bumped.

@rawagner @mareklibra ^^ we should fix outdated peer dependencies in kubevirt-web-ui-components.

@spadgett
Copy link
Member

spadgett commented May 8, 2019

#1448 adds "@patternfly/react-charts": "^3.4.2", however the latest kubevirt-web-ui-components release has a peer dependency on "@patternfly/react-charts": "2.x" which should be bumped.

@rawagner @mareklibra ^^ we should fix outdated peer dependencies in kubevirt-web-ui-components.

FYI, #1448 merged and now has "@patternfly/react-charts": "^3.4.5"

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 13, 2019
@spadgett spadgett changed the base branch from master-next to master May 13, 2019 22:45
@vojtechszocs
Copy link
Contributor

@jtomasek Please rebase on top of #1586 (includes commits from #1528 and #1584).

@vojtechszocs
Copy link
Contributor

@jtomasek FYI, if you need to add YAML templates for your models, check out #1613.

@spadgett spadgett added this to the v4.2 milestone May 27, 2019
@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 28, 2019
@jtomasek
Copy link
Author

Rebased on top of #1586
Simplified to avoid using WithResources which will be added in a subsequent changes
Added OWNERS file

@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 28, 2019
@jtomasek jtomasek changed the title [WIP] Introduce Metal3 plugin for openshift console Introduce Metal3 plugin for openshift console May 28, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 28, 2019
Copy link
Contributor

@mareklibra mareklibra left a 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',
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 31, 2019
@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 31, 2019
@vojtechszocs
Copy link
Contributor

I am curious to see how often we will be getting merge conflicts in yarn.lock in practise.

There's one yarn.lock per the whole Console frontend monorepo, so we'll have to deal with those merge conflicts. Instead of manually sync'ing upstream yarn.lock vs. your local yarn.lock, you can rebase and execute dependency-mgmt Yarn commands on top of the latest upstream yarn.lock.

Copy link
Contributor

@vojtechszocs vojtechszocs left a 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
Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

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],
Copy link
Contributor

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).

Copy link
Author

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

Copy link
Contributor

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
},
Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@spadgett
Copy link
Member

/go/src/github.com/openshift/console/frontend/packages/metal3-plugin/src/plugin.ts
  19:29  error  Missing semicolon       semi
  32:24  error  Missing trailing comma  comma-dangle
  42:30  error  Missing trailing comma  comma-dangle

✖ 3 problems (3 errors, 0 warnings)
  3 errors and 0 warnings potentially fixable with the `--fix` option.

// getHostMachineName,
getHostBmcAddress,
getName,
getNamespace,
Copy link
Member

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.

Copy link
Author

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?

Copy link
Contributor

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.

Copy link
Contributor

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 to console/shared or similar packages within one of the last steps of merging web-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.)

Copy link
Author

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.

Copy link
Contributor

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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up that we're in the process of updating all tables to PF4 (#1465)

@priley86 FYI

return (
<ResourceRow obj={host}>
<div className={nameColumnClasses}>
<ResourceLink kind={BaremetalHostModel.kind} name={name} namespace={namespace} title={uid} />
Copy link
Member

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}

Copy link
Author

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 : {}}>
Copy link
Member

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.

Copy link
Author

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 */
Copy link
Member

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.

Copy link
Author

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 = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary export

Copy link
Author

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)) {
Copy link
Member

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

Copy link
Author

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}>
Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@spadgett
Copy link
Member

spadgett commented Jun 3, 2019

/retest

- jtomasek
- honza
- flofuchs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra newline

Copy link
Author

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)

Copy link
Author

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';
Copy link
Member

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.

Copy link
Author

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', []);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const getHostCpus = host => _.get(host, 'status.hardware.cpus', []);
export const getHostCPUs = host => _.get(host, 'status.hardware.cpus', []);

Copy link
Author

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', []);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const getHostNics = host => _.get(host, 'status.hardware.nics', []);
export const getHostNICs = host => _.get(host, 'status.hardware.nics', []);

Copy link
Author

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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const getHostBmcAddress = host => _.get(host, 'spec.bmc.address');
export const getHostBMCAddress = host => _.get(host, 'spec.bmc.address');

Copy link
Author

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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const getHostRam = host => _.get(host, 'status.hardware.ramGiB');
export const getHostRAM = host => _.get(host, 'status.hardware.ramGiB');

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jtomasek
Copy link
Author

jtomasek commented Jun 4, 2019

/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"
Copy link
Author

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

Copy link
Author

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>) => {
Copy link
Author

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)

Copy link
Contributor

@vojtechszocs vojtechszocs left a 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,
Copy link
Contributor

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 to console/shared or similar packages within one of the last steps of merging web-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 = {
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Author

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.

Copy link
Contributor

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],
Copy link
Contributor

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.

@vojtechszocs
Copy link
Contributor

@jtomasek #1668 changes resource page extension types, please adjust accordingly:

  • ResourcePage/List => Page/Resource/List
  • ResourcePage/Detail => Page/Resource/Details

@jtomasek
Copy link
Author

jtomasek commented Jun 5, 2019

@jtomasek #1668 changes resource page extension types, please adjust accordingly:

  • ResourcePage/List => Page/Resource/List
  • ResourcePage/Detail => Page/Resource/Details

Done

@jtomasek
Copy link
Author

jtomasek commented Jun 6, 2019

/retest

const ref = referenceForModel(MachineModel);
const href = `/k8s/ns/${namespace || 'default'}/${ref}/new`;
return (
<RequireCreatePermission model={MachineModel} namespace={namespace}>
Copy link
Member

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -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:
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Author

@jtomasek jtomasek Jun 6, 2019

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.

Copy link
Author

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"
Copy link
Contributor

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,
Copy link
Contributor

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
@jtomasek
Copy link
Author

jtomasek commented Jun 6, 2019

Removed kubevirt/web-ui-components dependency.

@spadgett
Copy link
Member

spadgett commented Jun 6, 2019

/retest

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 6, 2019
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 6, 2019
@openshift-merge-robot openshift-merge-robot merged commit 30c16b7 into openshift:master Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants