Skip to content

Commit

Permalink
Make hidden runbook_url annotations visible
Browse files Browse the repository at this point in the history
Some upstream Jsonnet hides the `runbook_url` annotation on alerts.

Because of that, some of our patches which insert the `runbook_url`
annotation don't work correctly with go-jsonnet 0.20.0, which correctly
inherits field visibility in object comprehension (e.g.
`com.makeMergeable()`). This behavior will also be fixed in an upcoming
C++ jsonnet version, cf. google/jsonnet#1140 so
we adjust the component to make all `runbook_url` annotations visible.

Notably, the upstream Jsonnet which hides the annotation also sets it to
`null`, so we can then clean up the unwanted `runbook_url: null`
annotations by calling `std.prune()` on the annotations object.
  • Loading branch information
simu committed Oct 31, 2024
1 parent 82ec34c commit cba2b9e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions component/rules.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,18 @@ local patchRules = {
function(group)
group {
rules: std.map(
function(rule) alertpatching.patchRule(rule, rulePatches, false) {
expr: patchExpr(super.expr),
},
function(rule)
alertpatching.patchRule(rule, rulePatches, false) {
// NOTE(sg): Make runbook_url annotation visible so we can
// always patch it. This is necessary because some upstream
// Jsonnet hides the annotation with `runbook_url::` for
// alerts where they don't want to set the annotation.
annotations+:
if std.objectHasAll(rule.annotations, 'runbook_url') then {
runbook_url::: super.runbook_url,
} else {},
expr: patchExpr(super.expr),
} + { annotations: std.prune(super.annotations) },
group.rules
),
},
Expand Down

0 comments on commit cba2b9e

Please sign in to comment.