mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add the data-path-addr
During configuration in SWARM mode is now possible to pass an additional parameter --data-path-addr <ip|interface>. The information is going to be used to configure which is the interface that is going to be used for the data path for global scope drivers. Up to now the only driver really using this extra parameter is the overlay driver. Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
This commit is contained in:
parent
de0926bf39
commit
a0e0231909
3 changed files with 29 additions and 14 deletions
|
@ -39,11 +39,21 @@ type agent struct {
|
|||
networkDB *networkdb.NetworkDB
|
||||
bindAddr string
|
||||
advertiseAddr string
|
||||
dataPathAddr string
|
||||
epTblCancel func()
|
||||
driverCancelFuncs map[string][]func()
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
func (a *agent) dataPathAddress() string {
|
||||
a.Lock()
|
||||
defer a.Unlock()
|
||||
if a.dataPathAddr != "" {
|
||||
return a.dataPathAddr
|
||||
}
|
||||
return a.advertiseAddr
|
||||
}
|
||||
|
||||
const libnetworkEPTable = "endpoint_table"
|
||||
|
||||
func getBindAddr(ifaceName string) (string, error) {
|
||||
|
@ -189,14 +199,16 @@ func (c *controller) agentSetup() error {
|
|||
c.Unlock()
|
||||
bindAddr := clusterProvider.GetLocalAddress()
|
||||
advAddr := clusterProvider.GetAdvertiseAddress()
|
||||
dataAddr := clusterProvider.GetDataPathAddress()
|
||||
remote := clusterProvider.GetRemoteAddress()
|
||||
remoteAddr, _, _ := net.SplitHostPort(remote)
|
||||
listen := clusterProvider.GetListenAddress()
|
||||
listenAddr, _, _ := net.SplitHostPort(listen)
|
||||
|
||||
logrus.Infof("Initializing Libnetwork Agent Listen-Addr=%s Local-addr=%s Adv-addr=%s Remote-addr =%s", listenAddr, bindAddr, advAddr, remoteAddr)
|
||||
logrus.Infof("Initializing Libnetwork Agent Listen-Addr=%s Local-addr=%s Adv-addr=%s Data-addr=%s Remote-addr=%s",
|
||||
listenAddr, bindAddr, advAddr, dataAddr, remoteAddr)
|
||||
if advAddr != "" && agent == nil {
|
||||
if err := c.agentInit(listenAddr, bindAddr, advAddr); err != nil {
|
||||
if err := c.agentInit(listenAddr, bindAddr, advAddr, dataAddr); err != nil {
|
||||
logrus.Errorf("Error in agentInit : %v", err)
|
||||
} else {
|
||||
c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool {
|
||||
|
@ -262,7 +274,7 @@ func (c *controller) getPrimaryKeyTag(subsys string) ([]byte, uint64, error) {
|
|||
return keys[1].Key, keys[1].LamportTime, nil
|
||||
}
|
||||
|
||||
func (c *controller) agentInit(listenAddr, bindAddrOrInterface, advertiseAddr string) error {
|
||||
func (c *controller) agentInit(listenAddr, bindAddrOrInterface, advertiseAddr, dataPathAddr string) error {
|
||||
if !c.isAgent() {
|
||||
return nil
|
||||
}
|
||||
|
@ -296,6 +308,7 @@ func (c *controller) agentInit(listenAddr, bindAddrOrInterface, advertiseAddr st
|
|||
networkDB: nDB,
|
||||
bindAddr: bindAddr,
|
||||
advertiseAddr: advertiseAddr,
|
||||
dataPathAddr: dataPathAddr,
|
||||
epTblCancel: cancel,
|
||||
driverCancelFuncs: make(map[string][]func()),
|
||||
}
|
||||
|
@ -336,25 +349,22 @@ func (c *controller) agentDriverNotify(d driverapi.Driver) {
|
|||
return
|
||||
}
|
||||
|
||||
d.DiscoverNew(discoverapi.NodeDiscovery, discoverapi.NodeDiscoveryData{
|
||||
Address: agent.advertiseAddr,
|
||||
if err := d.DiscoverNew(discoverapi.NodeDiscovery, discoverapi.NodeDiscoveryData{
|
||||
Address: agent.dataPathAddress(),
|
||||
BindAddress: agent.bindAddr,
|
||||
Self: true,
|
||||
})
|
||||
}); err != nil {
|
||||
logrus.Warnf("Failed the node discovery in driver: %v", err)
|
||||
}
|
||||
|
||||
drvEnc := discoverapi.DriverEncryptionConfig{}
|
||||
keys, tags := c.getKeys(subsysIPSec)
|
||||
drvEnc.Keys = keys
|
||||
drvEnc.Tags = tags
|
||||
|
||||
c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool {
|
||||
err := driver.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc)
|
||||
if err != nil {
|
||||
logrus.Warnf("Failed to set datapath keys in driver %s: %v", name, err)
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
if err := d.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc); err != nil {
|
||||
logrus.Warnf("Failed to set datapath keys in driver: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *controller) agentClose() {
|
||||
|
|
|
@ -12,6 +12,7 @@ type Provider interface {
|
|||
GetLocalAddress() string
|
||||
GetListenAddress() string
|
||||
GetAdvertiseAddress() string
|
||||
GetDataPathAddress() string
|
||||
GetRemoteAddress() string
|
||||
ListenClusterEvents() <-chan struct{}
|
||||
AttachNetwork(string, string, []string) (*network.NetworkingConfig, error)
|
||||
|
|
|
@ -312,6 +312,10 @@ func (d *dnetConnection) GetAdvertiseAddress() string {
|
|||
return d.Orchestration.Bind
|
||||
}
|
||||
|
||||
func (d *dnetConnection) GetDataPathAddress() string {
|
||||
return d.Orchestration.Bind
|
||||
}
|
||||
|
||||
func (d *dnetConnection) GetLocalAddress() string {
|
||||
return d.Orchestration.Bind
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue