-
Notifications
You must be signed in to change notification settings - Fork 243
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
grafana_rule_group rule block ordering reassigns rule UIDs #1928
Comments
I've been digging into this one and it's a bit complex. One way I think we might be able to get around it is by implementing a CustomDiff function which calculates some kind of semantic difference. It'd be somewhat arbitrary what constitutes a "new" rule rather than an edit of an existing one though as there isn't really anything that necessarily indicates identity from the configuration. I was thinking roughly in the direction of Levenshtien/edit distances or maybe weighting the various keys differently. (i.e. Title change means it's new rule, modifications of the expression not so much?) I think perhaps if the basic semantics of reordering rules doesn't maintain the UID and we err on the side of creating new UIDs rather than unintentional rewriting of existing rules that might be sufficient. |
Discussed with @yuri-tceretian and we resolved to link the |
Unfortunately it seems that implementing a WRT making |
…xisting rule history Unfortunately this is the only viable workaround. It will require users to manually set the uid for alert rules similar to how it is done in file provisioning. Addresses #1928
…xisting rule history Unfortunately this is the only viable workaround. It will require users to manually set the uid for alert rules similar to how it is done in file provisioning. Addresses #1928
…xisting rule history Unfortunately this is the only viable workaround. It will require users to manually set the uid for alert rules similar to how it is done in file provisioning. Addresses #1928
…xisting rule history Unfortunately this is the only viable workaround. It will require users to manually set the uid for alert rules similar to how it is done in file provisioning. Addresses #1928
…xisting rule history Unfortunately this is the only viable workaround. It will require users to manually set the uid for alert rules similar to how it is done in file provisioning. Addresses #1928
…xisting rule history Unfortunately this is the only viable workaround. It will require users to manually set the uid for alert rules similar to how it is done in file provisioning. Addresses #1928
…xisting rule history Unfortunately this is the only viable workaround. It will require users to manually set the uid for alert rules similar to how it is done in file provisioning. Addresses #1928
…xisting rule history Unfortunately this is the only viable workaround. It will require users to manually set the uid for alert rules similar to how it is done in file provisioning. Addresses #1928
…xisting rule history Unfortunately this is the only viable workaround. It will require users to manually set the uid for alert rules similar to how it is done in file provisioning. Addresses #1928
This was discovered as part of work to add support `uid` to the alert rule terraform provider. When modifying rule groups the uid can be specified but only if the rule already existed in the DB. If the rule is new the update would be rejected. Additionally, the RuleGroupIdx was not being updated when rules were reordered in the group. TODO: This breaks a number of tests and breaks the PutRule endpoint as it uses the same underlying function. I need to figure out how to bifurcate the usages of the delta calculator as PutRule should not allow creation of new rules. Context: grafana/terraform-provider-grafana#1971 (comment) Relates to: grafana/terraform-provider-grafana#1928
This was discovered as part of work to add support `uid` to the alert rule terraform provider. When modifying rule groups the uid can be specified but only if the rule already existed in the DB. If the rule is new the update would be rejected. Additionally, the RuleGroupIdx was not being updated when rules were reordered in the group. Context: grafana/terraform-provider-grafana#1971 (comment) Relates to: grafana/terraform-provider-grafana#1928
This was discovered as part of work to add support `uid` to the alert rule terraform provider. When modifying rule groups the uid can be specified but only if the rule already existed in the DB. If the rule is new the update would be rejected. Additionally, the RuleGroupIdx was not being updated when rules were reordered in the group. Context: grafana/terraform-provider-grafana#1971 (comment) Relates to: grafana/terraform-provider-grafana#1928
When modifying rule groups the `uid` can be specified but only if the rule already existed in the DB. If the rule is new the update would be rejected. This updates the RuleGroup provisioning apis to allow specifying the `uid` when creating/updating rule groups. Additionally, the RuleGroupIdx was not being updated when rules were reordered in the group. Context: grafana/terraform-provider-grafana#1971 (comment) Relates to: grafana/terraform-provider-grafana#1928 Fixes: #98283
When modifying rule groups the `uid` can be specified but only if the rule already existed in the DB. If the rule is new the update would be rejected. This updates the RuleGroup provisioning apis to allow specifying the `uid` when creating/updating rule groups. Additionally, the RuleGroupIdx was not being updated when rules were reordered in the group. Context: grafana/terraform-provider-grafana#1971 (comment) Relates to: grafana/terraform-provider-grafana#1928 Fixes: #98283 (cherry picked from commit 7dee4d1)
When modifying rule groups the `uid` can be specified but only if the rule already existed in the DB. If the rule is new the update would be rejected. This updates the RuleGroup provisioning apis to allow specifying the `uid` when creating/updating rule groups. Additionally, the RuleGroupIdx was not being updated when rules were reordered in the group. Context: grafana/terraform-provider-grafana#1971 (comment) Relates to: grafana/terraform-provider-grafana#1928 Fixes: #98283 (cherry picked from commit 7dee4d1)
…#99858) When modifying rule groups the `uid` can be specified but only if the rule already existed in the DB. If the rule is new the update would be rejected. This updates the RuleGroup provisioning apis to allow specifying the `uid` when creating/updating rule groups. Additionally, the RuleGroupIdx was not being updated when rules were reordered in the group. Context: grafana/terraform-provider-grafana#1971 (comment) Relates to: grafana/terraform-provider-grafana#1928 Fixes: grafana#98283
When modifying rule groups the `uid` can be specified but only if the rule already existed in the DB. If the rule is new the update would be rejected. This updates the RuleGroup provisioning apis to allow specifying the `uid` when creating/updating rule groups. Additionally, the RuleGroupIdx was not being updated when rules were reordered in the group. Context: grafana/terraform-provider-grafana#1971 (comment) Relates to: grafana/terraform-provider-grafana#1928 Fixes: #98283 (cherry picked from commit 7dee4d1)
Terraform Version
1.10.0
Terraform Grafana Provider Version
3.13.1
Grafana Version
main (11.4.0-pre)
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
Modifications to a
grafana_rule_group
that alter the ordering of rules would preferably retain the connection between a rule and its computed UID. This may be difficult to do in general given how alert rules are not resources and are instead modelled asLIST
type blocks under a group. So, at the very least the following should hold true:Actual Behavior
Modifying rule ordering in a group can unintentionally reassign a rule's UID to that of a different rule in the group. There are multiple ways this can happen, some examples:
idx-1
idx+1
. The last rule will obtain a newly generated UID.Steps to Reproduce
example alert
block.example alert 2
rule now has the UID of the deletedexample alert
rule.Important Factoids
Not sure how likely a general solution not requiring modifications to existing HCL is, considering this is tied pretty closely to how Alert rules and groups are modelled. That being said, optionally allowing a
rule
block UID to be configurable is a simple backwards compatible change and should allow a workaround to the issue.References
No response
The text was updated successfully, but these errors were encountered: