Skip to content
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

Merged
merged 1 commit into from
May 19, 2020

Conversation

glekner
Copy link
Contributor

@glekner glekner commented May 7, 2020

This should later be fixed when common-templates have validations for CDs

@openshift-ci-robot openshift-ci-robot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels May 7, 2020
@openshift-ci-robot
Copy link
Contributor

@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
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1813198: Windows CDs use VirtIO instead of sata

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
Copy link
Contributor Author

glekner commented May 12, 2020

@suomiy @yaacov can you review?

@glekner
Copy link
Contributor Author

glekner commented May 12, 2020

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(),
Copy link
Member

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.

Copy link
Member

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),
Copy link
Member

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;
Copy link
Member

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}
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

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)}
Copy link
Member

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?

@glekner
Copy link
Contributor Author

glekner commented May 17, 2020

@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 = (
Copy link
Member

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?

Copy link
Member

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');
Copy link
Member

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,
Copy link
Member

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

@atiratree
Copy link
Member

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?

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(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Member

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 = (
Copy link
Member

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 (
Copy link
Member

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 @@

Copy link
Member

Choose a reason for hiding this comment

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

runaway file?

@glekner glekner force-pushed the fix-1813198 branch 2 times, most recently from 7a2aa21 to afc35f1 Compare May 18, 2020 19:30
@glekner
Copy link
Contributor Author

glekner commented May 18, 2020

  • applied suggestions and added validations to templates
    @suomiy

@@ -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(),
Copy link
Member

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(),
Copy link
Member

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)
Copy link
Member

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';
Copy link
Member

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]);
Copy link
Member

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) =>
Copy link
Member

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);
Copy link
Member

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();
Copy link
Member

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);
Copy link
Member

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: {
Copy link
Member

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 = (
Copy link
Member

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>) =>
Copy link
Member

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

@glekner glekner force-pushed the fix-1813198 branch 2 times, most recently from f5ca0c3 to 56eeec3 Compare May 19, 2020 12:07
@@ -91,3 +94,11 @@ export const initializeCommonVMMetadata = (
);
}
};

export const initializeCommonTemplateMetadata = (
entity: VMWrapper | VMTemplateWrapper,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
entity: VMWrapper | VMTemplateWrapper,
entity: VMTemplateWrapper,

template?: TemplateKind,
) => {
entity.addLabel(TEMPLATE_TYPE_LABEL, TEMPLATE_TYPE_VM);
entity.addAnotation(ANNOTATION_VALIDATIONS, getAnnotations(template)?.[ANNOTATION_VALIDATIONS]);
Copy link
Member

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 19, 2020
@glekner
Copy link
Contributor Author

glekner commented May 19, 2020

/retest

@atiratree
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 19, 2020
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit defbd3a into openshift:master May 19, 2020
@openshift-ci-robot
Copy link
Contributor

@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:

Bug 1813198: Windows CDs use VirtIO instead of sata

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.

@yaacov
Copy link
Member

yaacov commented May 19, 2020

/cherry-pick release-4.4

@openshift-cherrypick-robot

@yaacov: #5334 failed to apply on top of branch "release-4.4":

Using index info to reconstruct a base tree...
A	frontend/packages/kubevirt-plugin/src/components/create-vm-wizard/redux/state-update/storage-tab-state-update.ts
M	frontend/packages/kubevirt-plugin/src/components/create-vm-wizard/tabs/virtual-hardware-tab/virtual-hardware-tab.tsx
M	frontend/packages/kubevirt-plugin/src/components/modals/disk-modal/disk-modal.tsx
M	frontend/packages/kubevirt-plugin/src/constants/vm/constants.ts
M	frontend/packages/kubevirt-plugin/src/k8s/requests/vm/create/common.ts
M	frontend/packages/kubevirt-plugin/src/k8s/requests/vm/create/create.ts
M	frontend/packages/kubevirt-plugin/src/k8s/requests/vm/create/default-template.ts
A	frontend/packages/kubevirt-plugin/src/utils/common.ts
M	frontend/packages/kubevirt-plugin/src/utils/validations/template/template-validations.ts
M	frontend/packages/kubevirt-plugin/src/utils/validations/vm/disk.ts
Falling back to patching base and 3-way merge...
Auto-merging frontend/packages/kubevirt-plugin/src/utils/validations/vm/disk.ts
Auto-merging frontend/packages/kubevirt-plugin/src/utils/validations/template/template-validations.ts
CONFLICT (content): Merge conflict in frontend/packages/kubevirt-plugin/src/utils/validations/template/template-validations.ts
CONFLICT (modify/delete): frontend/packages/kubevirt-plugin/src/utils/common.ts deleted in HEAD and modified in Fixes 1813198: Windows CDs use VirtIO instead of sata. Version Fixes 1813198: Windows CDs use VirtIO instead of sata of frontend/packages/kubevirt-plugin/src/utils/common.ts left in tree.
Auto-merging frontend/packages/kubevirt-plugin/src/k8s/requests/vm/create/default-template.ts
CONFLICT (content): Merge conflict in frontend/packages/kubevirt-plugin/src/k8s/requests/vm/create/default-template.ts
Auto-merging frontend/packages/kubevirt-plugin/src/k8s/requests/vm/create/create.ts
CONFLICT (content): Merge conflict in frontend/packages/kubevirt-plugin/src/k8s/requests/vm/create/create.ts
Auto-merging frontend/packages/kubevirt-plugin/src/k8s/requests/vm/create/common.ts
CONFLICT (content): Merge conflict in frontend/packages/kubevirt-plugin/src/k8s/requests/vm/create/common.ts
Auto-merging frontend/packages/kubevirt-plugin/src/constants/vm/constants.ts
Auto-merging frontend/packages/kubevirt-plugin/src/components/modals/disk-modal/disk-modal.tsx
Auto-merging frontend/packages/kubevirt-plugin/src/components/create-vm-wizard/tabs/virtual-hardware-tab/virtual-hardware-tab.tsx
Auto-merging frontend/packages/kubevirt-plugin/src/components/create-vm-wizard/redux/stateUpdate/vmSettings/storage-tab-state-update.ts
CONFLICT (content): Merge conflict in frontend/packages/kubevirt-plugin/src/components/create-vm-wizard/redux/stateUpdate/vmSettings/storage-tab-state-update.ts
error: Failed to merge in the changes.
Patch failed at 0001 Fixes 1813198: Windows CDs use VirtIO instead of sata

In response to this:

/cherry-pick release-4.4

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.

@yaacov
Copy link
Member

yaacov commented May 19, 2020

@glekner hi, ^^ looks like this should be backported by hand :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/kubevirt Related to kubevirt-plugin lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants