diff --git a/rules/manager.go b/rules/manager.go index 84eb0697e..212c9f9e5 100644 --- a/rules/manager.go +++ b/rules/manager.go @@ -123,7 +123,11 @@ func (g *Group) run() { defer close(g.terminated) // Wait an initial amount to have consistently slotted intervals. - time.Sleep(g.offset()) + select { + case <-time.After(g.offset()): + case <-g.done: + return + } iter := func() { start := time.Now() diff --git a/rules/recording.go b/rules/recording.go index 070b43820..698a08323 100644 --- a/rules/recording.go +++ b/rules/recording.go @@ -55,6 +55,10 @@ func (rule RecordingRule) eval(timestamp model.Time, engine *promql.Engine) (mod result = query.Exec() vector model.Vector ) + if result.Err != nil { + return nil, err + } + switch result.Value.(type) { case model.Vector: vector, err = result.Vector()