fix lint errors

Signed-off-by: Mustafain Ali Khan <mustalik@amazon.com>
This commit is contained in:
Mustafain Ali Khan 2025-02-20 12:50:50 -08:00
parent 26bd06361b
commit f1b284a8b6
4 changed files with 12 additions and 12 deletions

View File

@ -71,9 +71,9 @@ type Group struct {
// Rule group evaluation iteration function,
// defaults to DefaultEvalIterationFunc.
evalIterationFunc GroupEvalIterationFunc
alertStore AlertStore
appOpts *storage.AppendOptions
alertStore AlertStore
appOpts *storage.AppendOptions
}
// GroupEvalIterationFunc is used to implement and extend rule group
@ -144,8 +144,8 @@ func NewGroup(o GroupOptions) *Group {
logger: opts.Logger.With("file", o.File, "group", o.Name),
metrics: metrics,
evalIterationFunc: evalIterationFunc,
appOpts: &storage.AppendOptions{DiscardOutOfOrder: true},
alertStore: o.AlertStore,
appOpts: &storage.AppendOptions{DiscardOutOfOrder: true},
}
}

View File

@ -2586,7 +2586,7 @@ func TestKeepFiringForStateRestore(t *testing.T) {
Queryable: testStorage,
Context: context.Background(),
Logger: promslog.NewNopLogger(),
NotifyFunc: func(ctx context.Context, expr string, alerts ...*Alert) {},
NotifyFunc: func(_ context.Context, _ string, _ ...*Alert) {},
OutageTolerance: 30 * time.Minute,
ForGracePeriod: 10 * time.Minute,
AlertStore: alertStore,
@ -2713,8 +2713,8 @@ func TestKeepFiringForStateRestore(t *testing.T) {
got := newRule.ActiveAlerts()
got2 := newRule2.ActiveAlerts()
require.Equal(t, len(exp), len(got))
require.Equal(t, len(exp2), len(got2))
require.Len(t, got, len(exp))
require.Len(t, got2, len(exp2))
require.Equal(t, tt.alertsExpected, len(got)+len(got2))
results := [][]*Alert{got, got2}
@ -2733,7 +2733,7 @@ func TestKeepFiringForStateRestore(t *testing.T) {
for i, expected := range expectedAlerts {
got = results[i]
require.Equal(t, len(expected), len(got))
require.Len(t, got, len(expected))
for j, alert := range expected {
diff := float64(alert.KeepFiringSince.Unix() - got[j].KeepFiringSince.Unix())
require.Equal(t, 0.0, math.Abs(diff), "'keep_firing_for' restored time is wrong")

View File

@ -115,12 +115,12 @@ func (s *FileStore) SetAlerts(key uint64, groupKey string, alerts []*Alert) erro
s.stateMtx.Lock()
defer s.stateMtx.Unlock()
// Update in memory
if alerts != nil {
s.alertsByRule[key] = alerts
} else {
if alerts == nil {
return nil
}
// Update in memory
s.alertsByRule[key] = alerts
// flush in memory state to file storage
file, err := os.Create(s.path)
if err != nil {

View File

@ -48,7 +48,7 @@ func TestAlertStore(t *testing.T) {
got, err := alertStore.GetAlerts(key)
require.NoError(t, err)
require.Equal(t, len(alerts), len(got))
require.Len(t, got, len(alerts))
result := make([]*Alert, 0, len(got))
for _, value := range got {