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

kubevirt: Edit VM flavor #2392

Merged
merged 16 commits into from
Sep 21, 2019
Merged

kubevirt: Edit VM flavor #2392

merged 16 commits into from
Sep 21, 2019

Conversation

mareklibra
Copy link
Contributor

@mareklibra mareklibra commented Aug 19, 2019

The VM Detail is enriched for the Edit VM Flavor feature, implemented as a modal dialog.

TODO:

  • edit flavor on Template Detail page

Note:
Integration tests will be added by a follow-up as they will need to be stacked on other open PRs recently.

@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. approved Indicates a PR has been approved by an approver from all required OWNERS files. component/kubevirt Related to kubevirt-plugin labels Aug 19, 2019
@mareklibra
Copy link
Contributor Author

01

02

@@ -13,6 +13,7 @@ import { VMLikeEntityKind } from '../../../types';
import { getDescription, getVMLikeModel } from '../../../selectors/selectors';
import { getUpdateDescriptionPatches } from '../../../k8s/patches/vm/vm-patches';

// TODO: should be moved under kubevirt-plugin/src/style.scss
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking for opinions: will we encapsulate styles with components or will we maintain single SASS hierarchy starting with frontend/public/style.scss (or kubevirt-plugin/src/style.scss).

The encapsulation has clearly its benefits, but we do not develop a library here. And the rest of the code follows the later approach.

@mareklibra mareklibra changed the title WIP Edit VM flavor kubevirt: Edit VM flavor Aug 19, 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 Aug 19, 2019
@mareklibra
Copy link
Contributor Author

Cc @matthewcarleton

@matthewcarleton
Copy link
Contributor

@mareklibra thanks this looks great. A few questions: can we only adjust the height of the modal if they choose custom? That white space is a bit odd if they choose any other preset flavor.
Also some text here could be useful for screen reader users. Maybe "Edit the combination of processing power and memory for the virtual machine."

@mareklibra
Copy link
Contributor Author

@matthewcarleton , I tried to resize the modal for non-custom entries but the dropdown shows badly as it hides its rows behind modal box content.
This is what I got so far:

flavorLarge

Recently, there can be up to 5 options to select from.
Any idea how to deal with it, please?

@matthewcarleton
Copy link
Contributor

@mareklibra this would be an overflow issue on the content area of .modal-body that shouldn't ship with PF3 from what I've seen. Has it been applied via the console?

@mareklibra
Copy link
Contributor Author

Thank you, @matthewcarleton , that's the issue. As we are still on PF3, what about following fix:

noOverflow

I think it behaves better than "jumping on the fly", where the modal box would increase height when the dropdown is opened and resize back when an option is selected. If the dropdown is opened, there is no other action than select an option or dismiss. Wdyt?

01_open

02_close

@matthewcarleton
Copy link
Contributor

@mareklibra yes I agree this is much better IMO.
I've also opened an issue in PatternFly b/c I see the same issue with the latest version.

@mareklibra
Copy link
Contributor Author

/retest

@mareklibra
Copy link
Contributor Author

New addition: the VM Details page shows memory and CPU wihtin the Flavor field:

vmdetails

return convertToBaseValue(memory) / MB;
};

const getFlavors = (vm: VMLikeEntityKind, templates: TemplateKind[]) => {
Copy link
Contributor

@rawagner rawagner Aug 28, 2019

Choose a reason for hiding this comment

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

why dont we move this to selectors ? I think it has a potential to be used in other places too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, moved

const VMFlavorModal = withHandlePromise((props: VMFlavornModalProps) => {
const { vmLike, templates, inProgress, errorMessage, handlePromise, close, cancel } = props;

const flattenTemplates = _.get(templates, 'data', []) as TemplateKind[];
Copy link
Contributor

Choose a reason for hiding this comment

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

loading/error state should be handled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

};

let topClass = 'modal-content ';
topClass +=
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 rather use classNames for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

<dt>
Flavor
{canUpdateTemplate && (
<button
Copy link
Contributor

Choose a reason for hiding this comment

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

can we create component out of this ? Something like EditButton ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, done

import { getVMLikePatches } from '../vm-template';
import { isCPUEqual } from '../../../utils';

const getLabelsPatch = (vmLike: VMLikeEntityKind): Patch | null => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const getLabelsPatch = (vmLike: VMLikeEntityKind): Patch | null => {
const getLabelsPatch = (vmLike: VMLikeEntityKind): Patch => {

we dont have strict null check enabled, so no need to add | null. Applies for others too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

leftover, removed

getTemplatesLabelValues(vmTemplates, TEMPLATE_WORKLOAD_LABEL);

export const getTemplates = (
templates: TemplateKind[],
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 prefer to specify default type in function declaration

Suggested change
templates: TemplateKind[],
templates: TemplateKind[] = [],

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

workload: string,
flavor: string,
) =>
(templates || []).filter((t) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
(templates || []).filter((t) => {
templates.filter((t) => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

import { VirtualMachineModel } from '../../models';
import { selectVM } from '../vm-template/selectors';

export const isVM = (vmLikeEntity: VMLikeEntityKind): boolean =>
Copy link
Contributor

Choose a reason for hiding this comment

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

this could be a type guard

Suggested change
export const isVM = (vmLikeEntity: VMLikeEntityKind): boolean =>
export const isVM = (vmLikeEntity: VMLikeEntityKind): vmLikeEntity is VMKind =>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea, done

return null;
}

if (isVM(vmLikeEntity)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

when the above is converted to type guard you can just

Suggested change
if (isVM(vmLikeEntity)) {
return isVM(vmLikeEntity) ? vmLikeEntity : selectVM(vmLikeEntity);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

);
};

type CPUType = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
type CPUType = {
type CPURaw = {

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why not ... done

@matthewcarleton
Copy link
Contributor

@mareklibra three little nitpicks:

  1. Can we capitalize all the flavor types
  2. For memory I believe we are following the GiB format rather than just G
  3. Can we have the format be : Large : 2 vCPUs, 6 GiB memory

@mareklibra
Copy link
Contributor Author

@matthewcarleton ,

Can we capitalize all the flavor types

sure, done

For memory I believe we are following the GiB format rather than just G

Our (KubeVirt) templates use values like 6G which converted to GiB leads to an ugly number.
For that reason, I would not go with the binary units unless changed within wider context (out of scope for this PR).

I have newly added conversion to best-possible human readable decimal byte-unit, like 6 GB instead of input 6000 M. Wdyt?

Can we have the format be : Large : 2 vCPUs, 6 GiB memory

done with respect to the previous point

@mareklibra
Copy link
Contributor Author

Latest screenshots:

01

06

02

03

04

@matthewcarleton
Copy link
Contributor

@mareklibra that sounds reasonable to me. Thanks!

@mareklibra mareklibra changed the base branch from master to release-4.3 August 29, 2019 07:35
@mareklibra
Copy link
Contributor Author

The PR is retargeted to release-4.3 branch.

@mareklibra
Copy link
Contributor Author

/retest

@mareklibra mareklibra changed the base branch from release-4.3 to master August 29, 2019 08:28
@mareklibra
Copy link
Contributor Author

Switching back to master and waiting for next master-next. Please excuse the confusion.

@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. component/core Related to console core functionality component/dashboard Related to dashboard component/dev-console Related to dev-console component/metal3 Related to metal3-plugin component/monitoring Related to monitoring component/olm Related to OLM and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 19, 2019
@mareklibra mareklibra changed the base branch from master to master-4.3 September 19, 2019 10:55
@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 Sep 19, 2019
@mareklibra
Copy link
Contributor Author

/retest

@rawagner
Copy link
Contributor

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mareklibra, rawagner

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 Sep 21, 2019
@rawagner
Copy link
Contributor

/test e2e-aws-console-olm

@rhamilto
Copy link
Member

rhamilto commented Nov 4, 2019

This PR appears to be the cause of https://bugzilla.redhat.com/show_bug.cgi?id=1767853

attn: @mareklibra, @rawagner

@rhamilto
Copy link
Member

rhamilto commented Nov 4, 2019

Specifically, git bisect pointed at ef3a10c

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. component/core Related to console core functionality component/dashboard Related to dashboard component/dev-console Related to dev-console component/kubevirt Related to kubevirt-plugin component/metal3 Related to metal3-plugin component/monitoring Related to monitoring component/olm Related to OLM lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants