mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Docker daemon updates to libnetwork discovery support
Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
956fbccdaa
commit
139ea5b7f2
3 changed files with 23 additions and 15 deletions
|
@ -720,7 +720,17 @@ func NewDaemon(config *Config, registryService *registry.Service) (daemon *Daemo
|
|||
}
|
||||
}
|
||||
|
||||
d.netController, err = initNetworkController(config)
|
||||
// Discovery is only enabled when the daemon is launched with an address to advertise. When
|
||||
// initialized, the daemon is registered and we can store the discovery backend as its read-only
|
||||
// DiscoveryWatcher version.
|
||||
if config.ClusterStore != "" && config.ClusterAdvertise != "" {
|
||||
var err error
|
||||
if d.discoveryWatcher, err = initDiscovery(config.ClusterStore, config.ClusterAdvertise); err != nil {
|
||||
return nil, fmt.Errorf("discovery initialization failed (%v)", err)
|
||||
}
|
||||
}
|
||||
|
||||
d.netController, err = d.initNetworkController(config)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error initializing network controller: %v", err)
|
||||
}
|
||||
|
@ -754,16 +764,6 @@ func NewDaemon(config *Config, registryService *registry.Service) (daemon *Daemo
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Discovery is only enabled when the daemon is launched with an address to advertise. When
|
||||
// initialized, the daemon is registered and we can store the discovery backend as its read-only
|
||||
// DiscoveryWatcher version.
|
||||
if config.ClusterStore != "" && config.ClusterAdvertise != "" {
|
||||
var err error
|
||||
if d.discoveryWatcher, err = initDiscovery(config.ClusterStore, config.ClusterAdvertise); err != nil {
|
||||
return nil, fmt.Errorf("discovery initialization failed (%v)", err)
|
||||
}
|
||||
}
|
||||
|
||||
d.ID = trustKey.PublicKey().KeyID()
|
||||
d.repository = daemonRepo
|
||||
d.containers = &contStore{s: make(map[string]*Container)}
|
||||
|
|
|
@ -302,7 +302,7 @@ func isBridgeNetworkDisabled(config *Config) bool {
|
|||
return config.Bridge.Iface == disableNetworkBridge
|
||||
}
|
||||
|
||||
func networkOptions(dconfig *Config) ([]nwconfig.Option, error) {
|
||||
func (daemon *Daemon) networkOptions(dconfig *Config) ([]nwconfig.Option, error) {
|
||||
options := []nwconfig.Option{}
|
||||
if dconfig == nil {
|
||||
return options, nil
|
||||
|
@ -330,13 +330,21 @@ func networkOptions(dconfig *Config) ([]nwconfig.Option, error) {
|
|||
options = append(options, nwconfig.OptionKVProviderURL(strings.Join(kv[1:], "://")))
|
||||
}
|
||||
|
||||
if daemon.discoveryWatcher != nil {
|
||||
options = append(options, nwconfig.OptionDiscoveryWatcher(daemon.discoveryWatcher))
|
||||
}
|
||||
|
||||
if dconfig.ClusterAdvertise != "" {
|
||||
options = append(options, nwconfig.OptionDiscoveryAddress(dconfig.ClusterAdvertise))
|
||||
}
|
||||
|
||||
options = append(options, nwconfig.OptionLabels(dconfig.Labels))
|
||||
options = append(options, driverOptions(dconfig)...)
|
||||
return options, nil
|
||||
}
|
||||
|
||||
func initNetworkController(config *Config) (libnetwork.NetworkController, error) {
|
||||
netOptions, err := networkOptions(config)
|
||||
func (daemon *Daemon) initNetworkController(config *Config) (libnetwork.NetworkController, error) {
|
||||
netOptions, err := daemon.networkOptions(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ func isBridgeNetworkDisabled(config *Config) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func initNetworkController(config *Config) (libnetwork.NetworkController, error) {
|
||||
func (daemon *Daemon) initNetworkController(config *Config) (libnetwork.NetworkController, error) {
|
||||
// Set the name of the virtual switch if not specified by -b on daemon start
|
||||
if config.Bridge.VirtualSwitchName == "" {
|
||||
config.Bridge.VirtualSwitchName = defaultVirtualSwitch
|
||||
|
|
Loading…
Reference in a new issue