Skip to content

Commit 0c175ff

Browse files
author
Flavio Crisciani
committed
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>
1 parent 4dd9c06 commit 0c175ff

3 files changed

Lines changed: 29 additions & 14 deletions

File tree

agent.go

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,21 @@ type agent struct {
3939
networkDB *networkdb.NetworkDB
4040
bindAddr string
4141
advertiseAddr string
42+
dataPathAddr string
4243
epTblCancel func()
4344
driverCancelFuncs map[string][]func()
4445
sync.Mutex
4546
}
4647

48+
func (a *agent) dataPathAddress() string {
49+
a.Lock()
50+
defer a.Unlock()
51+
if a.dataPathAddr != "" {
52+
return a.dataPathAddr
53+
}
54+
return a.advertiseAddr
55+
}
56+
4757
const libnetworkEPTable = "endpoint_table"
4858

4959
func getBindAddr(ifaceName string) (string, error) {
@@ -189,14 +199,16 @@ func (c *controller) agentSetup() error {
189199
c.Unlock()
190200
bindAddr := clusterProvider.GetLocalAddress()
191201
advAddr := clusterProvider.GetAdvertiseAddress()
202+
dataAddr := clusterProvider.GetDataPathAddress()
192203
remote := clusterProvider.GetRemoteAddress()
193204
remoteAddr, _, _ := net.SplitHostPort(remote)
194205
listen := clusterProvider.GetListenAddress()
195206
listenAddr, _, _ := net.SplitHostPort(listen)
196207

197-
logrus.Infof("Initializing Libnetwork Agent Listen-Addr=%s Local-addr=%s Adv-addr=%s Remote-addr =%s", listenAddr, bindAddr, advAddr, remoteAddr)
208+
logrus.Infof("Initializing Libnetwork Agent Listen-Addr=%s Local-addr=%s Adv-addr=%s Data-addr=%s Remote-addr=%s",
209+
listenAddr, bindAddr, advAddr, dataAddr, remoteAddr)
198210
if advAddr != "" && agent == nil {
199-
if err := c.agentInit(listenAddr, bindAddr, advAddr); err != nil {
211+
if err := c.agentInit(listenAddr, bindAddr, advAddr, dataAddr); err != nil {
200212
logrus.Errorf("Error in agentInit : %v", err)
201213
} else {
202214
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) {
262274
return keys[1].Key, keys[1].LamportTime, nil
263275
}
264276

265-
func (c *controller) agentInit(listenAddr, bindAddrOrInterface, advertiseAddr string) error {
277+
func (c *controller) agentInit(listenAddr, bindAddrOrInterface, advertiseAddr, dataPathAddr string) error {
266278
if !c.isAgent() {
267279
return nil
268280
}
@@ -296,6 +308,7 @@ func (c *controller) agentInit(listenAddr, bindAddrOrInterface, advertiseAddr st
296308
networkDB: nDB,
297309
bindAddr: bindAddr,
298310
advertiseAddr: advertiseAddr,
311+
dataPathAddr: dataPathAddr,
299312
epTblCancel: cancel,
300313
driverCancelFuncs: make(map[string][]func()),
301314
}
@@ -336,25 +349,22 @@ func (c *controller) agentDriverNotify(d driverapi.Driver) {
336349
return
337350
}
338351

339-
d.DiscoverNew(discoverapi.NodeDiscovery, discoverapi.NodeDiscoveryData{
340-
Address: agent.advertiseAddr,
352+
if err := d.DiscoverNew(discoverapi.NodeDiscovery, discoverapi.NodeDiscoveryData{
353+
Address: agent.dataPathAddress(),
341354
BindAddress: agent.bindAddr,
342355
Self: true,
343-
})
356+
}); err != nil {
357+
logrus.Warnf("Failed the node discovery in driver: %v", err)
358+
}
344359

345360
drvEnc := discoverapi.DriverEncryptionConfig{}
346361
keys, tags := c.getKeys(subsysIPSec)
347362
drvEnc.Keys = keys
348363
drvEnc.Tags = tags
349364

350-
c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool {
351-
err := driver.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc)
352-
if err != nil {
353-
logrus.Warnf("Failed to set datapath keys in driver %s: %v", name, err)
354-
}
355-
return false
356-
})
357-
365+
if err := d.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc); err != nil {
366+
logrus.Warnf("Failed to set datapath keys in driver: %v", err)
367+
}
358368
}
359369

360370
func (c *controller) agentClose() {

cluster/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type Provider interface {
1212
GetLocalAddress() string
1313
GetListenAddress() string
1414
GetAdvertiseAddress() string
15+
GetDataPathAddress() string
1516
GetRemoteAddress() string
1617
ListenClusterEvents() <-chan struct{}
1718
AttachNetwork(string, string, []string) (*network.NetworkingConfig, error)

cmd/dnet/dnet.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@ func (d *dnetConnection) GetAdvertiseAddress() string {
312312
return d.Orchestration.Bind
313313
}
314314

315+
func (d *dnetConnection) GetDataPathAddress() string {
316+
return d.Orchestration.Bind
317+
}
318+
315319
func (d *dnetConnection) GetLocalAddress() string {
316320
return d.Orchestration.Bind
317321
}

0 commit comments

Comments
 (0)