Alerting: Allow rules with same title across folders (#35270)

* Alerting: Allow rules with same title across folders

* Add test
This commit is contained in:
Sofia Papagiannaki
2021-06-04 20:45:26 +03:00
committed by GitHub
parent 99a6337e1f
commit 8cda1f5153
4 changed files with 133 additions and 1 deletions

View File

@@ -17,6 +17,8 @@ var (
ErrRuleGroupNamespaceNotFound = errors.New("rule group not found under this namespace")
// ErrAlertRuleFailedValidation
ErrAlertRuleFailedValidation = errors.New("invalid alert rule")
// ErrAlertRuleUniqueConstraintViolation
ErrAlertRuleUniqueConstraintViolation = errors.New("a conflicting alert rule is found: rule title under the same organisation and folder should be unique")
)
type NoDataState string

View File

@@ -522,6 +522,9 @@ func (st DBstore) UpdateRuleGroup(cmd UpdateRuleGroupCmd) error {
}
if err := st.UpsertAlertRules(upsertRules); err != nil {
if st.SQLStore.Dialect.IsUniqueConstraintViolation(err) {
return ngmodels.ErrAlertRuleUniqueConstraintViolation
}
return err
}