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 1803780: Validate disk buses on created VMs #4335

Conversation

irosenzw
Copy link
Contributor

Validate disk bus type for created VMs storage disks
using validations written in the template
the VMs were created from.

Signed-off-by: Ido Rosenzwig irosenzw@redhat.com

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Feb 17, 2020
@openshift-ci-robot
Copy link
Contributor

@irosenzw: This pull request references Bugzilla bug 1803780, 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:

Bug 1803780: Validate disk buses on created VMs

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.

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 17, 2020
@openshift-ci-robot openshift-ci-robot added the component/kubevirt Related to kubevirt-plugin label Feb 17, 2020
@irosenzw
Copy link
Contributor Author

/retest

@@ -117,6 +120,7 @@ const DiskModalFirehose: React.FC<DiskModalFirehoseProps> = (props) => {
vmLikeEntity={vmLikeEntity}
namespace={namespace}
onNamespaceChanged={(n) => setNamespace(n)}
templateValidations={restProps.templateValidations}
Copy link
Member

Choose a reason for hiding this comment

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

no need for this line

@@ -61,6 +62,7 @@ const DiskModalFirehoseComponent: React.FC<DiskModalFirehoseComponentProps> = (p
volume={volumeWrapper}
dataVolume={dataVolumeWrapper}
onSubmit={onSubmit}
templateValidations={restProps.templateValidations}
Copy link
Member

Choose a reason for hiding this comment

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

+here

@@ -80,11 +84,11 @@ const getActions = (

const isTemplate = vmLikeEntity && !isVM(vmLikeEntity);
if (disk.isEditingSupported(isTemplate)) {
actions.push(menuActionEdit);
actions.push(menuActionEdit(disk, vmLikeEntity, templateValidations, opts));
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 please pass it in the opts?

@@ -86,3 +90,14 @@ export const getTemplateOperatingSystems = (templates: TemplateKind[]) => {

export const getTemplateWorkloadProfiles = (templates: TemplateKind[]) =>
getTemplatesLabelValues(templates, TEMPLATE_WORKLOAD_LABEL);

export const getTemplateOfVM = (
Copy link
Member

Choose a reason for hiding this comment

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

we don't need all these selectors

@@ -62,6 +63,9 @@ export const getOperatingSystemName = (vmLike: VMGenericLikeEntityKind) =>
`${TEMPLATE_OS_NAME_ANNOTATION}/${getOperatingSystem(vmLike)}`,
);

export const getTemplateName = (vm: VMGenericLikeEntityKind) =>
Copy link
Member

Choose a reason for hiding this comment

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

there is already a function getVMTemplateNamespacedName - can we refactor it so it uses these constants?

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 is not needed anymore. Can we remove it?

const [isLocked, setIsLocked] = useSafetyFirst(false);
const withProgress = wrapWithProgress(setIsLocked);
const relevantTemplate = getTemplateOfVM(vmLikeEntity, commonTemplates.data, userTemplates.data);
const templateValidations = new TemplateValidations(
iGetTemplateValidations(fromJS(relevantTemplate)),
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 create a basic selector getTemplateValidations instead?

diskValidations && {
name: diskValidations.validations.name,
size: diskValidations.validations.size,
diskInterface: diskValidations.validations.diskInterface,
Copy link
Member

Choose a reason for hiding this comment

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

lets show the other validations in source

Copy link
Member

Choose a reason for hiding this comment

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

there is a source validation field

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not on UIDiskValidation type.
Here I'm using the result from validateDisk which returns UIDiskValidation object and not StorageSimpleDataValidation

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 fixing the source mapping

@@ -147,7 +176,7 @@ export const VMDisks: React.FC<VMDisksProps> = ({ vmLikeEntity, pvcs, datavolume
)}
<div className="co-m-pane__body">
<VMDisksTable
data={getStoragesData({ vmLikeEntity, pvcs, datavolumes })}
data={getStoragesData({ vmLikeEntity, pvcs, datavolumes, templateValidations })}
customData={{
Copy link
Member

Choose a reason for hiding this comment

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

lets pass the templateValidations to customData and not bundle it with each disk as it is the same entity

@spadgett
Copy link
Member

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot added bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. and removed bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Feb 20, 2020
@openshift-ci-robot
Copy link
Contributor

@spadgett: This pull request references Bugzilla bug 1803780, which is invalid:

  • expected the bug to target the "4.5.0" release, but it targets "4.4.0" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/bugzilla refresh

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 irosenzw force-pushed the validate-disk-bus-for-already-created-vms branch from 29b7cce to 729e3d0 Compare February 23, 2020 14:41
@irosenzw
Copy link
Contributor Author

/retest

@irosenzw
Copy link
Contributor Author

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot added bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. and removed bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Feb 25, 2020
@openshift-ci-robot
Copy link
Contributor

@irosenzw: This pull request references Bugzilla bug 1803780, which is valid.

In response to this:

/bugzilla refresh

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.

diskValidations && {
name: diskValidations.validations.name,
size: diskValidations.validations.size,
diskInterface: diskValidations.validations.diskInterface,
Copy link
Member

Choose a reason for hiding this comment

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

there is a source validation field

actions.push(menuActionDelete);
return actions.map((a) => a(disk, vmLikeEntity, opts));
actions.push(menuActionDelete(disk, vmLikeEntity, opts));
return actions;
Copy link
Member

Choose a reason for hiding this comment

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

IMO the map approach is better

  • less code duplication
  • one will not forget to add it when adding another action

@@ -173,6 +200,12 @@ export const VMDisksFirehose: React.FC<VMLikeEntityTabProps> = ({ obj: vmLikeEnt
namespace,
prop: 'datavolumes',
}),
getResource(TemplateModel, {
name: vmTemplate.name,
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
name: vmTemplate.name,
name: vmTemplate?.name,
namespace: vmTemplate?.namespace,

@@ -62,6 +63,9 @@ export const getOperatingSystemName = (vmLike: VMGenericLikeEntityKind) =>
`${TEMPLATE_OS_NAME_ANNOTATION}/${getOperatingSystem(vmLike)}`,
);

export const getTemplateName = (vm: VMGenericLikeEntityKind) =>
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 is not needed anymore. Can we remove it?

@@ -163,6 +189,7 @@ export const VMDisks: React.FC<VMDisksProps> = ({ vmLikeEntity, pvcs, datavolume

export const VMDisksFirehose: React.FC<VMLikeEntityTabProps> = ({ obj: vmLikeEntity }) => {
const namespace = getNamespace(vmLikeEntity);
const vmTemplate = getVMTemplateNamespacedName(vmLikeEntity);
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 refactor this function so it uses LABEL_USED_TEMPLATE_NAME and LABEL_USED_TEMPLATE_NAMESPACE constants

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it uses these constants. am I missing something ?

Copy link
Member

Choose a reason for hiding this comment

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

I already posted a PR which fixed that

const [isLocked, setIsLocked] = useSafetyFirst(false);
const withProgress = wrapWithProgress(setIsLocked);
const templateValidations = getTemplateValidationsFromTemplate(vmTemplate.data);
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
const templateValidations = getTemplateValidationsFromTemplate(vmTemplate.data);
const templateValidations = new TemplateValidations(getTemplateValidations(getLoadedData(vmTemplate, [])));

@@ -55,6 +58,9 @@ export const getTemplatesLabelValues = (templates: TemplateKind[], label: string
return labelValues;
};

export const getTemplateValidationsFromTemplate = (vmTemplate: TemplateKind): TemplateValidations =>
new TemplateValidations(iGetTemplateValidations(fromJS(vmTemplate)));
Copy link
Member

Choose a reason for hiding this comment

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

this should be a basic selector. It is very inefficient to create an immutable to just select some stuff

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@irosenzw irosenzw force-pushed the validate-disk-bus-for-already-created-vms branch from 729e3d0 to ded47b8 Compare February 27, 2020 14:24
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 27, 2020
@irosenzw irosenzw force-pushed the validate-disk-bus-for-already-created-vms branch from ded47b8 to a7972dc Compare March 1, 2020 10:50
@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. component/core Related to console core functionality and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 1, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: irosenzw
To complete the pull request process, please assign spadgett
You can assign the PR to them by writing /assign @spadgett in a comment when ready.

The full list of commands accepted by this bot can be found 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-ci-robot
Copy link
Contributor

openshift-ci-robot commented Mar 1, 2020

@irosenzw: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/verify 729e3d0 link /test verify

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.

Bug 1807212: Fix async bug where models not loaded in time
@irosenzw irosenzw force-pushed the validate-disk-bus-for-already-created-vms branch from a7972dc to feddb0a Compare March 1, 2020 13:02
export const getTemplateValidationsFromTemplate = (
vmTemplate: TemplateKind,
): TemplateValidations => {
const result = _.get(vmTemplate, ['metadata', 'annotations', '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 can use ts optional chaining here and probably do not need the default

): TemplateValidations => {
const result = _.get(vmTemplate, ['metadata', 'annotations', 'validations'], []);
try {
return new TemplateValidations(JSON.parse(result));
Copy link
Member

Choose a reason for hiding this comment

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

IMO, I would just return the raw data and not construct the object TemplateValidations here

Copy link
Member

Choose a reason for hiding this comment

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

+it would be consistent with the iGetTemplateValidations version

}
};

export const getTemplateFlavors = (vmTemplates: TemplateKind[]) =>
Copy link
Member

Choose a reason for hiding this comment

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

all this stuff doesn't belong here - wrong rebase/squash?

@@ -24,3 +37,99 @@ export const getVMTemplate = (
)
: undefined;
};

export const getTemplatesLabelValues = (templates: TemplateKind[], label: string) => {
Copy link
Member

Choose a reason for hiding this comment

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

doesn't belong here

datavolumes,
vmTemplate,
}) => {
// console.log('vmTemplate', vmTemplate);
Copy link
Member

Choose a reason for hiding this comment

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

forgotten comment?

@@ -405,6 +405,8 @@ describe('Kubernetes resource CRUD operations', () => {
'/k8s/ns/openshift-monitoring/monitoring.coreos.com~v1~Alertmanager/main',
'/settings/cluster',
'/monitoring/query-browser',
// Test loading search page for a kind with no static model.
Copy link
Member

Choose a reason for hiding this comment

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

code from different PR

@@ -145,7 +145,12 @@ const SearchPage_: React.FC<SearchProps> = (props) => {
};

const getToggleText = (item: string) => {
const { labelPlural, apiVersion, apiGroup } = modelFor(item);
const model = modelFor(item);
// API discovery happens asynchronously. Avoid runtime errors if the model hasn't loaded.
Copy link
Member

Choose a reason for hiding this comment

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

also here

diskValidations && {
name: diskValidations.validations.name,
size: diskValidations.validations.size,
diskInterface: diskValidations.validations.diskInterface,
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 fixing the source mapping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/core Related to console core functionality component/kubevirt Related to kubevirt-plugin size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants