-
Notifications
You must be signed in to change notification settings - Fork 20
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
Write a hint for empty arrays/dicts into customvar_flat
#601
Conversation
Why does Icinga DB Web use the From my understanding, |
I second @julianbrost's opinion. |
Because of deny lists and protection rules. They are evaluated on the database, based on the same rules the user is comfortable with using them in the restrictions and search bar. |
I'm not sure if I fully understand and how restrictions play into this. Is this change also useful for the filter/restriction evaluation you're doing? Or is this more like that you want to display information that's as close to to underlying data that will be used for restrictions? |
It's an implementation detail, nothing more. We don't need to go into detail for this, just think about custom variables that shouldn't be visible, that aren't fetched from the db at all instead of filtering them out later on. |
Wait, are you talking about some mechanism that controls the visibility of individual custom vars for users? If so, I wasn't even aware that this existed and I thought you were referring to host/service permission filters based on custom vars. |
This also appears to be another bug that Alex didn't classify as such on Icingadb side, though it doesn't relate to this fix. |
I mean the primary user of all of this is Icinga DB Web, so if you say you want/need that, we can change it.
Yeah, I knew I've recently seen something like that. However, that couldn't be changed in the |
This PR isn't supposed to fix only the representation problem in the object details, but also for filtering. You already mentioned above that the @nilmerg also has clearly described in the referenced issue. So in the end, this PR only fixes some minor bugs, though doesn't break nor introduce any undesirable behaviors. |
There are two ways to review this. One would be to answer the question whether this writes Regarding filtering, can you provide an example how this change would actually be useful in this regard? I tried to play around with list filters quickly, and added So does this PR do what it advertises? Probably yes. Am I convinced that what it does is actually useful? Not really. |
I understand what's going on and that's basically why I tried this, to check if Icinga DB Web would do any fancy magic that expands filter conditions in ways I didn't expect it to. For you, it works as expected because you know the implementation of the filters and what happens is exactly what was implemented. But does it make sense for a user? Would users typically understand that to filter hosts that have
Adapting your suggestion from the screenshot, this would be |
It could make sense to always emit Maybe it could make sense to add some But in any case, it would make sense to understand what the underlying issues are. For displaying all vars that's clear, but for filtering, examples of what should be possible but can't be expressed at the moment would be helpful (buzzword: user stories). |
Actually, Icinga DB Web should solve this internally automatically (filtering by
Isn't the goal of Icinga DB to be able to replace the monitoring module? If the user was able to filter for something like |
Suggestion from a whiteboard discussion:
|
666b42f
to
3377152
Compare
Does this work properly without any extra changes in Icinga DB Web? Or is there already a PR? |
b55a2fd
to
2708e02
Compare
2708e02
to
d4fa951
Compare
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 current attempt to solve the display and search issues with empty variables doesn't make much sense to me anymore.
Take a look at the search bar changes for example. We need the suffixes (.
and []
) to show the user that a given variable is an empty dict or list (respectively).
Though, if one object uses the name "foo" to define an integer and another object uses it to define a string, we just show the name "foo" once and then the user can differentiate by the search value.
That is, we ignore the fact that the value of a variable might be of interest (name conflict) and we don't (empty lists/dicts).
So the suffixes are an entirely new thing, just to indicate empty lists or dicts. There's no other use or benefit. The trailing dot also causes issues with other parts in the Web code base, which have no notion of "custom variables". (Which they shouldn't have, that's fine)
So let's drop the suffixes, please. Yes, the searchbar cannot indicate an empty dict or list then anymore.
Though, what I'd keep is that empty lists and dicts are written to the customvar_flat table. Otherwise they're not shown anymore in the searchbar and are not visible in an object detail.
I also don't see this as a deviation of what the customvar_flat table is meant to be. Technically, it contains all concrete custom variable values. And their paths. But not any of the intermediate values or types. That's also the reason why empty variables weren't there in the first place, as they have no concrete value, as they're empty. Though, isn't the empty value the concrete value then? So, inserting a flatvalue of NULL
into the database for such variables, is fine to me with regard to these assumptions.
With a flatvalue of NULL
for only empty dicts and lists, the search bar can show them, the user can filter for them and they can be displayed in an object detail.
Isn't that just a side effect of everything being represented as strings in the database? When it's the same name mixed with values of type string and array on different objects, it's shown twice at the moment.
It's whatever we define it to be. For the current implementation (as in current master), there is a value if there is a scalar value at that path/flatname.
So empty arrays and dicts will become indistinguishable in the database just like they already are in the current PHP implementation?
Can you briefly explain what filters could be performed and how these interact with empty arrays (or also empty dicts for that matter if you can't distinguish them). |
Yes. The only thing which gets lost then is still the
Of course, while just |
So in regards to expressiveness of search filters, this would allow I'm not entirely sure what that did previously. Would it never match as |
(Yes.) Yes. Yes. No. |
So to summarize, the full list of things this PR (in combination with Icinga/icingadb-web#779) is supposed to change (assuming
Sounds fine for me, even though treating empty arrays and dicts as the same feels somewhat artificially limited. One remaining question regarding search filters: how are |
It is. But that's a topic for #610.
Correct. |
Is it? If that was resolved, it would allow you to tell whether the empty thing is at |
I'd extend the expected outcome of course 😉 This is strictly about empty variables. |
So I think the last few comments summarized in one sentence are: remove the |
d4fa951
to
14c79d5
Compare
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 PR description itself shows outdated behavior, so please update that as well.
Overall, the PR on the Go side now does what I expect it to do given the recent comments. I'd wait though and only merge this after Icinga/icingadb-web#779 is fully reviewed (I don't find the current behavior of search filters very intuitive, some of that could probably be improved by better labels but not sure what exactly is supposed to be the scope of these two PRs in the end).
14c79d5
to
23ac591
Compare
array
& map
correctlycustomvar_flat
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 Go part seems to work fine, but even with a freshly pulled icinga/icingaweb2:master
image (which should include Icinga/icingadb-web#779), I still receive two visually identical suggestion in the search bar for lists that are empty on some hosts and non-empty on others. One renders in the URL as array
, the other as array[*]
(± URL enconding). Is this still expected/intended @nilmerg?
Yes. |
I'd say should instead of could. At least to me, the current behavior looks more like a bug than intentional. |
Contents of the review were adressed: there are now no more .
/[]
suffixes in flatname
and flatvalue
may be NULL
.
Just inserts empty custom vars of type
array
&map
withNULL
value in to thecustomvar_flat
table.fixes #597