-
Notifications
You must be signed in to change notification settings - Fork 17
allow to enter arbitrary data for the network #175
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
base: master
Are you sure you want to change the base?
Conversation
| :id, | ||
| :name, | ||
| {}, | ||
| :'data-tags' => '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.
We could also do something fancy like
| :'data-tags' => 'true', | |
| :'data-tags' => compute_resource.networks.empty?, |
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 think it's not needed. Even if you see a partial list, it does not mean that there are no other valid values.
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 distinguish between the list is empty because you lack permissions or empty because there are none? Is the latter even a realistic case?
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 make
foreman_kubevirt/app/models/foreman_kubevirt/kubevirt.rb
Lines 80 to 86 in 63e77c2
| def networks | |
| client.networkattachmentdefs.all | |
| rescue StandardError => e | |
| logger.warn("Failed to retrieve network attachments definition from KubeVirt, | |
| make sure KubeVirt has CNI provider and NetworkAttachmentDefinition CRD deployed: #{e.message}") | |
| [] | |
| end |
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 logger.warn message is not visible for the user because it's only in the logs.
My main worry is that is may not be clear to the user why it's a text field and not a drop down. I'm tempted by the idea of returning nil so the frontend can distinguish but also worried about introducing new bugs with that.
If we go this route, I'd also suggest StandardError is too generic and looking at a more specific exception for a missing permission would be better.
Also toying with the idea of flashing an info/warn box in the except block, but that's also not great for the user to act on.
Perhaps short term the best we can do is to document the requirement. I'd also really like it if the Test connection button could show a warning that the permission is missing. Shall I write up a story for that so we don't lose track of it?
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.
@ekohl since it's totally acceptable not to have that list populated, I think I would avoid warning the user. Now that I think about it, I am not sure log.warn is appropriate here too. It's not something that the user/foreman admin should do something about.
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'd say we should catch the permission error and that could be a logger.warn but StandardError should be IMHO be logger.exception.
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 permission error is a Kubeclient::HttpError, so better than StandardError, but still not really specific :/
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.
Mhh, https://github.com/ManageIQ/kubeclient/blob/v4.y/lib/kubeclient/http_error.rb says
# TODO: remove this on next major version bump
# Deprected http exception
but https://github.com/ManageIQ/kubeclient/blob/master/lib/kubeclient/http_error.rb is still there for 5.x
but then again, this particular comment was introduced during 2.x→3.x and so far remains there
ManageIQ/kubeclient@87b8ff1
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 of course fog hides that and we get a Fog::Kubevirt::Errors::ClientError, jeez
app/views/compute_resources_vms/form/kubevirt/_network.html.erb
Outdated
Show resolved
Hide resolved
this is useful when the suggestion list is empty
ebc7e9c to
bf89cb1
Compare
| :id, | ||
| :name, | ||
| {}, | ||
| :data => { tags: 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.
This works fine for creation, but when you try to edit (a host or a compute profile, which uses the same form), the value gets reset, as the custom value we injected is not part of the compute_resource.network list above
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.
okay, adding it explicitly works, but ewww
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 probably should be .compact.uniq, but I bet the openstruct thing won't uniq with a real network anyway 😭
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 use the block parameter in uniq to compare different classes of objects: https://apidock.com/ruby/Array/uniq
this is useful when the suggestion list is empty