Load Notification objects after User and UserGroup#10427
Conversation
Notification objects can refer User and Group objects similar to how they can
refer Host and Service objects, so that dependency feels quite natural. Note
that for evaluating most configuration, this order doesn't really matter, the
configuration will successfully evaluate in either case, the difference can be
noticed mainly in more advanced configurations, for example when dynamically
assigning user based on their groups. When accessing user objects from the
Notification object definition (like in the following example), without this
change, only groups configured directly in groups attribute of User objects are
visible and those added via assign clauses in UserGroup objects are missing.
With this commit, these are also visible.
apply Notification "n" to Host {
for (var u in get_objects(User)) {
log(u.name + " -> " + Json.encode(u.groups))
}
# [...]
}
|
Did you want to point out https://github.com/Icinga/icinga2/compare/687013c4a1b538e3c5a231d97da80b88efb39f42..f8df6b4fa8fc0dd4a6cab0bfaa2bf1b7468db546? At least looking at the individual commits there makes little sense to me. |
Oh GitHub ! Yes thank you! |
|
So what exactly would be your suggestion for doing here instead? Applying https://github.com/Icinga/icinga2/compare/687013c4a1b538e3c5a231d97da80b88efb39f42..f8df6b4fa8fc0dd4a6cab0bfaa2bf1b7468db546 as-is instead? I wouldn't resort to #10000 here: that PR was supposed to solve something different, and did so in a different way. It can be a reference, but the suggestion in this PR should be more or less self-contained, as that suggestion is somewhere in the quite long history of that PR. |
No, not all! I'm asking you if that's all what you want to do here and wait till someone complains about the other types as well or fix it for all of them here.
|
|
The thing is that it's actually not that much about " The problem here is that none of this is really well-specified, the config language allows you to do pretty much everything and hence you may observe all kinds of implementation details. So yes, that might happen:
If you see particular reasons why we should add some other |
|
|
I've added a short section to the PR description describing what's done in the configuration using which the change in behavior was noticed. So far, I've only described a minimal example to show the difference, now it also describes a real-world use-case. |
Notification objects can refer User and Group objects similar to how they can refer Host and Service objects, so that dependency feels quite natural. Note that for evaluating most configuration, this order doesn't really matter, the configuration will successfully evaluate in either case, the difference can be noticed mainly in more advanced configurations, for example when dynamically assigning user based on their groups. When accessing user objects from the Notification object definition (like in the following example), without this change, only groups configured directly in groups attribute of User objects are visible and those added via assign clauses in UserGroup objects are missing. With this commit, these are also visible.
This was reported by a customer. Their configuration no longer worked as expected with snapshot packages compared to already released versions. I can't share their config here, but in summary, they are populating the
usersattribute with users that are both member of a group and are configured to receive notifications via a specific communication channel.Tests
Self-contained Icinga 2 config that adds a User to the UserGroup "g-attr" via its `groups` attribute and adds it to a second UserGroup "g-assign" via the `assign` clause in the group definition. It logs the groups of the user visible from within the Notification definition.
Current master
This PR
ref/IP/59088
refs #10148 (This behavior was changed by 467e8b1, this PR restores the previous behavior)