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.
  • Add the validations to the store.
  • Implement enum validation methods.

Depends on: #3909

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

- unify and enhance template selections for validation and create requests
- use GiB instead of GB for memory to allign with validations
- show validation intervals
@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 15, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: irosenzw
To complete the pull request process, please assign jelkosz
You can assign the PR to them by writing /assign @jelkosz in a comment when ready.

The full list of commands accepted by this bot can be found 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

@openshift-ci-robot openshift-ci-robot added the component/kubevirt Related to kubevirt-plugin label Jan 15, 2020
@irosenzw irosenzw force-pushed the add-windows-disk-validation branch 2 times, most recently from c389565 to 1015dc9 Compare January 15, 2020 14:49
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't it be fromJS(payload.value), ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because the payload isn't an immutable object but a TemplateValidations[] object.

Copy link
Member

Choose a reason for hiding this comment

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

not needing const state = getState(); in this function is strange ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1

Copy link
Member

Choose a reason for hiding this comment

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

I do not think it is needed to store validations in the redux.

There are problems with this approach:

  • redux should not store duplicate data
  • this function is missing all the dependencies for this to work correctly
  • this might be another place for performance issues in the future

Copy link
Contributor Author

@irosenzw irosenzw Jan 19, 2020

Choose a reason for hiding this comment

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

@suomiy , I don't understand this comment at all. Can you elaborate ?
why the validations consider duplicate data ?
what are the dependencies I missed?
what performance issues you are referring to? can you give an example ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@suomiy, how do you suggest to get the validations to the disk-modal without using Redux store ?

Copy link
Member

Choose a reason for hiding this comment

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

@suomiy , I don't understand this comment at all. Can you elaborate ?
why the validations consider duplicate data ?

because they are already stored in the template

what are the dependencies I missed?
what performance issues you are referring to? can you give an example ?

usertemplate and templates and that is why it could be a performance issue (we could still use it if we decide to, but it is better to be careful)

Copy link
Member

Choose a reason for hiding this comment

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

@suomiy, how do you suggest to get the validations to the disk-modal without using Redux store ?

from the templates

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.
 - Add the validations to the store.
 - Implement enum validation methods.

Depends on: openshift#3909

Signed-off-by: Ido Rosenzwig irosenzw@redhat.com
@irosenzw irosenzw force-pushed the add-windows-disk-validation branch from 1015dc9 to 1b7ce12 Compare January 16, 2020 15:46
@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 16, 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 16, 2020
Copy link
Member

Choose a reason for hiding this comment

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

I do not think it is needed to store validations in the redux.

There are problems with this approach:

  • redux should not store duplicate data
  • this function is missing all the dependencies for this to work correctly
  • this might be another place for performance issues in the future

);
case InternalActionType.SetTemplateValidations:
return state.setIn(
[dialogID, 'commonData', 'dataIDReferences', 'templateValidations'],
Copy link
Member

Choose a reason for hiding this comment

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

just a note: dataIDReferences is for storing references of already present data in the redux store only. Not the original data.

if (templates.size > 0 && os && workload) {
// templates are sorted by relevance if only flavor is missing
return getValidationsFromTemplates([templates.first()]);
return getValidationsFromTemplates(templates.toArray());
Copy link
Member

Choose a reason for hiding this comment

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

I don't see a reason why this is necessary. Please update to the newest version

},
];

const getAllowedBusses = (): Set<string> => {
Copy link
Member

Choose a reason for hiding this comment

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

should not be needed, there should be just one templateValidation at this point.

const vmLikeFinal = getLoadedData(vmLikeEntityLoading, vmLikeEntity); // default old snapshot before loading a new one
const vm = asVM(vmLikeFinal);

const allowedBusses = getOperatingSystem(vmLikeEntity).startsWith('win')
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 we should rather allow all buses in the VM detail disk modal, than to hardcode some

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for the modal in the Disk details page.
If a user uses a windows OS it shouldn't have the option to pick scsi bus - just virtio or sata

{DiskBus.getAll().map((b) => (
<FormSelectOption key={b.getValue()} value={b.getValue()} label={b.toString()} />
))}
{!allowedBusses || allowedBusses.size === 0
Copy link
Member

Choose a reason for hiding this comment

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

this does not make semantically sense. either we say

  • allowedBusses will default to all when null
  • or they will reflect the real meaning at all times - actual allowed busses

))
: DiskBus.getAll().map(
(b) =>
Array.from(allowedBusses).includes(b.getValue()) && (
Copy link
Member

Choose a reason for hiding this comment

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

set has especially method has for this task, so there is no need for array creation

Copy link
Member

Choose a reason for hiding this comment

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

also there should not be code duplication for FormSelectOption creation

// Empty array means all values are allowed

// Get all the validations which has the 'values' key and aren't optional
const relevantValidations = this.getRelevantValidations(jsonPath).filter(
Copy link
Member

Choose a reason for hiding this comment

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

latest change moves the filter to getRelevantValidations

return { min, max, isMinInclusive, isMaxInclusive, isValid };
};

getAllowedBusses = (): Set<string> => this.getAllowedEnumValues(ValidationJSONPath.BUS);
Copy link
Member

Choose a reason for hiding this comment

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

does not take into account the name of the rule - e.g. windows-virtio-bus, windows-disk-bus which has a meaning with consequences

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand what you wanted to say in this comment

Copy link
Member

Choose a reason for hiding this comment

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

ok, let's not do that and just enforce the rules

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 13, 2020
@openshift-ci-robot
Copy link
Contributor

@irosenzw: PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@irosenzw irosenzw closed this Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/kubevirt Related to kubevirt-plugin 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants