Skip to content

Commit

Permalink
chore: handle error before using task (#6055)
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv authored Sep 24, 2024
1 parent 419d2da commit b49ed91
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/query-service/rules/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,15 +476,15 @@ func (m *Manager) addTask(rule *PostableRule, taskName string) error {
UseLogsNewSchema: m.opts.UseLogsNewSchema,
})

for _, r := range newTask.Rules() {
m.rules[r.ID()] = r
}

if err != nil {
zap.L().Error("creating rule task failed", zap.String("name", taskName), zap.Error(err))
return errors.New("error loading rules, previous rule set restored")
}

for _, r := range newTask.Rules() {
m.rules[r.ID()] = r
}

// If there is an another task with the same identifier, raise an error
_, ok := m.tasks[taskName]
if ok {
Expand Down

0 comments on commit b49ed91

Please sign in to comment.