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

Reload config should initialize only the appropriate datastore #1049

Merged
merged 1 commit into from
Mar 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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)
Expand Down
18 changes: 13 additions & 5 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
Expand Down