Browse code

bump libnetwork to ebcade70ad1059b070d0040d798ecca359bc5fed

full diff: https://github.com/docker/libnetwork/compare/1a06131fb8a047d919f7deaf02a4c414d7884b83...ebcade70ad1059b070d0040d798ecca359bc5fed

relevant changes:

- docker/libnetwork#2349 IPVS: Add support for GetConfig/SetConfig
- docker/libnetwork#2343 Revert "debian has iptables-legacy and iptables-nft now"
- docker/libnetwork#2230 Moving IPVLAN driver out of experimental
- docker/libnetwork#2307 Fix for problem where agent is stopped and does not restart
- docker/libnetwork#2303 Touch-up error-message and godoc for ConfigVXLANUDPPort
- docker/libnetwork#2325 Fix possible nil pointer exception
- docker/libnetwork#2302 Use sync.RWMutex for VXLANUDPPort
- docker/libnetwork#2306 Improve error if auto-selecting IP-range failed

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2019/04/02 02:40:09
Showing 14 changed files
... ...
@@ -3,7 +3,7 @@
3 3
 # LIBNETWORK_COMMIT is used to build the docker-userland-proxy binary. When
4 4
 # updating the binary version, consider updating github.com/docker/libnetwork
5 5
 # in vendor.conf accordingly
6
-LIBNETWORK_COMMIT=1a06131fb8a047d919f7deaf02a4c414d7884b83
6
+LIBNETWORK_COMMIT=ebcade70ad1059b070d0040d798ecca359bc5fed
7 7
 
8 8
 install_proxy() {
9 9
 	case "$1" in
... ...
@@ -39,7 +39,7 @@ github.com/gofrs/flock 7f43ea2e6a643ad441fc12d0ecc0d3388b300c53 # v0.7.0
39 39
 #get libnetwork packages
40 40
 
41 41
 # When updating, also update LIBNETWORK_COMMIT in hack/dockerfile/install/proxy.installer accordingly
42
-github.com/docker/libnetwork 1a06131fb8a047d919f7deaf02a4c414d7884b83
42
+github.com/docker/libnetwork ebcade70ad1059b070d0040d798ecca359bc5fed
43 43
 github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9
44 44
 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
45 45
 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
... ...
@@ -378,6 +378,9 @@ func (c *controller) agentClose() {
378 378
 	c.agent = nil
379 379
 	c.Unlock()
380 380
 
381
+	// when the agent is closed the cluster provider should be cleaned up
382
+	c.SetClusterProvider(nil)
383
+
381 384
 	if agent == nil {
382 385
 		return
383 386
 	}
... ...
@@ -181,10 +181,8 @@ func (c *controller) defaultGwNetwork() (Network, error) {
181 181
 	defer func() { <-procGwNetwork }()
182 182
 
183 183
 	n, err := c.NetworkByName(libnGWNetwork)
184
-	if err != nil {
185
-		if _, ok := err.(types.NotFoundError); ok {
186
-			n, err = c.createGWNetwork()
187
-		}
184
+	if _, ok := err.(types.NotFoundError); ok {
185
+		n, err = c.createGWNetwork()
188 186
 	}
189 187
 	return n, err
190 188
 }
... ...
@@ -48,7 +48,7 @@ func setupIPForwarding(enableIPTables bool) error {
48 48
 		iptables.OnReloaded(func() {
49 49
 			logrus.Debug("Setting the default DROP policy on firewall reload")
50 50
 			if err := iptables.SetDefaultPolicy(iptables.Filter, "FORWARD", iptables.Drop); err != nil {
51
-				logrus.Warnf("Settig the default DROP policy on firewall reload failed, %v", err)
51
+				logrus.Warnf("Setting the default DROP policy on firewall reload failed, %v", err)
52 52
 			}
53 53
 		})
54 54
 	}
... ...
@@ -7,8 +7,8 @@ import (
7 7
 )
8 8
 
9 9
 var (
10
+	mutex        sync.RWMutex
10 11
 	vxlanUDPPort uint32
11
-	mutex        sync.Mutex
12 12
 )
13 13
 
14 14
 const defaultVXLANUDPPort = 4789
... ...
@@ -17,11 +17,10 @@ func init() {
17 17
 	vxlanUDPPort = defaultVXLANUDPPort
18 18
 }
19 19
 
20
-// ConfigVXLANUDPPort configures vxlan udp port number.
20
+// ConfigVXLANUDPPort configures the VXLAN UDP port (data path port) number.
21
+// If no port is set, the default (4789) is returned. Valid port numbers are
22
+// between 1024 and 49151.
21 23
 func ConfigVXLANUDPPort(vxlanPort uint32) error {
22
-	mutex.Lock()
23
-	defer mutex.Unlock()
24
-	// if the value comes as 0 by any reason we set it to default value 4789
25 24
 	if vxlanPort == 0 {
26 25
 		vxlanPort = defaultVXLANUDPPort
27 26
 	}
... ...
@@ -31,16 +30,17 @@ func ConfigVXLANUDPPort(vxlanPort uint32) error {
31 31
 	// The Dynamic Ports, aka the Private Ports, from 49152-65535
32 32
 	// So we can allow range between 1024 to 49151
33 33
 	if vxlanPort < 1024 || vxlanPort > 49151 {
34
-		return fmt.Errorf("ConfigVxlanUDPPort Vxlan UDP port number is not in valid range %d", vxlanPort)
34
+		return fmt.Errorf("VXLAN UDP port number is not in valid range (1024-49151): %d", vxlanPort)
35 35
 	}
36
+	mutex.Lock()
36 37
 	vxlanUDPPort = vxlanPort
37
-
38
+	mutex.Unlock()
38 39
 	return nil
39 40
 }
40 41
 
41 42
 // VXLANUDPPort returns Vxlan UDP port number
42 43
 func VXLANUDPPort() uint32 {
43
-	mutex.Lock()
44
-	defer mutex.Unlock()
44
+	mutex.RLock()
45
+	defer mutex.RUnlock()
45 46
 	return vxlanUDPPort
46 47
 }
47 48
deleted file mode 100644
... ...
@@ -1,9 +0,0 @@
1
-package libnetwork
2
-
3
-import "github.com/docker/libnetwork/drivers/ipvlan"
4
-
5
-func additionalDrivers() []initializer {
6
-	return []initializer{
7
-		{ipvlan.Init, "ipvlan"},
8
-	}
9
-}
... ...
@@ -3,6 +3,7 @@ package libnetwork
3 3
 import (
4 4
 	"github.com/docker/libnetwork/drivers/bridge"
5 5
 	"github.com/docker/libnetwork/drivers/host"
6
+	"github.com/docker/libnetwork/drivers/ipvlan"
6 7
 	"github.com/docker/libnetwork/drivers/macvlan"
7 8
 	"github.com/docker/libnetwork/drivers/null"
8 9
 	"github.com/docker/libnetwork/drivers/overlay"
... ...
@@ -13,14 +14,11 @@ func getInitializers(experimental bool) []initializer {
13 13
 	in := []initializer{
14 14
 		{bridge.Init, "bridge"},
15 15
 		{host.Init, "host"},
16
+		{ipvlan.Init, "ipvlan"},
16 17
 		{macvlan.Init, "macvlan"},
17 18
 		{null.Init, "null"},
18
-		{remote.Init, "remote"},
19 19
 		{overlay.Init, "overlay"},
20
-	}
21
-
22
-	if experimental {
23
-		in = append(in, additionalDrivers()...)
20
+		{remote.Init, "remote"},
24 21
 	}
25 22
 	return in
26 23
 }
... ...
@@ -87,16 +87,11 @@ func initFirewalld() {
87 87
 }
88 88
 
89 89
 func detectIptables() {
90
-	path, err := exec.LookPath("iptables-legacy") // debian has iptables-legacy and iptables-nft now
90
+	path, err := exec.LookPath("iptables")
91 91
 	if err != nil {
92
-		path, err = exec.LookPath("iptables")
93
-		if err != nil {
94
-			return
95
-		}
92
+		return
96 93
 	}
97
-
98 94
 	iptablesPath = path
99
-
100 95
 	supportsXlock = exec.Command(iptablesPath, "--wait", "-L", "-n").Run() == nil
101 96
 	mj, mn, mc, err := GetVersion()
102 97
 	if err != nil {
... ...
@@ -68,6 +68,13 @@ type Destination struct {
68 68
 // DstStats defines IPVS destination (real server) statistics
69 69
 type DstStats SvcStats
70 70
 
71
+// Config defines IPVS timeout configuration
72
+type Config struct {
73
+	TimeoutTCP    time.Duration
74
+	TimeoutTCPFin time.Duration
75
+	TimeoutUDP    time.Duration
76
+}
77
+
71 78
 // Handle provides a namespace specific ipvs handle to program ipvs
72 79
 // rules.
73 80
 type Handle struct {
... ...
@@ -188,3 +195,13 @@ func (i *Handle) GetService(s *Service) (*Service, error) {
188 188
 
189 189
 	return res[0], nil
190 190
 }
191
+
192
+// GetConfig returns the current timeout configuration
193
+func (i *Handle) GetConfig() (*Config, error) {
194
+	return i.doGetConfigCmd()
195
+}
196
+
197
+// SetConfig set the current timeout configuration. 0: no change
198
+func (i *Handle) SetConfig(c *Config) error {
199
+	return i.doSetConfigCmd(c)
200
+}
... ...
@@ -12,6 +12,7 @@ import (
12 12
 	"sync"
13 13
 	"sync/atomic"
14 14
 	"syscall"
15
+	"time"
15 16
 	"unsafe"
16 17
 
17 18
 	"github.com/sirupsen/logrus"
... ...
@@ -503,6 +504,60 @@ func (i *Handle) doGetDestinationsCmd(s *Service, d *Destination) ([]*Destinatio
503 503
 	return res, nil
504 504
 }
505 505
 
506
+// parseConfig given a ipvs netlink response this function will respond with a valid config entry, an error otherwise
507
+func (i *Handle) parseConfig(msg []byte) (*Config, error) {
508
+	var c Config
509
+
510
+	//Remove General header for this message
511
+	hdr := deserializeGenlMsg(msg)
512
+	attrs, err := nl.ParseRouteAttr(msg[hdr.Len():])
513
+	if err != nil {
514
+		return nil, err
515
+	}
516
+
517
+	for _, attr := range attrs {
518
+		attrType := int(attr.Attr.Type)
519
+		switch attrType {
520
+		case ipvsCmdAttrTimeoutTCP:
521
+			c.TimeoutTCP = time.Duration(native.Uint32(attr.Value)) * time.Second
522
+		case ipvsCmdAttrTimeoutTCPFin:
523
+			c.TimeoutTCPFin = time.Duration(native.Uint32(attr.Value)) * time.Second
524
+		case ipvsCmdAttrTimeoutUDP:
525
+			c.TimeoutUDP = time.Duration(native.Uint32(attr.Value)) * time.Second
526
+		}
527
+	}
528
+
529
+	return &c, nil
530
+}
531
+
532
+// doGetConfigCmd a wrapper function to be used by GetConfig
533
+func (i *Handle) doGetConfigCmd() (*Config, error) {
534
+	msg, err := i.doCmdWithoutAttr(ipvsCmdGetConfig)
535
+	if err != nil {
536
+		return nil, err
537
+	}
538
+
539
+	res, err := i.parseConfig(msg[0])
540
+	if err != nil {
541
+		return res, err
542
+	}
543
+	return res, nil
544
+}
545
+
546
+// doSetConfigCmd a wrapper function to be used by SetConfig
547
+func (i *Handle) doSetConfigCmd(c *Config) error {
548
+	req := newIPVSRequest(ipvsCmdSetConfig)
549
+	req.Seq = atomic.AddUint32(&i.seq, 1)
550
+
551
+	req.AddData(nl.NewRtAttr(ipvsCmdAttrTimeoutTCP, nl.Uint32Attr(uint32(c.TimeoutTCP.Seconds()))))
552
+	req.AddData(nl.NewRtAttr(ipvsCmdAttrTimeoutTCPFin, nl.Uint32Attr(uint32(c.TimeoutTCPFin.Seconds()))))
553
+	req.AddData(nl.NewRtAttr(ipvsCmdAttrTimeoutUDP, nl.Uint32Attr(uint32(c.TimeoutUDP.Seconds()))))
554
+
555
+	_, err := execute(i.sock, req, 0)
556
+
557
+	return err
558
+}
559
+
506 560
 // IPVS related netlink message format explained
507 561
 
508 562
 /* EACH NETLINK MSG is of the below format, this is what we will receive from execute() api.
... ...
@@ -94,10 +94,12 @@ func ElectInterfaceAddresses(name string) ([]*net.IPNet, []*net.IPNet, error) {
94 94
 	}
95 95
 
96 96
 	if link == nil || len(v4Nets) == 0 {
97
-		// Choose from predefined local scope  networks
97
+		// Choose from predefined local scope networks
98 98
 		v4Net, err := FindAvailableNetwork(ipamutils.PredefinedLocalScopeDefaultNetworks)
99 99
 		if err != nil {
100
-			return nil, nil, err
100
+			return nil, nil, fmt.Errorf("%s, PredefinedLocalScopeDefaultNetworks List: %+v",
101
+				err.Error(),
102
+				ipamutils.PredefinedLocalScopeDefaultNetworks)
101 103
 		}
102 104
 		v4Nets = append(v4Nets, v4Net)
103 105
 	}
... ...
@@ -396,11 +396,9 @@ func (n *network) validateConfiguration() error {
396 396
 					driverOptions map[string]string
397 397
 					opts          interface{}
398 398
 				)
399
-				switch data.(type) {
400
-				case map[string]interface{}:
401
-					opts = data.(map[string]interface{})
402
-				case map[string]string:
403
-					opts = data.(map[string]string)
399
+				switch t := data.(type) {
400
+				case map[string]interface{}, map[string]string:
401
+					opts = t
404 402
 				}
405 403
 				ba, err := json.Marshal(opts)
406 404
 				if err != nil {
... ...
@@ -288,7 +288,12 @@ func (nDB *NetworkDB) rejoinClusterBootStrap() {
288 288
 		return
289 289
 	}
290 290
 
291
-	myself, _ := nDB.nodes[nDB.config.NodeID]
291
+	myself, ok := nDB.nodes[nDB.config.NodeID]
292
+	if !ok {
293
+		nDB.RUnlock()
294
+		logrus.Warnf("rejoinClusterBootstrap unable to find local node info using ID:%v", nDB.config.NodeID)
295
+		return
296
+	}
292 297
 	bootStrapIPs := make([]string, 0, len(nDB.bootStrapIP))
293 298
 	for _, bootIP := range nDB.bootStrapIP {
294 299
 		// botostrap IPs are usually IP:port from the Join
... ...
@@ -352,7 +357,7 @@ func (nDB *NetworkDB) reconnectNode() {
352 352
 	nDB.bulkSync([]string{node.Name}, true)
353 353
 }
354 354
 
355
-// For timing the entry deletion in the repaer APIs that doesn't use monotonic clock
355
+// For timing the entry deletion in the reaper APIs that doesn't use monotonic clock
356 356
 // source (time.Now, Sub etc.) should be avoided. Hence we use reapTime in every
357 357
 // entry which is set initially to reapInterval and decremented by reapPeriod every time
358 358
 // the reaper runs. NOTE nDB.reapTableEntries updates the reapTime with a readlock. This