Don't stop, recreate, and start remote storage QueueManagers if the (#5485)

remote write config hasn't changed at all.

Signed-off-by: Callum Styan <callumstyan@gmail.com>
This commit is contained in:
Callum Styan 2019-04-23 01:47:18 -07:00 committed by Brian Brazil
parent abc1994bec
commit b7538e7b49
1 changed files with 18 additions and 0 deletions

View File

@ -15,10 +15,13 @@ package remote
import (
"context"
"crypto/md5"
"encoding/json"
"sync"
"time"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
@ -37,6 +40,8 @@ type Storage struct {
logger log.Logger
mtx sync.Mutex
configHash [16]byte
// For writes
walDir string
queues []*QueueManager
@ -77,6 +82,19 @@ func (s *Storage) ApplyConfig(conf *config.Config) error {
s.mtx.Lock()
defer s.mtx.Unlock()
cfgBytes, err := json.Marshal(conf.RemoteWriteConfigs)
if err != nil {
return err
}
hash := md5.Sum(cfgBytes)
if hash == s.configHash {
level.Debug(s.logger).Log("msg", "remote write config has not changed, no need to restart QueueManagers")
return nil
}
s.configHash = hash
// Update write queues
newQueues := []*QueueManager{}
// TODO: we should only stop & recreate queues which have changes,