From 8ca73d18afa4efea1050f8283d5f9994be29a3e1 Mon Sep 17 00:00:00 2001 From: Anusha Ragunathan Date: Mon, 26 Sep 2016 10:08:52 -0700 Subject: [PATCH] Initialize libnetwork and IPAMDriver with pluginstore. Signed-off-by: Anusha Ragunathan Upstream-commit: a00940f02c2699c091ebffb47f4c2d7f14f284d9 Component: engine --- components/engine/daemon/daemon.go | 9 +++++++-- components/engine/daemon/daemon_unix.go | 2 +- components/engine/daemon/daemon_unix_test.go | 4 ++-- components/engine/daemon/daemon_windows.go | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/components/engine/daemon/daemon.go b/components/engine/daemon/daemon.go index 9911f3d2a3..8aabd6e6ed 100644 --- a/components/engine/daemon/daemon.go +++ b/components/engine/daemon/daemon.go @@ -47,6 +47,7 @@ import ( "github.com/docker/docker/pkg/sysinfo" "github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/truncindex" + plugingetter "github.com/docker/docker/plugin/getter" pluginstore "github.com/docker/docker/plugin/store" "github.com/docker/docker/reference" "github.com/docker/docker/registry" @@ -1095,7 +1096,7 @@ func (daemon *Daemon) reloadClusterDiscovery(config *Config) error { if daemon.netController == nil { return nil } - netOptions, err := daemon.networkOptions(daemon.configStore, nil) + netOptions, err := daemon.networkOptions(daemon.configStore, daemon.pluginStore, nil) if err != nil { logrus.WithError(err).Warnf("failed to get options with network controller") return nil @@ -1112,7 +1113,7 @@ func isBridgeNetworkDisabled(config *Config) bool { return config.bridgeConfig.Iface == disableNetworkBridge } -func (daemon *Daemon) networkOptions(dconfig *Config, activeSandboxes map[string]interface{}) ([]nwconfig.Option, error) { +func (daemon *Daemon) networkOptions(dconfig *Config, pg plugingetter.PluginGetter, activeSandboxes map[string]interface{}) ([]nwconfig.Option, error) { options := []nwconfig.Option{} if dconfig == nil { return options, nil @@ -1153,6 +1154,10 @@ func (daemon *Daemon) networkOptions(dconfig *Config, activeSandboxes map[string options = append(options, nwconfig.OptionActiveSandboxes(activeSandboxes)) } + if pg != nil { + options = append(options, nwconfig.OptionPluginGetter(pg)) + } + return options, nil } diff --git a/components/engine/daemon/daemon_unix.go b/components/engine/daemon/daemon_unix.go index ba0c423aaf..c35b485aff 100644 --- a/components/engine/daemon/daemon_unix.go +++ b/components/engine/daemon/daemon_unix.go @@ -609,7 +609,7 @@ func configureKernelSecuritySupport(config *Config, driverName string) error { } func (daemon *Daemon) initNetworkController(config *Config, activeSandboxes map[string]interface{}) (libnetwork.NetworkController, error) { - netOptions, err := daemon.networkOptions(config, activeSandboxes) + netOptions, err := daemon.networkOptions(config, daemon.pluginStore, activeSandboxes) if err != nil { return nil, err } diff --git a/components/engine/daemon/daemon_unix_test.go b/components/engine/daemon/daemon_unix_test.go index 3b15547b9a..9766584b8f 100644 --- a/components/engine/daemon/daemon_unix_test.go +++ b/components/engine/daemon/daemon_unix_test.go @@ -188,7 +188,7 @@ func TestNetworkOptions(t *testing.T) { }, } - if _, err := daemon.networkOptions(dconfigCorrect, nil); err != nil { + if _, err := daemon.networkOptions(dconfigCorrect, nil, nil); err != nil { t.Fatalf("Expect networkOptions success, got error: %v", err) } @@ -198,7 +198,7 @@ func TestNetworkOptions(t *testing.T) { }, } - if _, err := daemon.networkOptions(dconfigWrong, nil); err == nil { + if _, err := daemon.networkOptions(dconfigWrong, nil, nil); err == nil { t.Fatalf("Expected networkOptions error, got nil") } } diff --git a/components/engine/daemon/daemon_windows.go b/components/engine/daemon/daemon_windows.go index c65c597ac1..af45ab84fe 100644 --- a/components/engine/daemon/daemon_windows.go +++ b/components/engine/daemon/daemon_windows.go @@ -186,7 +186,7 @@ func configureMaxThreads(config *Config) error { } func (daemon *Daemon) initNetworkController(config *Config, activeSandboxes map[string]interface{}) (libnetwork.NetworkController, error) { - netOptions, err := daemon.networkOptions(config, nil) + netOptions, err := daemon.networkOptions(config, nil, nil) if err != nil { return nil, err }