-
Notifications
You must be signed in to change notification settings - Fork 670
Show only the allowed storage interfaces on Disk-modal #4028
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,11 +69,13 @@ export const DiskModal = withHandlePromise((props: DiskModalProps) => { | |
| handlePromise, | ||
| close, | ||
| cancel, | ||
| allowedBusses = new Set(DiskBus.getAll()), | ||
| } = props; | ||
| const asId = prefixedID.bind(null, 'disk'); | ||
| const disk = props.disk || DiskWrapper.EMPTY; | ||
| const volume = props.volume || VolumeWrapper.EMPTY; | ||
| const dataVolume = props.dataVolume || DataVolumeWrapper.EMPTY; | ||
| const validAllowedBusses = allowedBusses || new Set(DiskBus.getAll()); | ||
|
|
||
| const combinedDisk = new CombinedDisk({ | ||
| diskWrapper: disk, | ||
|
|
@@ -102,7 +104,12 @@ export const DiskModal = withHandlePromise((props: DiskModalProps) => { | |
| disk.getName() || getSequenceName('disk', usedDiskNames), | ||
| ); | ||
| const [bus, setBus] = React.useState<DiskBus>( | ||
| disk.getDiskBus() || (isEditing ? null : DiskBus.VIRTIO), | ||
| disk.getDiskBus() || | ||
| (isEditing | ||
| ? null | ||
| : validAllowedBusses.has(DiskBus.VIRTIO) | ||
| ? DiskBus.VIRTIO | ||
| : [...validAllowedBusses][0]), | ||
| ); | ||
| const [storageClassName, setStorageClassName] = React.useState<string>( | ||
| combinedDisk.getStorageClassName(), | ||
|
|
@@ -170,13 +177,15 @@ export const DiskModal = withHandlePromise((props: DiskModalProps) => { | |
| size: sizeValidation, | ||
| container: containerValidation, | ||
| pvc: pvcValidation, | ||
| diskInterface: busValidation, | ||
| url: urlValidation, | ||
| }, | ||
| isValid, | ||
| hasAllRequiredFilled, | ||
| } = validateDisk(resultDisk, resultVolume, resultDataVolume, resultPersistentVolumeClaim, { | ||
| usedDiskNames, | ||
| usedPVCNames, | ||
| allowedBusses, | ||
| }); | ||
|
|
||
| const [showUIError, setShowUIError] = useShowErrorToggler(false, isValid, isValid); | ||
|
|
@@ -370,17 +379,30 @@ export const DiskModal = withHandlePromise((props: DiskModalProps) => { | |
| /> | ||
| </FormRow> | ||
| )} | ||
| <FormRow title="Interface" fieldId={asId('interface')} isRequired> | ||
| <FormRow | ||
| title="Interface" | ||
| fieldId={asId('interface')} | ||
| isRequired | ||
| validation={busValidation} | ||
| > | ||
| <FormSelect | ||
| onChange={React.useCallback((diskBus) => setBus(DiskBus.fromString(diskBus)), [ | ||
|
||
| setBus, | ||
| ])} | ||
| isValid={!isValidationError(busValidation)} | ||
| value={asFormSelectValue(bus)} | ||
| id={asId('interface')} | ||
| isDisabled={inProgress} | ||
| > | ||
| <FormSelectPlaceholderOption isDisabled placeholder="--- Select Interface ---" /> | ||
| {DiskBus.getAll().map((b) => ( | ||
| {!validAllowedBusses.has(bus) && ( | ||
| <FormSelectOption | ||
| key={bus.getValue()} | ||
| value={bus.getValue()} | ||
| label={`${bus.toString()} --- Invalid ---`} | ||
|
||
| /> | ||
| )} | ||
| {[...validAllowedBusses].map((b) => ( | ||
| <FormSelectOption key={b.getValue()} value={b.getValue()} label={b.toString()} /> | ||
| ))} | ||
| </FormSelect> | ||
|
|
@@ -444,6 +466,7 @@ export type DiskModalProps = { | |
| vmNamespace: string; | ||
| namespace: string; | ||
| onNamespaceChanged: (namespace: string) => void; | ||
| allowedBusses?: Set<DiskBus>; | ||
| usedDiskNames: Set<string>; | ||
| usedPVCNames: Set<string>; | ||
| } & ModalComponentProps & | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,14 +6,16 @@ import { | |||||||||||||
| ValidationErrorType, | ||||||||||||||
| ValidationObject, | ||||||||||||||
| } from '@console/shared'; | ||||||||||||||
| import { validateTrim, validateURL } from '../common'; | ||||||||||||||
| import { validateTrim, validateURL, validateBus } from '../common'; | ||||||||||||||
| import { DiskWrapper } from '../../../k8s/wrapper/vm/disk-wrapper'; | ||||||||||||||
| import { VolumeWrapper } from '../../../k8s/wrapper/vm/volume-wrapper'; | ||||||||||||||
| import { DataVolumeWrapper } from '../../../k8s/wrapper/vm/data-volume-wrapper'; | ||||||||||||||
| import { POSITIVE_SIZE_ERROR } from '../strings'; | ||||||||||||||
| import { StorageUISource } from '../../../components/modals/disk-modal/storage-ui-source'; | ||||||||||||||
| import { CombinedDisk } from '../../../k8s/wrapper/vm/combined-disk'; | ||||||||||||||
| import { PersistentVolumeClaimWrapper } from '../../../k8s/wrapper/vm/persistent-volume-claim-wrapper'; | ||||||||||||||
| import { DiskBus } from '../../../constants/vm/storage/disk-bus'; | ||||||||||||||
| import { DiskType } from '../../../constants/vm/storage/disk-type'; | ||||||||||||||
|
|
||||||||||||||
| const validateDiskName = (name: string, usedDiskNames: Set<string>): ValidationObject => { | ||||||||||||||
| let validation = validateDNS1123SubdomainValue(name); | ||||||||||||||
|
|
@@ -51,16 +53,19 @@ export const validateDisk = ( | |||||||||||||
| { | ||||||||||||||
| usedDiskNames, | ||||||||||||||
| usedPVCNames, | ||||||||||||||
| allowedBusses, | ||||||||||||||
| }: { | ||||||||||||||
| usedDiskNames?: Set<string>; | ||||||||||||||
| usedPVCNames?: Set<string>; | ||||||||||||||
| allowedBusses: Set<DiskBus>; | ||||||||||||||
| }, | ||||||||||||||
| ): UIDiskValidation => { | ||||||||||||||
| const validations = { | ||||||||||||||
| name: validateDiskName(disk && disk.getName(), usedDiskNames), | ||||||||||||||
| size: null, | ||||||||||||||
| url: null, | ||||||||||||||
| container: null, | ||||||||||||||
| diskInterface: null, | ||||||||||||||
| pvc: null, | ||||||||||||||
| }; | ||||||||||||||
| let hasAllRequiredFilled = disk && disk.getName(); | ||||||||||||||
|
|
@@ -129,8 +134,13 @@ export const validateDisk = ( | |||||||||||||
| addRequired(pvcName); | ||||||||||||||
| validations.pvc = validatePVCName(pvcName, usedPVCNames); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // TODO: implement CDROM disk bus validation | ||||||||||||||
|
||||||||||||||
| // 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); | |
| } |
Outdated
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 think we can skip this if, as all disk types require bus
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 probably have to deffer this one to a followup if we cannot make CDs support into this PR on time.
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 @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:
Otherwise the errors appear every time we build the app.
@jcaianirh
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.
fixed in #3949