|
@@ -59,13 +59,11 @@ import (
|
|
"github.com/docker/docker/libnetwork/discoverapi"
|
|
"github.com/docker/docker/libnetwork/discoverapi"
|
|
"github.com/docker/docker/libnetwork/driverapi"
|
|
"github.com/docker/docker/libnetwork/driverapi"
|
|
"github.com/docker/docker/libnetwork/drvregistry"
|
|
"github.com/docker/docker/libnetwork/drvregistry"
|
|
- "github.com/docker/docker/libnetwork/hostdiscovery"
|
|
|
|
"github.com/docker/docker/libnetwork/ipamapi"
|
|
"github.com/docker/docker/libnetwork/ipamapi"
|
|
"github.com/docker/docker/libnetwork/netlabel"
|
|
"github.com/docker/docker/libnetwork/netlabel"
|
|
"github.com/docker/docker/libnetwork/options"
|
|
"github.com/docker/docker/libnetwork/options"
|
|
"github.com/docker/docker/libnetwork/osl"
|
|
"github.com/docker/docker/libnetwork/osl"
|
|
"github.com/docker/docker/libnetwork/types"
|
|
"github.com/docker/docker/libnetwork/types"
|
|
- "github.com/docker/docker/pkg/discovery"
|
|
|
|
"github.com/docker/docker/pkg/plugingetter"
|
|
"github.com/docker/docker/pkg/plugingetter"
|
|
"github.com/docker/docker/pkg/plugins"
|
|
"github.com/docker/docker/pkg/plugins"
|
|
"github.com/docker/docker/pkg/stringid"
|
|
"github.com/docker/docker/pkg/stringid"
|
|
@@ -161,7 +159,6 @@ type controller struct {
|
|
sandboxes sandboxTable
|
|
sandboxes sandboxTable
|
|
cfg *config.Config
|
|
cfg *config.Config
|
|
stores []datastore.DataStore
|
|
stores []datastore.DataStore
|
|
- discovery hostdiscovery.HostDiscovery
|
|
|
|
extKeyListener net.Listener
|
|
extKeyListener net.Listener
|
|
watchCh chan *endpoint
|
|
watchCh chan *endpoint
|
|
unWatchCh chan *endpoint
|
|
unWatchCh chan *endpoint
|
|
@@ -228,14 +225,6 @@ func New(cfgOptions ...config.Option) (NetworkController, error) {
|
|
|
|
|
|
c.drvRegistry = drvRegistry
|
|
c.drvRegistry = drvRegistry
|
|
|
|
|
|
- if c.cfg != nil && c.cfg.Cluster.Watcher != nil {
|
|
|
|
- if err := c.initDiscovery(c.cfg.Cluster.Watcher); err != nil {
|
|
|
|
- // Failing to initialize discovery is a bad situation to be in.
|
|
|
|
- // But it cannot fail creating the Controller
|
|
|
|
- logrus.Errorf("Failed to Initialize Discovery : %v", err)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
c.WalkNetworks(populateSpecial)
|
|
c.WalkNetworks(populateSpecial)
|
|
|
|
|
|
// Reserve pools first before doing cleanup. Otherwise the
|
|
// Reserve pools first before doing cleanup. Otherwise the
|
|
@@ -518,13 +507,6 @@ func (c *controller) ReloadConfiguration(cfgOptions ...config.Option) error {
|
|
}
|
|
}
|
|
return false
|
|
return false
|
|
})
|
|
})
|
|
-
|
|
|
|
- if c.discovery == nil && c.cfg.Cluster.Watcher != nil {
|
|
|
|
- if err := c.initDiscovery(c.cfg.Cluster.Watcher); err != nil {
|
|
|
|
- logrus.Errorf("Failed to Initialize Discovery after configuration update: %v", err)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
@@ -564,30 +546,6 @@ func (c *controller) clusterHostID() string {
|
|
return addr[0]
|
|
return addr[0]
|
|
}
|
|
}
|
|
|
|
|
|
-func (c *controller) initDiscovery(watcher discovery.Watcher) error {
|
|
|
|
- if c.cfg == nil {
|
|
|
|
- return fmt.Errorf("discovery initialization requires a valid configuration")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- c.discovery = hostdiscovery.NewHostDiscovery(watcher)
|
|
|
|
- return c.discovery.Watch(c.activeCallback, c.hostJoinCallback, c.hostLeaveCallback)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func (c *controller) activeCallback() {
|
|
|
|
- ds := c.getStore(datastore.GlobalScope)
|
|
|
|
- if ds != nil && !ds.Active() {
|
|
|
|
- ds.RestartWatch()
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func (c *controller) hostJoinCallback(nodes []net.IP) {
|
|
|
|
- c.processNodeDiscovery(nodes, true)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func (c *controller) hostLeaveCallback(nodes []net.IP) {
|
|
|
|
- c.processNodeDiscovery(nodes, false)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func (c *controller) processNodeDiscovery(nodes []net.IP, add bool) {
|
|
func (c *controller) processNodeDiscovery(nodes []net.IP, add bool) {
|
|
c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool {
|
|
c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool {
|
|
c.pushNodeDiscovery(driver, capability, nodes, add)
|
|
c.pushNodeDiscovery(driver, capability, nodes, add)
|
|
@@ -662,14 +620,6 @@ func (c *controller) GetPluginGetter() plugingetter.PluginGetter {
|
|
}
|
|
}
|
|
|
|
|
|
func (c *controller) RegisterDriver(networkType string, driver driverapi.Driver, capability driverapi.Capability) error {
|
|
func (c *controller) RegisterDriver(networkType string, driver driverapi.Driver, capability driverapi.Capability) error {
|
|
- c.Lock()
|
|
|
|
- hd := c.discovery
|
|
|
|
- c.Unlock()
|
|
|
|
-
|
|
|
|
- if hd != nil {
|
|
|
|
- c.pushNodeDiscovery(driver, capability, hd.Fetch(), true)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
c.agentDriverNotify(driver)
|
|
c.agentDriverNotify(driver)
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|