Skip to content

Conversation

@irosenzw
Copy link
Contributor

Fixes: CNV-2914

Enforce the validations from common and user templates
so the user can choose only from the allowed values in the Disk-modal
at the storage tab.

Depends on: #3909

Signed-off-by: Ido Rosenzwig irosenzw@redhat.com

@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 Jan 21, 2020
@openshift-ci-robot openshift-ci-robot added the component/kubevirt Related to kubevirt-plugin label Jan 21, 2020
@irosenzw irosenzw force-pushed the kubevirt.DiskBusValidation branch from bbbd1fc to 87311ec Compare January 22, 2020 08:00
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 22, 2020
@irosenzw irosenzw force-pushed the kubevirt.DiskBusValidation branch from 87311ec to e25f8a0 Compare January 22, 2020 08:08
@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 22, 2020
@irosenzw irosenzw changed the title [WIP] Show only the allowed storage interfaces on Disk-modal Show only the allowed storage interfaces on Disk-modal Jan 22, 2020
@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 Jan 22, 2020
@irosenzw
Copy link
Contributor Author

/retest

Copy link
Member

@atiratree atiratree left a comment

Choose a reason for hiding this comment

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

  • doesn't work with justWarning validations
  • doesn't work well with CDs - no errors + no possibility to edit
  • there should be a different default picked for new disks if VirtIO is not present in allowedBuses
  • no validation for already created VMs (just a reminder for a followup)

Copy link
Member

Choose a reason for hiding this comment

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

can we have something akin to iGetRelevantTemplate - getTemplateValidations and getTemplateValidation ?

Copy link
Member

Choose a reason for hiding this comment

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

and call console.warn when there are multiple of them - as that should not happen?

Copy link
Member

Choose a reason for hiding this comment

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

we could call this after the first if

Copy link
Member

Choose a reason for hiding this comment

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

there is no need for the spread here

Copy link
Member

Choose a reason for hiding this comment

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

we could use getTemplateValidation here as well

Copy link
Member

Choose a reason for hiding this comment

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

still probably better check this is not null

Copy link
Member

Choose a reason for hiding this comment

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

what happens when allowedBusses become null here?

Copy link
Member

Choose a reason for hiding this comment

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

also you could use joinGrammaticallyListOfItems

Copy link
Member

Choose a reason for hiding this comment

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

why dont we use this? and also pass validation to FormRow?

Copy link
Member

Choose a reason for hiding this comment

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

I suppose the Invalid is good as well, but can we also add isDisabled ?

Copy link
Member

Choose a reason for hiding this comment

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

probably the validation + isDisabled should be enough

@irosenzw irosenzw force-pushed the kubevirt.DiskBusValidation branch 2 times, most recently from f5d75d8 to 02b6ecc Compare January 22, 2020 17:12
Copy link
Member

Choose a reason for hiding this comment

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

the default is all right? Let's rather do this

Suggested change
const allowedBusses = templateValidation ? templateValidation.getAllowedBusses() : null;
const allowedBusses = (templateValidation || new TemplateValidations()).getAllowedBusses();

Copy link
Member

Choose a reason for hiding this comment

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

let's move these to ../template.ts ? as these do not return immutable objects

Copy link
Member

Choose a reason for hiding this comment

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

we can do the same trick here as well

(templateValidations || new TemplateValidations()).getAllowedBusses()

Copy link
Member

Choose a reason for hiding this comment

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

probably not here though as this is just the modal

Copy link
Member

Choose a reason for hiding this comment

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

lets remove this line and let DiskModal take care of it for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

First, this is just for now, there will be a followup. Second, this is DiskModal prop, it has to get the default value.

Copy link
Member

Choose a reason for hiding this comment

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

fair enough, let's do it in a followup. Anyway the DiskModal could contain the default value by itself

Copy link
Member

Choose a reason for hiding this comment

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

easier to read

Suggested change
: Array.from(allowedBusses)[0]),
: [...allowedBusses][0]),

Copy link
Member

Choose a reason for hiding this comment

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

can we do the same thing here and just map the thing without any conditions?

Suggested change
{DiskBus.getAll().map((b) =>
{(allowedBusses || new Set(DiskBus.getAll())).map((b) =>

we probably should check if allowedBusses are null in the begiining and assing new Set(DiskBus.getAll()) so we can use it everywhere without a fear

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/openshift/console/pull/4028/files#r369505305, so you don't have to do it here before the return

Copy link
Member

Choose a reason for hiding this comment

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

and you can do

Suggested change
if (allowedBusses.size === 0) {
return new Set(allowedBusses.size === 0 ? DiskBus.getAll() : allowedBusses)

Copy link
Member

Choose a reason for hiding this comment

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

the disk condition should still be here or we could get stuck in cdroms

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what are you suggesting?:

  1. remove the line
  2. keep the line and add a comment above for a followup
  3. comment the line and add a comment about a followup

Copy link
Member

Choose a reason for hiding this comment

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

please call toString here

Copy link
Member

Choose a reason for hiding this comment

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

please pass validation to FormRow as it is not visible

Copy link
Member

Choose a reason for hiding this comment

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

IMO in that case we can remove Invalid here as it would be shown twice

Copy link
Member

Choose a reason for hiding this comment

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

sorry it does not work with isDisabled - lets remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you sure? for me it does:
Screenshot from 2020-01-22 21-42-53

Copy link
Member

Choose a reason for hiding this comment

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

for me it does not

table:

aa

dialog after opening:

aaa

@irosenzw irosenzw force-pushed the kubevirt.DiskBusValidation branch from 02b6ecc to 7c6ab42 Compare January 22, 2020 19:45
Copy link
Member

@atiratree atiratree Jan 23, 2020

Choose a reason for hiding this comment

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

I meant, lets revert it to the same state it was before. Thumbs up for the TODO.

Suggested change
// TODO: implement CDROM disk bus validation
// TODO: implement CDROM disk bus validation
if (disk.getType() === DiskType.DISK) {
addRequired(allowedBusses.has(disk.getDiskBus()));
validations.diskInterface = validateBus(disk.getDiskBus(), allowedBusses);
}

@irosenzw irosenzw force-pushed the kubevirt.DiskBusValidation branch from 7c6ab42 to 11960d5 Compare January 23, 2020 12:25
Copy link
Member

Choose a reason for hiding this comment

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

really no need for this check - it will always return true

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I suppose the user should know it is not selectable

We could try to make the disabled work in the future

Copy link
Member

Choose a reason for hiding this comment

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

ow sorry it should just read:

Suggested change
addRequired(allowedBusses.has(disk.getDiskBus()));
addRequired(disk.getDiskBus());

this just checks the value is not null

Copy link
Member

Choose a reason for hiding this comment

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

please move this above the method as this talks about the whole thing

@irosenzw irosenzw force-pushed the kubevirt.DiskBusValidation branch from 11960d5 to 874fcbe Compare January 23, 2020 12:38
@atiratree
Copy link
Member

works great!

/lgtm

now let's proceed with the folowups :)

  • should work with justWarning validations as well
  • should work with and validate CDs + possibility to edit them
  • should validater already created VMs
  • should automatically fix our provision source Disks which are created automatically by the wizard

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 23, 2020
Fixes: CNV-2914

Enforce the validations from common and user templates
so the user can choose only from the allowed values in the Disk-modal
at the storage tab.

Depends on: openshift#3909

Signed-off-by: Ido Rosenzwig <irosenzw@redhat.com>
@irosenzw irosenzw force-pushed the kubevirt.DiskBusValidation branch from 874fcbe to aaa0c77 Compare January 23, 2020 13:07
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jan 23, 2020
@atiratree
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 23, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: irosenzw, suomiy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@irosenzw
Copy link
Contributor Author

/test analyze

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 492960d into openshift:master Jan 23, 2020
const templateValidations = getTemplateValidations(state, id);
if (templateValidations && templateValidations.length > 0) {
templateValidations.length > 1 &&
console.warn('WARNING: getTemplateValidation: multiple template validations detected!');
Copy link
Contributor

Choose a reason for hiding this comment

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

@suomiy @irosenzw
If this is an error that should be handled, ensure there is something in place, otherwise, if its something that is sufficiently handled with the console statement, then please add:

// eslint-disable-next-line no-console
console.warn('....');

Otherwise the errors appear every time we build the app.
@jcaianirh

Copy link
Member

Choose a reason for hiding this comment

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

fixed in #3949

@spadgett spadgett added this to the v4.4 milestone Jan 27, 2020
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/kubevirt Related to kubevirt-plugin 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.

7 participants