-
Notifications
You must be signed in to change notification settings - Fork 605
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 1813198: Windows CDs use VirtIO instead of sata #5334
Conversation
@glekner: This pull request references Bugzilla bug 1813198, 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. 3 validation(s) were run on this bug
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. |
this should fix warning messages - kubevirt/common-templates#148 |
@@ -86,7 +94,7 @@ const VirtualHardwareTabFirehose: React.FC<VirtualHardwareTabFirehoseProps> = ({ | |||
const diskWrapper = DiskWrapper.initializeFromSimpleData({ | |||
name: availableCDName, | |||
type: DiskType.CDROM, | |||
bus: templateValidations.getDefaultBus(), | |||
bus: os?.startsWith('win') ? DiskBus.SATA : templateValidations.getDefaultBus(), |
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.
so this will be later deprecated in favor of common templates right? Can you please write a TODO comment somewhere with the PR link: kubevirt/common-templates#148. Together with bugzilla bug to track this.
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 do toLowerCase and includes instead?
@@ -185,6 +194,7 @@ type VirtualHardwareConnectedProps = VirtualHardwareTabFirehoseProps & { | |||
|
|||
const stateToProps = (state, { wizardReduxID }) => ({ | |||
namespace: iGetCommonData(state, wizardReduxID, VMWizardProps.activeNamespace), | |||
os: iGetVmSettingAttribute(state, wizardReduxID, VMSettingsField.OPERATING_SYSTEM), |
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.
please use iGetVmSettingValue
instead
@@ -581,6 +587,7 @@ export type DiskModalProps = { | |||
showInitialValidation?: boolean; | |||
isCreateTemplate?: boolean; | |||
isEditing?: boolean; | |||
isWindows?: boolean; |
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.
please, let's not add more properties to this component. We can pass the desired value inside the disk value in place where we need it.
@@ -458,7 +464,7 @@ export const DiskModal = withHandlePromise((props: DiskModalProps) => { | |||
isValid={!isValidationError(busValidation)} | |||
value={asFormSelectValue(bus)} | |||
id={asId('interface')} | |||
isDisabled={isDisabled('interface')} | |||
isDisabled={isDisabled('interface') || isWindowsCD} |
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.
IMO we should still allow the user to change it. Anyway generally, it is better to pass these values in editConfig instead from outside
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 give the illusion that the user can change the interface?
the only wanted bus for windows && cd is SATA so it should be fixed to SATA.
thats why this change shouldn't be deprecated, IMO
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.
what about scsi? IMo we should use only what comes from the template and don't have a special logic like this one
@@ -458,7 +464,7 @@ export const DiskModal = withHandlePromise((props: DiskModalProps) => { | |||
isValid={!isValidationError(busValidation)} |
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.
btw shouldn't we change TemplateValidations to react to cd-roms in this PR as well. And allow sata's for now until common-templates are fixed?
@suomiy I'm trying to make this work on my local env with the updated templates. I didn't want to pass a disk to the TemplateValidation constructor as it seems out of place, I ended up cloning methods for CD type. This works for creating a VM from scratch, but when choosing a Windows Template I created, I still see the unsupported buses. can you take a look? Thanks! |
@@ -47,6 +51,17 @@ export class TemplateValidations { | |||
return new Set(allowedBuses.length === 0 ? DiskBus.getAll() : allowedBuses); | |||
}; | |||
|
|||
getAllowedCDBuses = ( |
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't we just pass the DiskType to all these functions so we don't have to duplicate the functionality?
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.
still relevant, can we just pass the DiskType and not have the same logic twice?
import { CommonTemplatesValidation } from '../../../types/template'; | ||
import { | ||
IntervalValidationResult, | ||
MemoryIntervalValidationResult, | ||
} from './interval-validation-result'; | ||
import { DiskBusValidationResult } from './disk-bus-validation-result'; | ||
import { DiskWrapper } from 'packages/kubevirt-plugin/src/k8s/wrapper/vm/disk-wrapper'; | ||
|
||
export class ValidationJSONPath extends ObjectEnum<string> { | ||
static readonly CPU = new ValidationJSONPath('jsonpath::.spec.domain.cpu.cores'); | ||
static readonly MEMORY = new ValidationJSONPath( | ||
'jsonpath::.spec.domain.resources.requests.memory', | ||
); | ||
static readonly BUS = new ValidationJSONPath('jsonpath::.spec.domain.devices.disks[*].disk.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.
can we name this one DiskBus?
); | ||
}; | ||
|
||
validateBus = ( | ||
bus: DiskBus, | ||
disk: DiskWrapper, |
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 send just the bus and the type? So we don't propagate Wrapper API to here
This happens because the created template doesn't include the validations anymore. We should probably copy the validations when we are creating the template from common templates. |
@@ -14,7 +14,12 @@ export class ValidationJSONPath extends ObjectEnum<string> { | |||
static readonly MEMORY = new ValidationJSONPath( | |||
'jsonpath::.spec.domain.resources.requests.memory', | |||
); | |||
static readonly BUS = new ValidationJSONPath('jsonpath::.spec.domain.devices.disks[*].disk.bus'); | |||
static readonly DISKBUS = new ValidationJSONPath( |
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.
static readonly DISKBUS = new ValidationJSONPath( | |
static readonly DISK_BUS = new ValidationJSONPath( |
+ CD_BUS
if (!resultValidation.isValid && resultValidation.type === ValidationErrorType.Error) { | ||
someBusChanged = true; | ||
finalDisk = new DiskWrapper(disk, true) | ||
finalDisk = diskWrapper |
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 you please revert this change? This is done, so there is no unnecessary copying when the validation passes fine
@@ -47,6 +51,17 @@ export class TemplateValidations { | |||
return new Set(allowedBuses.length === 0 ? DiskBus.getAll() : allowedBuses); | |||
}; | |||
|
|||
getAllowedCDBuses = ( |
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.
still relevant, can we just pass the DiskType and not have the same logic twice?
const otherRecommendedBuses = otherTempValidations.getRecommendedBuses(); | ||
const otherRecommendedCDBuses = otherTempValidations.getRecommendedCDBuses(); | ||
|
||
return ( |
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.
maybe we could do a lazy compare here? First get AllowedBuses and compare if not equal return. Then get aand compare recommended. Etc.
@@ -0,0 +1,764 @@ | |||
|
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.
runaway file?
7a2aa21
to
afc35f1
Compare
|
@@ -97,11 +97,16 @@ export const internalStorageDiskBusUpdater = ({ | |||
VMWizardStorageType.WINDOWS_GUEST_TOOLS, | |||
].includes(type) | |||
) { | |||
const resultValidation = newValidations.validateBus(new DiskWrapper(disk).getDiskBus()); | |||
const resultValidation = newValidations.validateBus( | |||
new DiskWrapper(disk).getType(), |
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.
you can make a variable for these two lines
if (!resultValidation.isValid && resultValidation.type === ValidationErrorType.Error) { | ||
someBusChanged = true; | ||
finalDisk = new DiskWrapper(disk, true) | ||
.appendTypeData({ bus: newValidations.getDefaultBus().getValue() }) | ||
.appendTypeData({ | ||
bus: newValidations.getDefaultBus(new DiskWrapper(disk).getType()).getValue(), |
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.
and for getting the type here
const resultValidation = newValidations.validateBus( | ||
new DiskWrapper(disk).getType(), | ||
new DiskWrapper(disk).getDiskBus(), | ||
); | ||
if (!resultValidation.isValid && resultValidation.type === ValidationErrorType.Error) { | ||
someBusChanged = true; | ||
finalDisk = new DiskWrapper(disk, true) |
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.
the main difference is that the final disk is mutated, so it needs to be copied to its own wrapper
@@ -5,6 +5,7 @@ export const ANNOTATION_FIRST_BOOT = 'kubevirt.ui/firstBoot'; | |||
export const ANNOTATION_DESCRIPTION = 'description'; | |||
export const ANNOTATION_PXE_INTERFACE = 'kubevirt.ui/pxeInterface'; | |||
export const CUSTOM_FLAVOR = 'Custom'; | |||
export const VALIDATIONS = 'validations'; |
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 for the constant. Can we add ANNOTATION
to its name?
@@ -50,6 +51,7 @@ export const initializeCommonMetadata = ( | |||
if (template) { | |||
entity.addLabel(LABEL_USED_TEMPLATE_NAME, getName(template)); | |||
entity.addLabel(LABEL_USED_TEMPLATE_NAMESPACE, getNamespace(template)); | |||
entity.addAnotation(VALIDATIONS, getAnnotations(template)?.[VALIDATIONS]); |
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 you please make a new function called initializeCommonTemplateMetadata and put it there instead?
This function is also used for creating VMs and we are not really expecting VMs to include validations.
@@ -63,50 +70,67 @@ export class TemplateValidations { | |||
if (this === otherTempValidations) { | |||
return true; | |||
} | |||
const isBusesEqual = (buses, otherBuses) => |
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 for having a function. Can we move it one layer up to the class and make it private?
[...allowedBuses].every((bus) => otherAllowedBuses.has(bus)) && | ||
[...recommendedBuses].every((bus) => otherRecommendedBuses.has(bus)) | ||
); | ||
const allowedBuses = this.getAllowedBuses(DiskType.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 could also do [DiskType.DISK, DiskType.CDROM].every
but I do not mind either way
@@ -97,11 +97,15 @@ export const internalStorageDiskBusUpdater = ({ | |||
VMWizardStorageType.WINDOWS_GUEST_TOOLS, | |||
].includes(type) | |||
) { | |||
const resultValidation = newValidations.validateBus(new DiskWrapper(disk).getDiskBus()); | |||
const diskType = new DiskWrapper(disk).getType(); |
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.
better, but still the diskWrapper can be reused
entity: VMWrapper | VMTemplateWrapper, | ||
template?: TemplateKind, | ||
) => { | ||
initializeCommonMetadata(settings, entity, template); |
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.
please use the same pattern as VM and call the initializeCommonMetadata
separately
@@ -91,3 +92,18 @@ export const initializeCommonVMMetadata = ( | |||
); | |||
} | |||
}; | |||
|
|||
export const initializeCommonTemplateMetadata = ( | |||
settings: { |
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 that case you can remove the settings here and it will simplify the API
@@ -91,3 +92,18 @@ export const initializeCommonVMMetadata = ( | |||
); | |||
} | |||
}; | |||
|
|||
export const initializeCommonTemplateMetadata = ( |
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 function should be called - to initialize common template metadata
@@ -67,3 +67,6 @@ export const combineIntegerValidationResults = ( | |||
} | |||
return asValidationObject(message, finalType); | |||
}; | |||
|
|||
export const isSetEqual = (set: Set<any>, otherSet: Set<any>) => |
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 can be rather moved to src/utils/common.ts
f5ca0c3
to
56eeec3
Compare
@@ -91,3 +94,11 @@ export const initializeCommonVMMetadata = ( | |||
); | |||
} | |||
}; | |||
|
|||
export const initializeCommonTemplateMetadata = ( | |||
entity: VMWrapper | VMTemplateWrapper, |
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.
entity: VMWrapper | VMTemplateWrapper, | |
entity: VMTemplateWrapper, |
template?: TemplateKind, | ||
) => { | ||
entity.addLabel(TEMPLATE_TYPE_LABEL, TEMPLATE_TYPE_VM); | ||
entity.addAnotation(ANNOTATION_VALIDATIONS, getAnnotations(template)?.[ANNOTATION_VALIDATIONS]); |
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 check for undefined/null here so we don't add epmty annotations label
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: glekner, 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 |
@glekner: All pull requests linked via external trackers have merged: openshift/console#5334. Bugzilla bug 1813198 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. |
/cherry-pick release-4.4 |
@yaacov: #5334 failed to apply on top of branch "release-4.4":
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. |
@glekner hi, ^^ looks like this should be backported by hand :-( |
This should later be fixed when
common-templates
have validations for CDs