Browse code

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 authored on 2016/02/18 10:08:11
Showing 4 changed files
... ...
@@ -1598,12 +1598,12 @@ func (daemon *Daemon) initDiscovery(config *Config) error {
1598 1598
 // daemon according to those changes.
1599 1599
 // This are the settings that Reload changes:
1600 1600
 // - Daemon labels.
1601
+// - Cluster discovery (reconfigure and restart).
1601 1602
 func (daemon *Daemon) Reload(config *Config) error {
1602 1603
 	daemon.configStore.reloadLock.Lock()
1604
+	defer daemon.configStore.reloadLock.Unlock()
1603 1605
 	daemon.configStore.Labels = config.Labels
1604
-	daemon.configStore.reloadLock.Unlock()
1605
-
1606
-	return nil
1606
+	return daemon.reloadClusterDiscovery(config)
1607 1607
 }
1608 1608
 
1609 1609
 func (daemon *Daemon) reloadClusterDiscovery(config *Config) error {
... ...
@@ -1640,6 +1640,19 @@ func (daemon *Daemon) reloadClusterDiscovery(config *Config) error {
1640 1640
 	daemon.configStore.ClusterOpts = config.ClusterOpts
1641 1641
 	daemon.configStore.ClusterAdvertise = newAdvertise
1642 1642
 
1643
+	if daemon.netController == nil {
1644
+		return nil
1645
+	}
1646
+	netOptions, err := daemon.networkOptions(daemon.configStore)
1647
+	if err != nil {
1648
+		logrus.Warnf("Failed to reload configuration with network controller: %v", err)
1649
+		return nil
1650
+	}
1651
+	err = daemon.netController.ReloadConfiguration(netOptions...)
1652
+	if err != nil {
1653
+		logrus.Warnf("Failed to reload configuration with network controller: %v", err)
1654
+	}
1655
+
1643 1656
 	return nil
1644 1657
 }
1645 1658
 
... ...
@@ -371,7 +371,7 @@ func TestDaemonDiscoveryReload(t *testing.T) {
371 371
 		&discovery.Entry{Host: "127.0.0.1", Port: "5555"},
372 372
 	}
373 373
 
374
-	if err := daemon.reloadClusterDiscovery(newConfig); err != nil {
374
+	if err := daemon.Reload(newConfig); err != nil {
375 375
 		t.Fatal(err)
376 376
 	}
377 377
 	ch, errCh = daemon.discoveryWatcher.Watch(stopCh)
... ...
@@ -403,7 +403,7 @@ func TestDaemonDiscoveryReloadFromEmptyDiscovery(t *testing.T) {
403 403
 		&discovery.Entry{Host: "127.0.0.1", Port: "5555"},
404 404
 	}
405 405
 
406
-	if err := daemon.reloadClusterDiscovery(newConfig); err != nil {
406
+	if err := daemon.Reload(newConfig); err != nil {
407 407
 		t.Fatal(err)
408 408
 	}
409 409
 	stopCh := make(chan struct{})
... ...
@@ -22,6 +22,7 @@ import (
22 22
 	"github.com/docker/docker/pkg/idtools"
23 23
 	"github.com/docker/docker/pkg/system"
24 24
 	"github.com/docker/libnetwork"
25
+	nwconfig "github.com/docker/libnetwork/config"
25 26
 	blkiodev "github.com/opencontainers/runc/libcontainer/configs"
26 27
 )
27 28
 
... ...
@@ -251,3 +252,7 @@ func restoreCustomImage(is image.Store, ls layer.Store, rs reference.Store) erro
251 251
 	}
252 252
 	return nil
253 253
 }
254
+
255
+func (daemon *Daemon) networkOptions(dconfig *Config) ([]nwconfig.Option, error) {
256
+	return nil, fmt.Errorf("Network controller config reload not aavailable on Windows yet")
257
+}
... ...
@@ -890,4 +890,13 @@ if there are conflicts, but it won't stop execution.
890 890
 The list of currently supported options that can be reconfigured is this:
891 891
 
892 892
 - `debug`: it changes the daemon to debug mode when set to true.
893
+- `cluster-store`: it reloads the discovery store with the new address.
894
+- `cluster-store-opts`: it uses the new options to reload the discovery store.
895
+- `cluster-advertise`: it modifies the address advertised after reloading.
893 896
 - `labels`: it replaces the daemon labels with a new set of labels.
897
+
898
+Updating and reloading the cluster configurations such as `--cluster-store`,
899
+`--cluster-advertise` and `--cluster-store-opts` will take effect only if
900
+these configurations were not previously configured. Configuration reload will
901
+log a warning message if it detects a change in previously configured cluster
902
+configurations.
894 903
\ No newline at end of file