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:
parent
abc1994bec
commit
b7538e7b49
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue