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:
parent
d60830037a
commit
c92b196d2e
2 changed files with 16 additions and 9 deletions
|
@ -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")
|
||||
}
|
||||
} else {
|
||||
if err := c.initScopedStore(s, nSCfg); err != nil {
|
||||
return err
|
||||
}
|
||||
update = true
|
||||
}
|
||||
}
|
||||
|
@ -229,10 +232,6 @@ func (c *controller) ReloadConfiguration(cfgOptions ...config.Option) error {
|
|||
c.cfg = cfg
|
||||
c.Unlock()
|
||||
|
||||
if err := c.initStores(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if c.discovery == nil && c.cfg.Cluster.Watcher != nil {
|
||||
if err := c.initDiscovery(c.cfg.Cluster.Watcher); err != nil {
|
||||
log.Errorf("Failed to Initialize Discovery after configuration update: %v", err)
|
||||
|
|
|
@ -7,6 +7,18 @@ import (
|
|||
"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 {
|
||||
c.Lock()
|
||||
if c.cfg == nil {
|
||||
|
@ -18,13 +30,9 @@ func (c *controller) initStores() error {
|
|||
c.Unlock()
|
||||
|
||||
for scope, scfg := range scopeConfigs {
|
||||
store, err := datastore.NewDataStore(scope, scfg)
|
||||
if err != nil {
|
||||
if err := c.initScopedStore(scope, scfg); err != nil {
|
||||
return err
|
||||
}
|
||||
c.Lock()
|
||||
c.stores = append(c.stores, store)
|
||||
c.Unlock()
|
||||
}
|
||||
|
||||
c.startWatch()
|
||||
|
|
Loading…
Reference in a new issue