Browse Source

Invoke ReloadConfiguration on network controller

- It reverts fa163f5619bb01cabca1c21 plus a small change
  in order to allow passing the global scope datastore
  to libnetwork after damon boot.

Signed-off-by: Alessandro Boch <aboch@docker.com>
Alessandro Boch 9 years ago
parent
commit
ed364b69df
4 changed files with 32 additions and 5 deletions
  1. 16 3
      daemon/daemon.go
  2. 2 2
      daemon/daemon_test.go
  3. 5 0
      daemon/daemon_windows.go
  4. 9 0
      docs/reference/commandline/daemon.md

+ 16 - 3
daemon/daemon.go

@@ -1598,12 +1598,12 @@ func (daemon *Daemon) initDiscovery(config *Config) error {
 // daemon according to those changes.
 // daemon according to those changes.
 // This are the settings that Reload changes:
 // This are the settings that Reload changes:
 // - Daemon labels.
 // - Daemon labels.
+// - Cluster discovery (reconfigure and restart).
 func (daemon *Daemon) Reload(config *Config) error {
 func (daemon *Daemon) Reload(config *Config) error {
 	daemon.configStore.reloadLock.Lock()
 	daemon.configStore.reloadLock.Lock()
+	defer daemon.configStore.reloadLock.Unlock()
 	daemon.configStore.Labels = config.Labels
 	daemon.configStore.Labels = config.Labels
-	daemon.configStore.reloadLock.Unlock()
-
-	return nil
+	return daemon.reloadClusterDiscovery(config)
 }
 }
 
 
 func (daemon *Daemon) reloadClusterDiscovery(config *Config) error {
 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.ClusterOpts = config.ClusterOpts
 	daemon.configStore.ClusterAdvertise = newAdvertise
 	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
 	return nil
 }
 }
 
 

+ 2 - 2
daemon/daemon_test.go

@@ -371,7 +371,7 @@ func TestDaemonDiscoveryReload(t *testing.T) {
 		&discovery.Entry{Host: "127.0.0.1", Port: "5555"},
 		&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)
 		t.Fatal(err)
 	}
 	}
 	ch, errCh = daemon.discoveryWatcher.Watch(stopCh)
 	ch, errCh = daemon.discoveryWatcher.Watch(stopCh)
@@ -403,7 +403,7 @@ func TestDaemonDiscoveryReloadFromEmptyDiscovery(t *testing.T) {
 		&discovery.Entry{Host: "127.0.0.1", Port: "5555"},
 		&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)
 		t.Fatal(err)
 	}
 	}
 	stopCh := make(chan struct{})
 	stopCh := make(chan struct{})

+ 5 - 0
daemon/daemon_windows.go

@@ -22,6 +22,7 @@ import (
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/libnetwork"
 	"github.com/docker/libnetwork"
+	nwconfig "github.com/docker/libnetwork/config"
 	blkiodev "github.com/opencontainers/runc/libcontainer/configs"
 	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
 	return nil
 }
 }
+
+func (daemon *Daemon) networkOptions(dconfig *Config) ([]nwconfig.Option, error) {
+	return nil, fmt.Errorf("Network controller config reload not aavailable on Windows yet")
+}

+ 9 - 0
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:
 The list of currently supported options that can be reconfigured is this:
 
 
 - `debug`: it changes the daemon to debug mode when set to true.
 - `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.
 - `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.