Skip to content

Commit 94b740b

Browse files
committed
node: set VXLAN port through network provider
Remove the last direct libnetwork call outside of cnmallocator from Swarmkit. Signed-off-by: Cory Snider <[email protected]>
1 parent de58b5d commit 94b740b

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

manager/allocator/cnmallocator/provider.go

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"strings"
55

66
"github.com/docker/docker/libnetwork/driverapi"
7+
"github.com/docker/docker/libnetwork/drivers/overlay/overlayutils"
78
"github.com/docker/docker/libnetwork/ipamapi"
89
"github.com/docker/docker/pkg/plugingetter"
910
"github.com/moby/swarmkit/v2/api"
@@ -84,3 +85,7 @@ func (p *Provider) validatePluginDriver(driver *api.Driver, pluginType string) e
8485

8586
return nil
8687
}
88+
89+
func (p *Provider) SetDefaultVXLANUDPPort(port uint32) error {
90+
return overlayutils.ConfigVXLANUDPPort(port)
91+
}

manager/allocator/networkallocator/networkallocator.go

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ type DriverValidator interface {
112112
type Provider interface {
113113
DriverValidator
114114
PredefinedNetworks() []PredefinedNetworkData
115+
SetDefaultVXLANUDPPort(uint32) error
115116
NewAllocator(*Config) (NetworkAllocator, error)
116117
}
117118

node/node.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"sync"
1616
"time"
1717

18-
"github.com/docker/docker/libnetwork/drivers/overlay/overlayutils"
1918
"github.com/docker/docker/pkg/plugingetter"
2019
"github.com/docker/go-metrics"
2120
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
@@ -164,7 +163,6 @@ type Node struct {
164163
manager *manager.Manager
165164
notifyNodeChange chan *agent.NodeChanges // used by the agent to relay node updates from the dispatcher Session stream to (*Node).run
166165
unlockKey []byte
167-
vxlanUDPPort uint32
168166
}
169167

170168
type lastSeenRole struct {
@@ -274,8 +272,11 @@ func (n *Node) currentRole() api.NodeRole {
274272
}
275273

276274
// configVXLANUDPPort sets vxlan port in libnetwork
277-
func configVXLANUDPPort(ctx context.Context, vxlanUDPPort uint32) {
278-
if err := overlayutils.ConfigVXLANUDPPort(vxlanUDPPort); err != nil {
275+
func (n *Node) configVXLANUDPPort(ctx context.Context, vxlanUDPPort uint32) {
276+
if n.config.NetworkProvider == nil {
277+
return
278+
}
279+
if err := n.config.NetworkProvider.SetDefaultVXLANUDPPort(vxlanUDPPort); err != nil {
279280
log.G(ctx).WithError(err).Error("failed to configure VXLAN UDP port")
280281
return
281282
}
@@ -372,8 +373,7 @@ func (n *Node) run(ctx context.Context) (err error) {
372373
case nodeChanges := <-n.notifyNodeChange:
373374
if nodeChanges.Node != nil {
374375
if nodeChanges.Node.VXLANUDPPort != 0 {
375-
n.vxlanUDPPort = nodeChanges.Node.VXLANUDPPort
376-
configVXLANUDPPort(ctx, n.vxlanUDPPort)
376+
n.configVXLANUDPPort(ctx, nodeChanges.Node.VXLANUDPPort)
377377
}
378378
// This is a bit complex to be backward compatible with older CAs that
379379
// don't support the Node.Role field. They only use what's presently

0 commit comments

Comments
 (0)