Browse code

Update libnetwork to 4df06c4

This fixes docker #28931, #28172, #28969

Signed-off-by: Santhosh Manohar <santhosh@docker.com>

Santhosh Manohar authored on 2016/12/13 04:40:14
Showing 12 changed files
... ...
@@ -23,7 +23,7 @@ github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5
23 23
 github.com/imdario/mergo 0.2.1
24 24
 
25 25
 #get libnetwork packages
26
-github.com/docker/libnetwork fd27f22aaa35e3d57f88688f919d05b744f431fd
26
+github.com/docker/libnetwork 4df06c4a7d9b67d0948eab39c5d013d7296acdbf
27 27
 github.com/docker/go-events 18b43f1bc85d9cdd42c05a6cd2d444c7a200a894
28 28
 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
29 29
 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
... ...
@@ -1,5 +1,5 @@
1 1
 // Package bitseq provides a structure and utilities for representing long bitmask
2
-// as sequence of run-lenght encoded blocks. It operates direclty on the encoded
2
+// as sequence of run-length encoded blocks. It operates directly on the encoded
3 3
 // representation, it does not decode/encode.
4 4
 package bitseq
5 5
 
... ...
@@ -312,7 +312,7 @@ func (c *controller) clusterAgentInit() {
312 312
 				c.clusterConfigAvailable = true
313 313
 				keys := c.keys
314 314
 				c.Unlock()
315
-				// agent initialization needs encyrption keys and bind/remote IP which
315
+				// agent initialization needs encryption keys and bind/remote IP which
316 316
 				// comes from the daemon cluster events
317 317
 				if len(keys) > 0 {
318 318
 					c.agentSetup()
... ...
@@ -786,7 +786,7 @@ func (c *controller) reservePools() {
786 786
 		}
787 787
 		for _, ep := range epl {
788 788
 			if err := ep.assignAddress(ipam, true, ep.Iface().AddressIPv6() != nil); err != nil {
789
-				logrus.Warnf("Failed to reserve current adress for endpoint %q (%s) on network %q (%s)",
789
+				logrus.Warnf("Failed to reserve current address for endpoint %q (%s) on network %q (%s)",
790 790
 					ep.Name(), ep.ID(), n.Name(), n.ID())
791 791
 			}
792 792
 		}
... ...
@@ -2,9 +2,10 @@ package bridge
2 2
 
3 3
 import (
4 4
 	"fmt"
5
-	log "github.com/Sirupsen/logrus"
6
-	"github.com/docker/libnetwork/iptables"
7 5
 	"io/ioutil"
6
+
7
+	"github.com/Sirupsen/logrus"
8
+	"github.com/docker/libnetwork/iptables"
8 9
 )
9 10
 
10 11
 const (
... ...
@@ -40,14 +41,14 @@ func setupIPForwarding(enableIPTables bool) error {
40 40
 		}
41 41
 		if err := iptables.SetDefaultPolicy(iptables.Filter, "FORWARD", iptables.Drop); err != nil {
42 42
 			if err := configureIPForwarding(false); err != nil {
43
-				log.Errorf("Disabling IP forwarding failed, %v", err)
43
+				logrus.Errorf("Disabling IP forwarding failed, %v", err)
44 44
 			}
45 45
 			return err
46 46
 		}
47 47
 		iptables.OnReloaded(func() {
48
-			log.Debugf("Setting the default DROP policy on firewall reload")
48
+			logrus.Debug("Setting the default DROP policy on firewall reload")
49 49
 			if err := iptables.SetDefaultPolicy(iptables.Filter, "FORWARD", iptables.Drop); err != nil {
50
-				log.Warnf("Settig the default DROP policy on firewall reload failed, %v", err)
50
+				logrus.Warnf("Settig the default DROP policy on firewall reload failed, %v", err)
51 51
 			}
52 52
 		})
53 53
 	}
... ...
@@ -71,7 +71,7 @@ func (n *bridgeNetwork) setupIPTables(config *networkConfiguration, i *bridgeInt
71 71
 		return fmt.Errorf("Cannot program chains, EnableIPTable is disabled")
72 72
 	}
73 73
 
74
-	// Pickup this configuraton option from driver
74
+	// Pickup this configuration option from driver
75 75
 	hairpinMode := !driverConfig.EnableUserlandProxy
76 76
 
77 77
 	maskedAddrv4 := &net.IPNet{
... ...
@@ -99,7 +99,7 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
99 99
 	// outside of the restore path can potentially fix the network join and succeed.
100 100
 	for nid, n := range d.networks {
101 101
 		if n.initErr != nil {
102
-			logrus.Infof("resetting init error and once variable for network %s after unsuccesful endpoint restore: %v", nid, n.initErr)
102
+			logrus.Infof("resetting init error and once variable for network %s after unsuccessful endpoint restore: %v", nid, n.initErr)
103 103
 			n.initErr = nil
104 104
 			n.once = &sync.Once{}
105 105
 		}
... ...
@@ -993,7 +993,7 @@ func (c *networkConfiguration) Conflicts(o *networkConfiguration) error {
993 993
 		return fmt.Errorf("same configuration")
994 994
 	}
995 995
 
996
-	// Also empty, becasue only one network with empty name is allowed
996
+	// Also empty, because only one network with empty name is allowed
997 997
 	if c.BridgeName == o.BridgeName {
998 998
 		return fmt.Errorf("networks have same bridge name")
999 999
 	}
... ...
@@ -47,7 +47,7 @@ type Handle struct {
47 47
 
48 48
 // New provides a new ipvs handle in the namespace pointed to by the
49 49
 // passed path. It will return a valid handle or an error in case an
50
-// error occured while creating the handle.
50
+// error occurred while creating the handle.
51 51
 func New(path string) (*Handle, error) {
52 52
 	setup()
53 53
 
... ...
@@ -54,7 +54,7 @@ func (n *network) startResolver() {
54 54
 						logrus.Errorf("Resolver Setup/Start failed for container %s, %q", n.Name(), err)
55 55
 						time.Sleep(1 * time.Second)
56 56
 					} else {
57
-						logrus.Debugf("Resolver bound successfuly for network %s", n.Name())
57
+						logrus.Debugf("Resolver bound successfully for network %s", n.Name())
58 58
 						n.resolver = append(n.resolver, resolver)
59 59
 						break
60 60
 					}
... ...
@@ -5,6 +5,7 @@ import (
5 5
 	"crypto/rand"
6 6
 	"encoding/hex"
7 7
 	"fmt"
8
+	"log"
8 9
 	"math/big"
9 10
 	rnd "math/rand"
10 11
 	"net"
... ...
@@ -27,15 +28,20 @@ type logWriter struct{}
27 27
 
28 28
 func (l *logWriter) Write(p []byte) (int, error) {
29 29
 	str := string(p)
30
+	str = strings.TrimSuffix(str, "\n")
30 31
 
31 32
 	switch {
32
-	case strings.Contains(str, "[WARN]"):
33
+	case strings.HasPrefix(str, "[WARN] "):
34
+		str = strings.TrimPrefix(str, "[WARN] ")
33 35
 		logrus.Warn(str)
34
-	case strings.Contains(str, "[DEBUG]"):
36
+	case strings.HasPrefix(str, "[DEBUG] "):
37
+		str = strings.TrimPrefix(str, "[DEBUG] ")
35 38
 		logrus.Debug(str)
36
-	case strings.Contains(str, "[INFO]"):
39
+	case strings.HasPrefix(str, "[INFO] "):
40
+		str = strings.TrimPrefix(str, "[INFO] ")
37 41
 		logrus.Info(str)
38
-	case strings.Contains(str, "[ERR]"):
42
+	case strings.HasPrefix(str, "[ERR] "):
43
+		str = strings.TrimPrefix(str, "[ERR] ")
39 44
 		logrus.Warn(str)
40 45
 	}
41 46
 
... ...
@@ -104,7 +110,9 @@ func (nDB *NetworkDB) clusterInit() error {
104 104
 	config.ProtocolVersion = memberlist.ProtocolVersionMax
105 105
 	config.Delegate = &delegate{nDB: nDB}
106 106
 	config.Events = &eventDelegate{nDB: nDB}
107
-	config.LogOutput = &logWriter{}
107
+	// custom logger that does not add time or date, so they are not
108
+	// duplicated by logrus
109
+	config.Logger = log.New(&logWriter{}, "", 0)
108 110
 
109 111
 	var err error
110 112
 	if len(nDB.config.Keys) > 0 {
... ...
@@ -211,10 +211,12 @@ func (nDB *NetworkDB) Peers(nid string) []PeerInfo {
211 211
 	defer nDB.RUnlock()
212 212
 	peers := make([]PeerInfo, 0, len(nDB.networkNodes[nid]))
213 213
 	for _, nodeName := range nDB.networkNodes[nid] {
214
-		peers = append(peers, PeerInfo{
215
-			Name: nDB.nodes[nodeName].Name,
216
-			IP:   nDB.nodes[nodeName].Addr.String(),
217
-		})
214
+		if node, ok := nDB.nodes[nodeName]; ok {
215
+			peers = append(peers, PeerInfo{
216
+				Name: node.Name,
217
+				IP:   node.Addr.String(),
218
+			})
219
+		}
218 220
 	}
219 221
 	return peers
220 222
 }
... ...
@@ -244,7 +246,7 @@ func (nDB *NetworkDB) getEntry(tname, nid, key string) (*entry, error) {
244 244
 
245 245
 // CreateEntry creates a table entry in NetworkDB for given (network,
246 246
 // table, key) tuple and if the NetworkDB is part of the cluster
247
-// propogates this event to the cluster. It is an error to create an
247
+// propagates this event to the cluster. It is an error to create an
248 248
 // entry for the same tuple for which there is already an existing
249 249
 // entry unless the current entry is deleting state.
250 250
 func (nDB *NetworkDB) CreateEntry(tname, nid, key string, value []byte) error {
... ...
@@ -279,7 +281,7 @@ func (nDB *NetworkDB) CreateEntry(tname, nid, key string, value []byte) error {
279 279
 
280 280
 // UpdateEntry updates a table entry in NetworkDB for given (network,
281 281
 // table, key) tuple and if the NetworkDB is part of the cluster
282
-// propogates this event to the cluster. It is an error to update a
282
+// propagates this event to the cluster. It is an error to update a
283 283
 // non-existent entry.
284 284
 func (nDB *NetworkDB) UpdateEntry(tname, nid, key string, value []byte) error {
285 285
 	if _, err := nDB.GetEntry(tname, nid, key); err != nil {
... ...
@@ -307,7 +309,7 @@ func (nDB *NetworkDB) UpdateEntry(tname, nid, key string, value []byte) error {
307 307
 
308 308
 // DeleteEntry deletes a table entry in NetworkDB for given (network,
309 309
 // table, key) tuple and if the NetworkDB is part of the cluster
310
-// propogates this event to the cluster.
310
+// propagates this event to the cluster.
311 311
 func (nDB *NetworkDB) DeleteEntry(tname, nid, key string) error {
312 312
 	value, err := nDB.GetEntry(tname, nid, key)
313 313
 	if err != nil {
... ...
@@ -408,7 +410,7 @@ func (nDB *NetworkDB) WalkTable(tname string, fn func(string, string, []byte) bo
408 408
 	return nil
409 409
 }
410 410
 
411
-// JoinNetwork joins this node to a given network and propogates this
411
+// JoinNetwork joins this node to a given network and propagates this
412 412
 // event across the cluster. This triggers this node joining the
413 413
 // sub-cluster of this network and participates in the network-scoped
414 414
 // gossip and bulk sync for this network.
... ...
@@ -447,7 +449,7 @@ func (nDB *NetworkDB) JoinNetwork(nid string) error {
447 447
 	return nil
448 448
 }
449 449
 
450
-// LeaveNetwork leaves this node from a given network and propogates
450
+// LeaveNetwork leaves this node from a given network and propagates
451 451
 // this event across the cluster. This triggers this node leaving the
452 452
 // sub-cluster of this network and as a result will no longer
453 453
 // participate in the network-scoped gossip and bulk sync for this
... ...
@@ -25,7 +25,7 @@ var (
25 25
 	// -- e.g. other link-local types -- either won't work in containers or are unnecessary.
26 26
 	// For readability and sufficiency for Docker purposes this seemed more reasonable than a
27 27
 	// 1000+ character regexp with exact and complete IPv6 validation
28
-	ipv6Address = `([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{0,4})`
28
+	ipv6Address = `([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{0,4})(%\w+)?`
29 29
 
30 30
 	localhostNSRegexp = regexp.MustCompile(`(?m)^nameserver\s+` + dns.IPLocalhost + `\s*\n*`)
31 31
 	nsIPv6Regexp      = regexp.MustCompile(`(?m)^nameserver\s+` + ipv6Address + `\s*\n*`)