Log sanitized config at startup and when it changes. (#9637)

Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com>
This commit is contained in:
ncabatoff 2020-07-30 13:15:00 -04:00 committed by GitHub
parent 3792fea313
commit 1154b36b56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import (
"crypto/subtle"
"crypto/tls"
"crypto/x509"
"encoding/json"
"errors"
"fmt"
"io"
@ -761,8 +762,6 @@ func NewCore(conf *CoreConfig) (*Core, error) {
}
c.standbyStopCh.Store(make(chan struct{}))
c.rawConfig.Store(conf.RawConfig)
atomic.StoreUint32(c.sealed, 1)
c.metricSink.SetGaugeWithLabels([]string{"core", "unsealed"}, 0, nil)
@ -771,6 +770,8 @@ func NewCore(conf *CoreConfig) (*Core, error) {
c.router.logger = c.logger.Named("router")
c.allLoggers = append(c.allLoggers, c.router.logger)
c.SetConfig(conf.RawConfig)
atomic.StoreUint32(c.replicationState, uint32(consts.ReplicationDRDisabled|consts.ReplicationPerformanceDisabled))
c.localClusterCert.Store(([]byte)(nil))
c.localClusterParsedCert.Store((*x509.Certificate)(nil))
@ -2424,6 +2425,13 @@ func (c *Core) SetLogLevel(level log.Level) {
// SetConfig sets core's config object to the newly provided config.
func (c *Core) SetConfig(conf *server.Config) {
c.rawConfig.Store(conf)
bz, err := json.Marshal(c.SanitizedConfig())
if err != nil {
c.logger.Error("error serializing sanitized config", "error", err)
return
}
c.logger.Debug("set config", "sanitized config", string(bz))
}
// SanitizedConfig returns a sanitized version of the current config.