-
Notifications
You must be signed in to change notification settings - Fork 592
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
Bug 1803780: Validate disk buses on created VMs #4335
Conversation
@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:
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. |
/retest |
@@ -117,6 +120,7 @@ const DiskModalFirehose: React.FC<DiskModalFirehoseProps> = (props) => { | |||
vmLikeEntity={vmLikeEntity} | |||
namespace={namespace} | |||
onNamespaceChanged={(n) => setNamespace(n)} | |||
templateValidations={restProps.templateValidations} |
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.
no need for this line
@@ -61,6 +62,7 @@ const DiskModalFirehoseComponent: React.FC<DiskModalFirehoseComponentProps> = (p | |||
volume={volumeWrapper} | |||
dataVolume={dataVolumeWrapper} | |||
onSubmit={onSubmit} | |||
templateValidations={restProps.templateValidations} |
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.
+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)); |
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 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 = ( |
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 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) => |
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.
there is already a function getVMTemplateNamespacedName
- can we refactor it so it uses these constants?
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 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)), |
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 create a basic selector getTemplateValidations
instead?
diskValidations && { | ||
name: diskValidations.validations.name, | ||
size: diskValidations.validations.size, | ||
diskInterface: diskValidations.validations.diskInterface, |
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.
lets show the other validations in source
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.
there is a source
validation field
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 on UIDiskValidation
type.
Here I'm using the result from validateDisk
which returns UIDiskValidation
object and not StorageSimpleDataValidation
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 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={{ |
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.
lets pass the templateValidations to customData and not bundle it with each disk as it is the same entity
/bugzilla refresh |
@spadgett: This pull request references Bugzilla bug 1803780, which is invalid:
Comment 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. |
29b7cce
to
729e3d0
Compare
/retest |
/bugzilla refresh |
@irosenzw: This pull request references Bugzilla bug 1803780, which is valid. 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. |
diskValidations && { | ||
name: diskValidations.validations.name, | ||
size: diskValidations.validations.size, | ||
diskInterface: diskValidations.validations.diskInterface, |
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.
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; |
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 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, |
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.
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) => |
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 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); |
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 refactor this function so it uses LABEL_USED_TEMPLATE_NAME
and LABEL_USED_TEMPLATE_NAMESPACE
constants
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.
it uses these constants. am I missing something ?
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 already posted a PR which fixed that
const [isLocked, setIsLocked] = useSafetyFirst(false); | ||
const withProgress = wrapWithProgress(setIsLocked); | ||
const templateValidations = getTemplateValidationsFromTemplate(vmTemplate.data); |
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.
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))); |
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 should be a basic selector. It is very inefficient to create an immutable to just select some stuff
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.
done
729e3d0
to
ded47b8
Compare
ded47b8
to
a7972dc
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: irosenzw 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 |
@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. |
Bug 1807212: Fix async bug where models not loaded in time
a7972dc
to
feddb0a
Compare
export const getTemplateValidationsFromTemplate = ( | ||
vmTemplate: TemplateKind, | ||
): TemplateValidations => { | ||
const result = _.get(vmTemplate, ['metadata', 'annotations', '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 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)); |
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, I would just return the raw data and not construct the object TemplateValidations 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.
+it would be consistent with the iGetTemplateValidations version
} | ||
}; | ||
|
||
export const getTemplateFlavors = (vmTemplates: TemplateKind[]) => |
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.
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) => { |
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.
doesn't belong here
datavolumes, | ||
vmTemplate, | ||
}) => { | ||
// console.log('vmTemplate', vmTemplate); |
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.
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. |
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.
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. |
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.
also here
diskValidations && { | ||
name: diskValidations.validations.name, | ||
size: diskValidations.validations.size, | ||
diskInterface: diskValidations.validations.diskInterface, |
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 fixing the source mapping
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