Browse Source

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.
pull/3541/head
Brian Brazil 7 years ago
parent
commit
0a42a9fc8f
  1. 2
      rules/manager.go
  2. 2
      rules/manager_test.go

2
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 // Rules are matched based on their name. If there are duplicates, the
// first is matched with the first, second with the second etc. // first is matched with the first, second with the second etc.
func (g *Group) copyState(from *Group) { func (g *Group) copyState(from *Group) {
g.evaluationTime = from.evaluationTime
ruleMap := make(map[string][]int, len(from.rules)) ruleMap := make(map[string][]int, len(from.rules))
for fi, fromRule := range from.rules { for fi, fromRule := range from.rules {

2
rules/manager_test.go

@ -266,6 +266,7 @@ func TestCopyState(t *testing.T) {
map[string]labels.Labels{"r3a": nil}, map[string]labels.Labels{"r3a": nil},
map[string]labels.Labels{"r3b": nil}, map[string]labels.Labels{"r3b": nil},
}, },
evaluationTime: time.Second,
} }
oldGroup.rules[0].(*AlertingRule).active[42] = nil oldGroup.rules[0].(*AlertingRule).active[42] = nil
newGroup := &Group{ newGroup := &Group{
@ -291,6 +292,7 @@ func TestCopyState(t *testing.T) {
} }
testutil.Equals(t, want, newGroup.seriesInPreviousEval) testutil.Equals(t, want, newGroup.seriesInPreviousEval)
testutil.Equals(t, oldGroup.rules[0], newGroup.rules[3]) testutil.Equals(t, oldGroup.rules[0], newGroup.rules[3])
testutil.Equals(t, oldGroup.evaluationTime, newGroup.evaluationTime)
} }
func TestUpdate(t *testing.T) { func TestUpdate(t *testing.T) {

Loading…
Cancel
Save