Alerting: Remove unused AlertRuleVersionWithPauseStatus (#82383)

Remove unused AlertRuleVersionWithPauseStatus
This commit is contained in:
Alexander Weaver 2024-02-13 10:56:24 -06:00 committed by GitHub
parent 3f940f4da1
commit ccb4533a86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 16 deletions

View File

@ -24,5 +24,5 @@ type RuleStore interface {
DeleteAlertRulesByUID(ctx context.Context, orgID int64, ruleUID ...string) error DeleteAlertRulesByUID(ctx context.Context, orgID int64, ruleUID ...string) error
// IncreaseVersionForAllRulesInNamespace Increases version for all rules that have specified namespace. Returns all rules that belong to the namespace // IncreaseVersionForAllRulesInNamespace Increases version for all rules that have specified namespace. Returns all rules that belong to the namespace
IncreaseVersionForAllRulesInNamespace(ctx context.Context, orgID int64, namespaceUID string) ([]ngmodels.AlertRuleKeyWithVersionAndPauseStatus, error) IncreaseVersionForAllRulesInNamespace(ctx context.Context, orgID int64, namespaceUID string) ([]ngmodels.AlertRuleKeyWithVersion, error)
} }

View File

@ -368,11 +368,6 @@ type AlertRuleKeyWithVersion struct {
AlertRuleKey `xorm:"extends"` AlertRuleKey `xorm:"extends"`
} }
type AlertRuleKeyWithVersionAndPauseStatus struct {
IsPaused bool
AlertRuleKeyWithVersion `xorm:"extends"`
}
type AlertRuleKeyWithId struct { type AlertRuleKeyWithId struct {
AlertRuleKey AlertRuleKey
ID int64 ID int64

View File

@ -72,8 +72,8 @@ func (st DBstore) DeleteAlertRulesByUID(ctx context.Context, orgID int64, ruleUI
} }
// IncreaseVersionForAllRulesInNamespace Increases version for all rules that have specified namespace. Returns all rules that belong to the namespace // IncreaseVersionForAllRulesInNamespace Increases version for all rules that have specified namespace. Returns all rules that belong to the namespace
func (st DBstore) IncreaseVersionForAllRulesInNamespace(ctx context.Context, orgID int64, namespaceUID string) ([]ngmodels.AlertRuleKeyWithVersionAndPauseStatus, error) { func (st DBstore) IncreaseVersionForAllRulesInNamespace(ctx context.Context, orgID int64, namespaceUID string) ([]ngmodels.AlertRuleKeyWithVersion, error) {
var keys []ngmodels.AlertRuleKeyWithVersionAndPauseStatus var keys []ngmodels.AlertRuleKeyWithVersion
err := st.SQLStore.WithTransactionalDbSession(ctx, func(sess *db.Session) error { err := st.SQLStore.WithTransactionalDbSession(ctx, func(sess *db.Session) error {
now := TimeNow() now := TimeNow()
_, err := sess.Exec("UPDATE alert_rule SET version = version + 1, updated = ? WHERE namespace_uid = ? AND org_id = ?", now, namespaceUID, orgID) _, err := sess.Exec("UPDATE alert_rule SET version = version + 1, updated = ? WHERE namespace_uid = ? AND org_id = ?", now, namespaceUID, orgID)

View File

@ -315,7 +315,7 @@ func (f *RuleStore) UpdateRuleGroup(ctx context.Context, orgID int64, namespaceU
return nil return nil
} }
func (f *RuleStore) IncreaseVersionForAllRulesInNamespace(_ context.Context, orgID int64, namespaceUID string) ([]models.AlertRuleKeyWithVersionAndPauseStatus, error) { func (f *RuleStore) IncreaseVersionForAllRulesInNamespace(_ context.Context, orgID int64, namespaceUID string) ([]models.AlertRuleKeyWithVersion, error) {
f.mtx.Lock() f.mtx.Lock()
defer f.mtx.Unlock() defer f.mtx.Unlock()
@ -324,18 +324,15 @@ func (f *RuleStore) IncreaseVersionForAllRulesInNamespace(_ context.Context, org
Params: []any{orgID, namespaceUID}, Params: []any{orgID, namespaceUID},
}) })
var result []models.AlertRuleKeyWithVersionAndPauseStatus var result []models.AlertRuleKeyWithVersion
for _, rule := range f.Rules[orgID] { for _, rule := range f.Rules[orgID] {
if rule.NamespaceUID == namespaceUID && rule.OrgID == orgID { if rule.NamespaceUID == namespaceUID && rule.OrgID == orgID {
rule.Version++ rule.Version++
rule.Updated = time.Now() rule.Updated = time.Now()
result = append(result, models.AlertRuleKeyWithVersionAndPauseStatus{ result = append(result, models.AlertRuleKeyWithVersion{
IsPaused: rule.IsPaused,
AlertRuleKeyWithVersion: models.AlertRuleKeyWithVersion{
Version: rule.Version, Version: rule.Version,
AlertRuleKey: rule.GetKey(), AlertRuleKey: rule.GetKey(),
},
}) })
} }
} }