From 0a42a9fc8f3da272964a6d14f1cb24fc82f65140 Mon Sep 17 00:00:00 2001 From: Brian Brazil Date: Thu, 30 Nov 2017 13:49:15 +0000 Subject: [PATCH] Copy over rule group duration on reload. This is currently getting lost, this will soon be in a metric and we don't want it dropping to 0 on every reload. --- rules/manager.go | 2 ++ rules/manager_test.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/rules/manager.go b/rules/manager.go index 27cc78f98..16fb48104 100644 --- a/rules/manager.go +++ b/rules/manager.go @@ -284,6 +284,8 @@ func (g *Group) offset() time.Duration { // Rules are matched based on their name. If there are duplicates, the // first is matched with the first, second with the second etc. func (g *Group) copyState(from *Group) { + g.evaluationTime = from.evaluationTime + ruleMap := make(map[string][]int, len(from.rules)) for fi, fromRule := range from.rules { diff --git a/rules/manager_test.go b/rules/manager_test.go index 30e38e922..859118797 100644 --- a/rules/manager_test.go +++ b/rules/manager_test.go @@ -266,6 +266,7 @@ func TestCopyState(t *testing.T) { map[string]labels.Labels{"r3a": nil}, map[string]labels.Labels{"r3b": nil}, }, + evaluationTime: time.Second, } oldGroup.rules[0].(*AlertingRule).active[42] = nil newGroup := &Group{ @@ -291,6 +292,7 @@ func TestCopyState(t *testing.T) { } testutil.Equals(t, want, newGroup.seriesInPreviousEval) testutil.Equals(t, oldGroup.rules[0], newGroup.rules[3]) + testutil.Equals(t, oldGroup.evaluationTime, newGroup.evaluationTime) } func TestUpdate(t *testing.T) {