Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: change rawConfig to be atomic.Value #8755

Merged
merged 1 commit into from Apr 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions vault/core.go
Expand Up @@ -501,7 +501,7 @@ type Core struct {
pendingRaftPeers map[string][]byte

// rawConfig stores the config as-is from the provided server configuration.
rawConfig *server.Config
rawConfig *atomic.Value

coreNumber int

Expand Down Expand Up @@ -758,7 +758,7 @@ func NewCore(conf *CoreConfig) (*Core, error) {
clusterLeaderParams: new(atomic.Value),
metricsHelper: conf.MetricsHelper,
secureRandomReader: conf.SecureRandomReader,
rawConfig: conf.RawConfig,
rawConfig: new(atomic.Value),
counters: counters{
requests: new(uint64),
syncInterval: syncInterval,
Expand All @@ -768,6 +768,8 @@ func NewCore(conf *CoreConfig) (*Core, error) {
raftJoinDoneCh: make(chan struct{}),
}

c.rawConfig.Store(conf.RawConfig)

atomic.StoreUint32(c.sealed, 1)
c.allLoggers = append(c.allLoggers, c.logger)

Expand Down Expand Up @@ -2307,17 +2309,17 @@ 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.stateLock.Lock()
c.rawConfig = conf
c.stateLock.Unlock()
c.rawConfig.Store(conf)
}

// SanitizedConfig returns a sanitized version of the current config.
// See server.Config.Sanitized for specific values omitted.
func (c *Core) SanitizedConfig() map[string]interface{} {
c.stateLock.RLock()
defer c.stateLock.RUnlock()
return c.rawConfig.Sanitized()
conf := c.rawConfig.Load()
if conf == nil {
return nil
}
return conf.(*server.Config).Sanitized()
}

// MetricsHelper returns the global metrics helper which allows external
Expand Down