1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Reload config should initialize only the appropriate datastore

With the current implementation, a config relaod event causes all the
datastores to reinitialize and that impacts objects with Persist=false
such as none and host network.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
Madhu Venugopal 2016-03-25 01:10:03 -07:00
parent d60830037a
commit c92b196d2e
2 changed files with 16 additions and 9 deletions

View file

@ -218,6 +218,9 @@ func (c *controller) ReloadConfiguration(cfgOptions ...config.Option) error {
return types.ForbiddenErrorf("cannot accept new configuration because it modifies an existing datastore client") return types.ForbiddenErrorf("cannot accept new configuration because it modifies an existing datastore client")
} }
} else { } else {
if err := c.initScopedStore(s, nSCfg); err != nil {
return err
}
update = true update = true
} }
} }
@ -229,10 +232,6 @@ func (c *controller) ReloadConfiguration(cfgOptions ...config.Option) error {
c.cfg = cfg c.cfg = cfg
c.Unlock() c.Unlock()
if err := c.initStores(); err != nil {
return err
}
if c.discovery == nil && c.cfg.Cluster.Watcher != nil { if c.discovery == nil && c.cfg.Cluster.Watcher != nil {
if err := c.initDiscovery(c.cfg.Cluster.Watcher); err != nil { if err := c.initDiscovery(c.cfg.Cluster.Watcher); err != nil {
log.Errorf("Failed to Initialize Discovery after configuration update: %v", err) log.Errorf("Failed to Initialize Discovery after configuration update: %v", err)

View file

@ -7,6 +7,18 @@ import (
"github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/datastore"
) )
func (c *controller) initScopedStore(scope string, scfg *datastore.ScopeCfg) error {
store, err := datastore.NewDataStore(scope, scfg)
if err != nil {
return err
}
c.Lock()
c.stores = append(c.stores, store)
c.Unlock()
return nil
}
func (c *controller) initStores() error { func (c *controller) initStores() error {
c.Lock() c.Lock()
if c.cfg == nil { if c.cfg == nil {
@ -18,13 +30,9 @@ func (c *controller) initStores() error {
c.Unlock() c.Unlock()
for scope, scfg := range scopeConfigs { for scope, scfg := range scopeConfigs {
store, err := datastore.NewDataStore(scope, scfg) if err := c.initScopedStore(scope, scfg); err != nil {
if err != nil {
return err return err
} }
c.Lock()
c.stores = append(c.stores, store)
c.Unlock()
} }
c.startWatch() c.startWatch()