Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Filter NAD by namespace when creating new nic raw #265

Merged
merged 4 commits into from Apr 8, 2019

Conversation

yaacov
Copy link

@yaacov yaacov commented Apr 7, 2019

When getting network resource for a nic we want to filter it by namespace.

Currently we filter by namespace on the web-ui-component side [1] but we may want to remove this filter for cases that do not have a namespace.

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1687917

[1] kubevirt/web-ui-components#316

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XS labels Apr 7, 2019
@yaacov
Copy link
Author

yaacov commented Apr 7, 2019

@rawagner Thanks for finding the issue that caused the bug 💯 ,

As you suggested off line the bug happen when we filter by missing namespace, In this PR I'm trying to filter by namespace on the web-ui repo side.

Does that make sense, do we need this, can it break something eles ?

@yaacov yaacov changed the title [WIP] Filter NAD by namespace when creating new nic raw Filter NAD by namespace when creating new nic raw Apr 7, 2019
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 7, 2019
@rawagner
Copy link

rawagner commented Apr 8, 2019

@yaacov filtering on web-ui side is great! I do not think it will break anything

@@ -85,8 +85,9 @@ const NIC_TYPE_VM = 'nic-type-vm';
const NIC_TYPE_CREATE = 'nic-type-create';

export const NicRow = (onChange, onAccept, onCancel) => ({obj: nic}) => {
const namespace = (nic.vm && nic.vm.metadata.namespace) || (nic.vmTemplate && nic.vmTemplate.metadata.namespace);
Copy link

Choose a reason for hiding this comment

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

you can use getNamespace from web-ui-components - getNamespace(nic.vm) || getNamespace(nic.vmTemplate)

Copy link
Author

Choose a reason for hiding this comment

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

Wow, thanks 👍

@@ -85,8 +95,9 @@ const NIC_TYPE_VM = 'nic-type-vm';
const NIC_TYPE_CREATE = 'nic-type-create';

export const NicRow = (onChange, onAccept, onCancel) => ({obj: nic}) => {
const namespace = getNamespace(nic.vm) || getNamespace(nic.vmTemplate);

Choose a reason for hiding this comment

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

getNamespace(nic.vm || nic.vmTemplate)

@yaacov
Copy link
Author

yaacov commented Apr 8, 2019

@suomiy @rawagner applied the namespace refactor, please re review.

@rawagner rawagner merged commit 3f2fc3f into kubevirt:master Apr 8, 2019
@@ -85,8 +95,9 @@ const NIC_TYPE_VM = 'nic-type-vm';
const NIC_TYPE_CREATE = 'nic-type-create';

export const NicRow = (onChange, onAccept, onCancel) => ({obj: nic}) => {
const namespace = getNamespace(nic.vm || nic.vmTemplate);
Copy link
Author

Choose a reason for hiding this comment

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

@suomiy @rawagner hi, I made a mistake here :-(

nic.vm can be defined ( actually it is a required prop, so it is always defined ) but be without namespace label, in this case:

getNamespace(nic.vm || nic.vmTemplate) will be empty while getNamespace(nic.vm) || getNamespace(nic.vmTemplate) will hold the namespace of the vm template.

I will have to fix that in a new PR :-(

Do you know if we can make vm a none required prop, so if called from a template page it can be undefined ?
Should I just use the longer phrase ?
Help :-)

Copy link

@atiratree atiratree Apr 10, 2019

Choose a reason for hiding this comment

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

or something like this

getNamespace(nic.vmTemplate || nic.vm) // order important (vm might be template vm)

or the original approach but I would add some comment so nobody refactors that ;)

Please also add the comment to the props, that vm can be template vm (was not yet created)

Copy link
Author

Choose a reason for hiding this comment

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

👍 Thanks, the '(nic.vmTemplate || nic.vm)' looks nice to me, I currently do not have a running okd :-( , will make a PR ASAP.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants