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
Bug 1801604: Add disk validation to virtual hardware on create-vm-wizard #4231
Bug 1801604: Add disk validation to virtual hardware on create-vm-wizard #4231
Conversation
frontend/packages/kubevirt-plugin/src/utils/validations/vm/disk.ts
Outdated
Show resolved
Hide resolved
frontend/packages/kubevirt-plugin/src/utils/validations/vm/disk.ts
Outdated
Show resolved
Hide resolved
frontend/packages/kubevirt-plugin/src/utils/validations/template/types.ts
Outdated
Show resolved
Hide resolved
...rt-plugin/src/components/create-vm-wizard/tabs/virtual-hardware-tab/virtual-hardware-tab.tsx
Outdated
Show resolved
Hide resolved
const iStorages = iGetStorages(state, id); | ||
|
||
const iStorages = iGetStorages(state, id).filter((iStorage) => | ||
iGetIn(iStorage, ['disk', 'disk']), |
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.
can this rather be everything except cdroms?
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.
In theory it can be LUN or FLOPPY, although it's highly unlikely I think we should still keep this filter to be sure we get only storage objects of type DISK.
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 are showing all the other devices as well, so we should show the validations for them too IMO. Even if it is more unlikely to have them.
it should be a complement of the cdrom table so the user can see all the information
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.
Yes I agree, we should show all the validations for all the types.
frontend/packages/kubevirt-plugin/src/components/create-vm-wizard/selectors/template.ts
Outdated
Show resolved
Hide resolved
frontend/packages/kubevirt-plugin/src/components/modals/disk-modal/disk-modal.tsx
Outdated
Show resolved
Hide resolved
frontend/packages/kubevirt-plugin/src/components/vm-disks/utils.ts
Outdated
Show resolved
Hide resolved
@@ -73,6 +73,18 @@ export class TemplateValidations { | |||
}); | |||
}; | |||
|
|||
// Return a valid bus, return the defaultBus if it's valid. | |||
getAValidBus = (defaultBus?: DiskBus): DiskBus => { |
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.
can we rename it to getDefaultBus
and have zero arguments 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.
I'd like to keep this method (we can change the name if you like)
the purpose is to verify the bus we are using as default, thus is has to have an argument.
I except the comment to have an additional method, with no arguments, to get the first valid bus
7b00a8d
to
7d5c87c
Compare
/retest |
@irosenzw: This pull request references Bugzilla bug 1801604, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
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. |
const iStorages = iGetStorages(state, id); | ||
|
||
const iStorages = iGetStorages(state, id).filter((iStorage) => | ||
iGetIn(iStorage, ['disk', 'disk']), |
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 are showing all the other devices as well, so we should show the validations for them too IMO. Even if it is more unlikely to have them.
it should be a complement of the cdrom table so the user can see all the information
@@ -73,6 +73,27 @@ export class TemplateValidations { | |||
}); | |||
}; | |||
|
|||
// Return a valid bus, return the defaultBus if it's valid. | |||
getAValidBus = (defaultBus?: DiskBus): DiskBus => { |
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.
getAValidBus = (defaultBus?: DiskBus): DiskBus => { | |
getAValidBus = (defaultBus = DiskBus.VIRTIO): DiskBus => { |
could we use this approach?
return null; | ||
}; | ||
|
||
getDefaultBus = (): DiskBus => { |
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.
these two methods are confusing and I am not sure which one I should use on the first look.
I am sorry, but can we revert this to the former state and have just one method called getDefaultBus
?
@@ -138,8 +139,7 @@ export const validateDisk = ( | |||
validations.pvc = validatePVCName(pvcName, usedPVCNames); | |||
} | |||
|
|||
// TODO: implement CDROM disk bus validation | |||
if (disk.getType() === DiskType.DISK) { | |||
if (diskType === DiskType.DISK || diskType === DiskType.CDROM) { |
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 is useful for LUN as well. Can we do this?
if (diskType === DiskType.DISK || diskType === DiskType.CDROM) { | |
if (disk.getType() !== DiskType.FLOPPY) { |
@@ -73,6 +73,27 @@ export class TemplateValidations { | |||
}); | |||
}; | |||
|
|||
// Return a valid bus, return the defaultBus if it's valid. |
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.
not entirely correct. Can we please remove the comment to lower the confusion?
7d5c87c
to
ac633e0
Compare
@@ -73,6 +73,14 @@ export class TemplateValidations { | |||
}); | |||
}; | |||
|
|||
getDefaultBus = (defaultBus = DiskBus.VIRTIO): DiskBus => { | |||
const allowedBuses = this.getAllowedBuses(); | |||
if (allowedBuses.size === 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.
not sure if we should keep it here or just return the defaultBus here for the function consistency. As this branch should never execute
ac633e0
to
63873c2
Compare
/retest |
@@ -71,6 +71,7 @@ export const validateStorages = (options: UpdateOptions) => { | |||
export const setStoragesTabValidity = (options: UpdateOptions) => { | |||
const { id, dispatch, getState } = options; | |||
const state = getState(); | |||
|
|||
const iStorages = iGetStorages(state, id); |
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.
should be everything except cdroms
Signed-off-by: Ido Rosenzwig <irosenzw@redhat.com>
63873c2
to
57556b1
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 |
@irosenzw: All pull requests linked via external trackers have merged. Bugzilla bug 1801604 has been moved to the MODIFIED state. In response to this:
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: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
Add disk bus validation for the virtual hardware tab on create VM wizard
Signed-off-by: Ido Rosenzwig irosenzw@redhat.com