Alerting: Copy alert rule metadata when the rule is updated via provisioning API (#93723)
Alerting: Copy alert rule metadata when the rule is updated
This commit is contained in:
@@ -795,6 +795,13 @@ func PatchPartialAlertRule(existingRule *AlertRule, ruleToPatch *AlertRuleWithOp
|
||||
if !ruleToPatch.HasPause {
|
||||
ruleToPatch.IsPaused = existingRule.IsPaused
|
||||
}
|
||||
|
||||
// Currently metadata contains only editor settings, so we can just copy it.
|
||||
// If we add more fields to metadata, we might need to handle them separately,
|
||||
// and/or merge or update their values.
|
||||
if ruleToPatch.Metadata == (AlertRuleMetadata{}) {
|
||||
ruleToPatch.Metadata = existingRule.Metadata
|
||||
}
|
||||
}
|
||||
|
||||
func ValidateRuleGroupInterval(intervalSeconds, baseIntervalSeconds int64) error {
|
||||
|
||||
@@ -253,10 +253,17 @@ func TestPatchPartialAlertRule(t *testing.T) {
|
||||
r.IsPaused = true
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "No metadata",
|
||||
mutator: func(r *AlertRuleWithOptionals) {
|
||||
r.Metadata = AlertRuleMetadata{}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
gen := RuleGen.With(
|
||||
RuleMuts.WithFor(time.Duration(rand.Int63n(1000) + 1)),
|
||||
RuleMuts.WithFor(time.Duration(rand.Int63n(1000)+1)),
|
||||
RuleMuts.WithEditorSettingsSimplifiedQueryAndExpressionsSection(true),
|
||||
)
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user