Move creation of default network from weaver to plugin

This way it is more likely that we create it after the plugin is up
and running.
This commit is contained in:
Bryan Boreham committed 2017-05-11 13:59:29 +00:00
1 parent f8d501ae50
commit 3e0eb4ac1e
2 files changed
+10 -10

No files matched your search

+9 -3
View File
@@ -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
}
+1 -7
View File
@@ -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 {