Alerting: Remove grafanaManagedRecordingRules feature flag (#105569)

This commit is contained in:
Alexander Akhmetov
2025-05-19 12:15:49 +02:00
committed by GitHub
parent f83fb35bfb
commit c58ac15031
16 changed files with 47 additions and 173 deletions
@@ -51,11 +51,6 @@ func makeLimits(cfg *setting.UnifiedAlertingSettings) RuleLimits {
return RuleLimitsFromConfig(cfg, baseToggles)
}
func allowRecording(lim RuleLimits) *RuleLimits {
lim.RecordingRulesAllowed = true
return &lim
}
func validRule() apimodels.PostableExtendedRuleNode {
forDuration := model.Duration(rand.Int64N(1000))
keepFiringForDuration := model.Duration(rand.Int64N(1000))
@@ -447,8 +442,7 @@ func TestValidateRuleNode_NoUID(t *testing.T) {
},
},
{
name: "accepts and converts recording rule when toggle is enabled",
limits: allowRecording(limits),
name: "accepts and converts recording rule",
rule: func() *apimodels.PostableExtendedRuleNode {
r := validRule()
r.GrafanaManagedAlert.Record = &apimodels.Record{Metric: "some_metric", From: "A"}
@@ -489,8 +483,7 @@ func TestValidateRuleNode_NoUID(t *testing.T) {
},
},
{
name: "recording rules ignore fields that only make sense for Alerting rules",
limits: allowRecording(limits),
name: "recording rules ignore fields that only make sense for Alerting rules",
rule: func() *apimodels.PostableExtendedRuleNode {
r := validRule()
r.GrafanaManagedAlert.Record = &apimodels.Record{Metric: "some_metric", From: "A"}
@@ -673,22 +666,7 @@ func TestValidateRuleNodeFailures_NoUID(t *testing.T) {
},
},
{
name: "rejects valid recording rules if toggle is disabled",
rule: func() *apimodels.PostableExtendedRuleNode {
r := validRule()
r.GrafanaManagedAlert.Record = &apimodels.Record{Metric: "some_metric", From: "A"}
r.GrafanaManagedAlert.Condition = ""
r.GrafanaManagedAlert.NoDataState = ""
r.GrafanaManagedAlert.ExecErrState = ""
r.GrafanaManagedAlert.NotificationSettings = nil
r.For = nil
return &r
},
expErr: "recording rules cannot be created",
},
{
name: "rejects recording rule with invalid metric name",
limits: allowRecording(limits),
name: "rejects recording rule with invalid metric name",
rule: func() *apimodels.PostableExtendedRuleNode {
r := validRule()
r.GrafanaManagedAlert.Record = &apimodels.Record{Metric: "", From: "A"}
@@ -702,8 +680,7 @@ func TestValidateRuleNodeFailures_NoUID(t *testing.T) {
expErr: "must be a valid Prometheus metric name",
},
{
name: "rejects recording rule with empty from",
limits: allowRecording(limits),
name: "rejects recording rule with empty from",
rule: func() *apimodels.PostableExtendedRuleNode {
r := validRule()
r.GrafanaManagedAlert.Record = &apimodels.Record{Metric: "my_metric", From: ""}
@@ -717,8 +694,7 @@ func TestValidateRuleNodeFailures_NoUID(t *testing.T) {
expErr: "cannot be empty",
},
{
name: "rejects recording rule with from not matching",
limits: allowRecording(limits),
name: "rejects recording rule with from not matching",
rule: func() *apimodels.PostableExtendedRuleNode {
r := validRule()
r.GrafanaManagedAlert.Record = &apimodels.Record{Metric: "my_metric", From: "NOTEXIST"}