diff --git a/plugin/plugin.go b/plugin/plugin.go index 7c37e319..85bd4fc4 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -23,19 +23,19 @@ const ( var Log = common.Log -func Start(weaveAPIAddr string, dockerClient *docker.Client, address string, meshAddress string, dns bool, isPluginV2, forceMulticast bool) { +func Start(weaveAPIAddr string, dockerClient *docker.Client, address string, meshAddress string, dns bool, isPluginV2, forceMulticast bool, defaultSubnet string) { weave := weaveapi.NewClient(weaveAPIAddr, Log) Log.Info("Waiting for Weave API Server...") weave.WaitAPIServer(30) Log.Info("Finished waiting for Weave API Server") - if err := run(dockerClient, weave, address, meshAddress, dns, isPluginV2, forceMulticast); err != nil { + if err := run(dockerClient, weave, address, meshAddress, dns, isPluginV2, forceMulticast, defaultSubnet); err != nil { Log.Fatal(err) } } -func run(dockerClient *docker.Client, weave *weaveapi.Client, address, meshAddress string, dns, isPluginV2, forceMulticast bool) error { +func run(dockerClient *docker.Client, weave *weaveapi.Client, address, meshAddress string, dns, isPluginV2, forceMulticast bool, defaultSubnet string) error { endChan := make(chan error, 1) if address != "" { @@ -54,6 +54,12 @@ func run(dockerClient *docker.Client, weave *weaveapi.Client, address, meshAddre defer os.Remove(meshAddress) defer meshListener.Close() } + if !isPluginV2 { + Log.Println("Creating default 'weave' network") + options := map[string]interface{}{MulticastOption: "true"} + // TODO: the driver name should be extracted from pluginMeshSocket + dockerClient.EnsureNetwork("weave", "weavemesh", defaultSubnet, options) + } return <-endChan } diff --git a/prog/weaver/main.go b/prog/weaver/main.go index 150744e1..be787916 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -451,13 +451,7 @@ func main() { } if enablePlugin || enablePluginV2 { - go plugin.Start(httpAddr, dockerCli, pluginSocket, pluginMeshSocket, !noDNS, enablePluginV2, enablePluginV2Multicast) - } - if enablePlugin { - Log.Println("Creating default 'weave' network") - options := map[string]interface{}{plugin.MulticastOption: "true"} - // TODO: the driver name should be extracted from pluginMeshSocket - dockerCli.EnsureNetwork("weave", "weavemesh", defaultSubnet.String(), options) + go plugin.Start(httpAddr, dockerCli, pluginSocket, pluginMeshSocket, !noDNS, enablePluginV2, enablePluginV2Multicast, defaultSubnet.String()) } if bridgeConfig.AWSVPC {