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: enhance memory validation and template selection #3909
kubevirt: enhance memory validation and template selection #3909
Conversation
@rhrazdil fyi wizard will be using GiB after this change |
@@ -85,6 +85,8 @@ export const prefillVmTemplateUpdater = ({ id, dispatch, getState }: UpdateOptio | |||
[VMSettingsField.WORKLOAD_PROFILE]: { value: null }, | |||
[VMSettingsField.PROVISION_SOURCE_TYPE]: { value: isProviderImport ? undefined : null }, | |||
[VMSettingsField.HOSTNAME]: { value: null }, | |||
[VMSettingsField.CPU]: { value: null }, | |||
[VMSettingsField.MEMORY]: { value: null }, |
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.
+1
if (validations.length === 0) { | ||
return null; | ||
validations.push(new TemplateValidations()); // add empty validation for positive integer if it is missing 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.
why not exit here, empty validation will end up in line 121 anyway ... ? what am I missing 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.
This just adds default validation for positive integer (not empty one), so there is no chance to insert negative values or 0
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.
👍 don't we have some other mechanism to enforce that ?
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 do, but just on the UI side in our component. IMO it will not hurt to have it also here
|
||
if (templates.size > 0 && os && workload) { | ||
// templates are sorted by relevance if only flavor is missing | ||
return getValidationsFromTemplates([templates.first()]); |
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.
@suomiy Why returning the validations from just one template? why not all of them ?
I think lines 38 and 41 should be switched. Am I wrong ?
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 refactored the code to make the intent more clear and added a comment. Can you please check the code if it makes sense to you?
const relevantValidations = this.getRelevantValidations(jsonPath); | ||
|
||
// combine validations for single template and make them strict (all integer validations must pass) | ||
const { min, max, isMinInclusive, isMaxInclusive } = relevantValidations.reduce( |
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 consider the option that a validation is optional - a.k.a has the key justWarning
.
optional validation shouldn't be combined and enforced.
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! added the support for justWarning
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>
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>
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>
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
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
f9c09da
to
a3df828
Compare
a3df828
to
ccd10ca
Compare
ccd10ca
to
aa575ff
Compare
b2473ca
to
a87aaa6
Compare
rebased |
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
/lgtm |
/retest |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest |
/retest Please review the full test history for this PR and help us cut down flakes. |
- unify and enhance template selections for validation and create requests - use GiB instead of GB for memory to allign with validations - show validation intervals
a87aaa6
to
1178a24
Compare
/lgtm |
[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
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
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>
/retest |
/hold |
/hold cancel |
/retest Please review the full test history for this PR and help us cut down flakes. |
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>
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>
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>
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>
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>
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>
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>
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>
@yaacov @irosenzw
depends on