diff --git a/daemon/daemon.go b/daemon/daemon.go index dfe6f0aeb6..8066a802d8 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -1598,12 +1598,12 @@ func (daemon *Daemon) initDiscovery(config *Config) error { // daemon according to those changes. // This are the settings that Reload changes: // - Daemon labels. +// - Cluster discovery (reconfigure and restart). func (daemon *Daemon) Reload(config *Config) error { daemon.configStore.reloadLock.Lock() + defer daemon.configStore.reloadLock.Unlock() daemon.configStore.Labels = config.Labels - daemon.configStore.reloadLock.Unlock() - - return nil + return daemon.reloadClusterDiscovery(config) } func (daemon *Daemon) reloadClusterDiscovery(config *Config) error { @@ -1640,6 +1640,19 @@ func (daemon *Daemon) reloadClusterDiscovery(config *Config) error { daemon.configStore.ClusterOpts = config.ClusterOpts daemon.configStore.ClusterAdvertise = newAdvertise + if daemon.netController == nil { + return nil + } + netOptions, err := daemon.networkOptions(daemon.configStore) + if err != nil { + logrus.Warnf("Failed to reload configuration with network controller: %v", err) + return nil + } + err = daemon.netController.ReloadConfiguration(netOptions...) + if err != nil { + logrus.Warnf("Failed to reload configuration with network controller: %v", err) + } + return nil } diff --git a/daemon/daemon_test.go b/daemon/daemon_test.go index 4a78bf2875..4f125e7a01 100644 --- a/daemon/daemon_test.go +++ b/daemon/daemon_test.go @@ -371,7 +371,7 @@ func TestDaemonDiscoveryReload(t *testing.T) { &discovery.Entry{Host: "127.0.0.1", Port: "5555"}, } - if err := daemon.reloadClusterDiscovery(newConfig); err != nil { + if err := daemon.Reload(newConfig); err != nil { t.Fatal(err) } ch, errCh = daemon.discoveryWatcher.Watch(stopCh) @@ -403,7 +403,7 @@ func TestDaemonDiscoveryReloadFromEmptyDiscovery(t *testing.T) { &discovery.Entry{Host: "127.0.0.1", Port: "5555"}, } - if err := daemon.reloadClusterDiscovery(newConfig); err != nil { + if err := daemon.Reload(newConfig); err != nil { t.Fatal(err) } stopCh := make(chan struct{}) diff --git a/daemon/daemon_windows.go b/daemon/daemon_windows.go index 2491caf28d..b4a6310475 100644 --- a/daemon/daemon_windows.go +++ b/daemon/daemon_windows.go @@ -22,6 +22,7 @@ import ( "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/system" "github.com/docker/libnetwork" + nwconfig "github.com/docker/libnetwork/config" blkiodev "github.com/opencontainers/runc/libcontainer/configs" ) @@ -251,3 +252,7 @@ func restoreCustomImage(is image.Store, ls layer.Store, rs reference.Store) erro } return nil } + +func (daemon *Daemon) networkOptions(dconfig *Config) ([]nwconfig.Option, error) { + return nil, fmt.Errorf("Network controller config reload not aavailable on Windows yet") +} diff --git a/docs/reference/commandline/daemon.md b/docs/reference/commandline/daemon.md index 34b42850a3..6565bd7b9b 100644 --- a/docs/reference/commandline/daemon.md +++ b/docs/reference/commandline/daemon.md @@ -890,4 +890,13 @@ if there are conflicts, but it won't stop execution. The list of currently supported options that can be reconfigured is this: - `debug`: it changes the daemon to debug mode when set to true. +- `cluster-store`: it reloads the discovery store with the new address. +- `cluster-store-opts`: it uses the new options to reload the discovery store. +- `cluster-advertise`: it modifies the address advertised after reloading. - `labels`: it replaces the daemon labels with a new set of labels. + +Updating and reloading the cluster configurations such as `--cluster-store`, +`--cluster-advertise` and `--cluster-store-opts` will take effect only if +these configurations were not previously configured. Configuration reload will +log a warning message if it detects a change in previously configured cluster +configurations. \ No newline at end of file