-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Alerting: Fix notification policies inheritance algorithm #69304
Alerting: Fix notification policies inheritance algorithm #69304
Conversation
public/app/features/alerting/unified/components/notification-policies/Policy.tsx
Show resolved
Hide resolved
public/app/features/alerting/unified/components/notification-policies/Policy.tsx
Outdated
Show resolved
Hide resolved
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.
LGTM!🚀
c212a0d
to
151a0bf
Compare
f71c053
to
75f7f7f
Compare
since the behaviour is currently inconsistent between AM flavors and we're not sure which one is correct
@@ -6,7 +6,7 @@ interface Props {} | |||
|
|||
const Strong = ({ children }: React.PropsWithChildren<Props>) => { | |||
const theme = useTheme2(); | |||
return <strong style={{ color: theme.colors.text.maxContrast }}>{children}</strong>; | |||
return <strong style={{ color: theme.colors.text.primary }}>{children}</strong>; |
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.
unrelated to the fix, but looks better :)
not sure how this one got updated
childRoute: Route, | ||
propertiesParentInherited?: Partial<InhertitableProperties> | ||
) { | ||
const fullParentProperties = merge({}, parentRoute, propertiesParentInherited); |
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.
So moving it to a new file makes it hard to make out the differences with the algorithm before, the quick version goes:
- we now compute the entire parent – with its inherited properties – before we create the inherited child properties
- we were previously merging the computed inherited properties with the parent's inherited properties – that's wrong
- since
merge()
mutates (ugh) I merge everything in to{}
to avoid any weird mutation bugs - we now also inherit from the parent if
group_by
is[]
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.
LGTM!🚀
This comment was marked as resolved.
This comment was marked as resolved.
(cherry picked from commit f94e07f)
Back-port PR here 👉 #69782 |
What is this feature?
This PR fixes the inheritance algorithm to compute what properties are inherited from a parent policy in a child policy.
Additionally
This PR normalizes the behaviour of the notification policies API response between Mimir and the built-in Alertmanager / vanilla Alertmanager.
It also changes to way we write the config for
inherit from parent
,group_by: []
is only preserved in the configuration by Mimir – other implementations simply returnundefined
.Note on grouping
There are several ways to define the
group_by
property of a notification policy, the following describes the values and their behaviour.group_by: ['label']
is just regular groupinggroup_by: []
means "inherit from parent" for child policiesgroup_by: []
means "single group" for the default (root) policygroup_by: <undefined>
(the absence of thegroup_by
key in the policy) inherits the grouping from the parent routegroup_by: ['...']
means disable groupingSpecial notes for your reviewer:
Please review the changes in the inheritance algorithm more closely than the rest of the PR – which is mostly updating the UI to take "no grouping" and "single group" semantics in to account.
I also moved that code to this file