bump libnetwork to ebcade70ad1059b070d0040d798ecca359bc5fed

full diff: 1a06131fb8...ebcade70ad

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>
This commit is contained in:
Sebastiaan van Stijn 2019-04-01 19:40:09 +02:00
parent d7ab8ad145
commit 3ab093d567
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
14 changed files with 108 additions and 46 deletions

View File

@ -3,7 +3,7 @@
# LIBNETWORK_COMMIT is used to build the docker-userland-proxy binary. When # LIBNETWORK_COMMIT is used to build the docker-userland-proxy binary. When
# updating the binary version, consider updating github.com/docker/libnetwork # updating the binary version, consider updating github.com/docker/libnetwork
# in vendor.conf accordingly # in vendor.conf accordingly
LIBNETWORK_COMMIT=1a06131fb8a047d919f7deaf02a4c414d7884b83 LIBNETWORK_COMMIT=ebcade70ad1059b070d0040d798ecca359bc5fed
install_proxy() { install_proxy() {
case "$1" in case "$1" in

View File

@ -39,7 +39,7 @@ github.com/gofrs/flock 7f43ea2e6a643ad441fc12d0ecc0d3388b300c53 # v0.7.0
#get libnetwork packages #get libnetwork packages
# When updating, also update LIBNETWORK_COMMIT in hack/dockerfile/install/proxy.installer accordingly # When updating, also update LIBNETWORK_COMMIT in hack/dockerfile/install/proxy.installer accordingly
github.com/docker/libnetwork 1a06131fb8a047d919f7deaf02a4c414d7884b83 github.com/docker/libnetwork ebcade70ad1059b070d0040d798ecca359bc5fed
github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9
github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec

View File

@ -378,6 +378,9 @@ func (c *controller) agentClose() {
c.agent = nil c.agent = nil
c.Unlock() c.Unlock()
// when the agent is closed the cluster provider should be cleaned up
c.SetClusterProvider(nil)
if agent == nil { if agent == nil {
return return
} }

View File

@ -181,10 +181,8 @@ func (c *controller) defaultGwNetwork() (Network, error) {
defer func() { <-procGwNetwork }() defer func() { <-procGwNetwork }()
n, err := c.NetworkByName(libnGWNetwork) n, err := c.NetworkByName(libnGWNetwork)
if err != nil { if _, ok := err.(types.NotFoundError); ok {
if _, ok := err.(types.NotFoundError); ok { n, err = c.createGWNetwork()
n, err = c.createGWNetwork()
}
} }
return n, err return n, err
} }

View File

@ -48,7 +48,7 @@ func setupIPForwarding(enableIPTables bool) error {
iptables.OnReloaded(func() { iptables.OnReloaded(func() {
logrus.Debug("Setting the default DROP policy on firewall reload") logrus.Debug("Setting the default DROP policy on firewall reload")
if err := iptables.SetDefaultPolicy(iptables.Filter, "FORWARD", iptables.Drop); err != nil { if err := iptables.SetDefaultPolicy(iptables.Filter, "FORWARD", iptables.Drop); err != nil {
logrus.Warnf("Settig the default DROP policy on firewall reload failed, %v", err) logrus.Warnf("Setting the default DROP policy on firewall reload failed, %v", err)
} }
}) })
} }

View File

@ -7,8 +7,8 @@ import (
) )
var ( var (
mutex sync.RWMutex
vxlanUDPPort uint32 vxlanUDPPort uint32
mutex sync.Mutex
) )
const defaultVXLANUDPPort = 4789 const defaultVXLANUDPPort = 4789
@ -17,11 +17,10 @@ func init() {
vxlanUDPPort = defaultVXLANUDPPort vxlanUDPPort = defaultVXLANUDPPort
} }
// ConfigVXLANUDPPort configures vxlan udp port number. // ConfigVXLANUDPPort configures the VXLAN UDP port (data path port) number.
// If no port is set, the default (4789) is returned. Valid port numbers are
// between 1024 and 49151.
func ConfigVXLANUDPPort(vxlanPort uint32) error { func ConfigVXLANUDPPort(vxlanPort uint32) error {
mutex.Lock()
defer mutex.Unlock()
// if the value comes as 0 by any reason we set it to default value 4789
if vxlanPort == 0 { if vxlanPort == 0 {
vxlanPort = defaultVXLANUDPPort vxlanPort = defaultVXLANUDPPort
} }
@ -31,16 +30,17 @@ func ConfigVXLANUDPPort(vxlanPort uint32) error {
// The Dynamic Ports, aka the Private Ports, from 49152-65535 // The Dynamic Ports, aka the Private Ports, from 49152-65535
// So we can allow range between 1024 to 49151 // So we can allow range between 1024 to 49151
if vxlanPort < 1024 || vxlanPort > 49151 { if vxlanPort < 1024 || vxlanPort > 49151 {
return fmt.Errorf("ConfigVxlanUDPPort Vxlan UDP port number is not in valid range %d", vxlanPort) return fmt.Errorf("VXLAN UDP port number is not in valid range (1024-49151): %d", vxlanPort)
} }
mutex.Lock()
vxlanUDPPort = vxlanPort vxlanUDPPort = vxlanPort
mutex.Unlock()
return nil return nil
} }
// VXLANUDPPort returns Vxlan UDP port number // VXLANUDPPort returns Vxlan UDP port number
func VXLANUDPPort() uint32 { func VXLANUDPPort() uint32 {
mutex.Lock() mutex.RLock()
defer mutex.Unlock() defer mutex.RUnlock()
return vxlanUDPPort return vxlanUDPPort
} }

View File

@ -1,9 +0,0 @@
package libnetwork
import "github.com/docker/libnetwork/drivers/ipvlan"
func additionalDrivers() []initializer {
return []initializer{
{ipvlan.Init, "ipvlan"},
}
}

View File

@ -3,6 +3,7 @@ package libnetwork
import ( import (
"github.com/docker/libnetwork/drivers/bridge" "github.com/docker/libnetwork/drivers/bridge"
"github.com/docker/libnetwork/drivers/host" "github.com/docker/libnetwork/drivers/host"
"github.com/docker/libnetwork/drivers/ipvlan"
"github.com/docker/libnetwork/drivers/macvlan" "github.com/docker/libnetwork/drivers/macvlan"
"github.com/docker/libnetwork/drivers/null" "github.com/docker/libnetwork/drivers/null"
"github.com/docker/libnetwork/drivers/overlay" "github.com/docker/libnetwork/drivers/overlay"
@ -13,14 +14,11 @@ func getInitializers(experimental bool) []initializer {
in := []initializer{ in := []initializer{
{bridge.Init, "bridge"}, {bridge.Init, "bridge"},
{host.Init, "host"}, {host.Init, "host"},
{ipvlan.Init, "ipvlan"},
{macvlan.Init, "macvlan"}, {macvlan.Init, "macvlan"},
{null.Init, "null"}, {null.Init, "null"},
{remote.Init, "remote"},
{overlay.Init, "overlay"}, {overlay.Init, "overlay"},
} {remote.Init, "remote"},
if experimental {
in = append(in, additionalDrivers()...)
} }
return in return in
} }

View File

@ -87,16 +87,11 @@ func initFirewalld() {
} }
func detectIptables() { func detectIptables() {
path, err := exec.LookPath("iptables-legacy") // debian has iptables-legacy and iptables-nft now path, err := exec.LookPath("iptables")
if err != nil { if err != nil {
path, err = exec.LookPath("iptables") return
if err != nil {
return
}
} }
iptablesPath = path iptablesPath = path
supportsXlock = exec.Command(iptablesPath, "--wait", "-L", "-n").Run() == nil supportsXlock = exec.Command(iptablesPath, "--wait", "-L", "-n").Run() == nil
mj, mn, mc, err := GetVersion() mj, mn, mc, err := GetVersion()
if err != nil { if err != nil {

View File

@ -68,6 +68,13 @@ type Destination struct {
// DstStats defines IPVS destination (real server) statistics // DstStats defines IPVS destination (real server) statistics
type DstStats SvcStats type DstStats SvcStats
// Config defines IPVS timeout configuration
type Config struct {
TimeoutTCP time.Duration
TimeoutTCPFin time.Duration
TimeoutUDP time.Duration
}
// Handle provides a namespace specific ipvs handle to program ipvs // Handle provides a namespace specific ipvs handle to program ipvs
// rules. // rules.
type Handle struct { type Handle struct {
@ -188,3 +195,13 @@ func (i *Handle) GetService(s *Service) (*Service, error) {
return res[0], nil return res[0], nil
} }
// GetConfig returns the current timeout configuration
func (i *Handle) GetConfig() (*Config, error) {
return i.doGetConfigCmd()
}
// SetConfig set the current timeout configuration. 0: no change
func (i *Handle) SetConfig(c *Config) error {
return i.doSetConfigCmd(c)
}

View File

@ -12,6 +12,7 @@ import (
"sync" "sync"
"sync/atomic" "sync/atomic"
"syscall" "syscall"
"time"
"unsafe" "unsafe"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -503,6 +504,60 @@ func (i *Handle) doGetDestinationsCmd(s *Service, d *Destination) ([]*Destinatio
return res, nil return res, nil
} }
// parseConfig given a ipvs netlink response this function will respond with a valid config entry, an error otherwise
func (i *Handle) parseConfig(msg []byte) (*Config, error) {
var c Config
//Remove General header for this message
hdr := deserializeGenlMsg(msg)
attrs, err := nl.ParseRouteAttr(msg[hdr.Len():])
if err != nil {
return nil, err
}
for _, attr := range attrs {
attrType := int(attr.Attr.Type)
switch attrType {
case ipvsCmdAttrTimeoutTCP:
c.TimeoutTCP = time.Duration(native.Uint32(attr.Value)) * time.Second
case ipvsCmdAttrTimeoutTCPFin:
c.TimeoutTCPFin = time.Duration(native.Uint32(attr.Value)) * time.Second
case ipvsCmdAttrTimeoutUDP:
c.TimeoutUDP = time.Duration(native.Uint32(attr.Value)) * time.Second
}
}
return &c, nil
}
// doGetConfigCmd a wrapper function to be used by GetConfig
func (i *Handle) doGetConfigCmd() (*Config, error) {
msg, err := i.doCmdWithoutAttr(ipvsCmdGetConfig)
if err != nil {
return nil, err
}
res, err := i.parseConfig(msg[0])
if err != nil {
return res, err
}
return res, nil
}
// doSetConfigCmd a wrapper function to be used by SetConfig
func (i *Handle) doSetConfigCmd(c *Config) error {
req := newIPVSRequest(ipvsCmdSetConfig)
req.Seq = atomic.AddUint32(&i.seq, 1)
req.AddData(nl.NewRtAttr(ipvsCmdAttrTimeoutTCP, nl.Uint32Attr(uint32(c.TimeoutTCP.Seconds()))))
req.AddData(nl.NewRtAttr(ipvsCmdAttrTimeoutTCPFin, nl.Uint32Attr(uint32(c.TimeoutTCPFin.Seconds()))))
req.AddData(nl.NewRtAttr(ipvsCmdAttrTimeoutUDP, nl.Uint32Attr(uint32(c.TimeoutUDP.Seconds()))))
_, err := execute(i.sock, req, 0)
return err
}
// IPVS related netlink message format explained // IPVS related netlink message format explained
/* EACH NETLINK MSG is of the below format, this is what we will receive from execute() api. /* EACH NETLINK MSG is of the below format, this is what we will receive from execute() api.

View File

@ -94,10 +94,12 @@ func ElectInterfaceAddresses(name string) ([]*net.IPNet, []*net.IPNet, error) {
} }
if link == nil || len(v4Nets) == 0 { if link == nil || len(v4Nets) == 0 {
// Choose from predefined local scope networks // Choose from predefined local scope networks
v4Net, err := FindAvailableNetwork(ipamutils.PredefinedLocalScopeDefaultNetworks) v4Net, err := FindAvailableNetwork(ipamutils.PredefinedLocalScopeDefaultNetworks)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, fmt.Errorf("%s, PredefinedLocalScopeDefaultNetworks List: %+v",
err.Error(),
ipamutils.PredefinedLocalScopeDefaultNetworks)
} }
v4Nets = append(v4Nets, v4Net) v4Nets = append(v4Nets, v4Net)
} }

View File

@ -396,11 +396,9 @@ func (n *network) validateConfiguration() error {
driverOptions map[string]string driverOptions map[string]string
opts interface{} opts interface{}
) )
switch data.(type) { switch t := data.(type) {
case map[string]interface{}: case map[string]interface{}, map[string]string:
opts = data.(map[string]interface{}) opts = t
case map[string]string:
opts = data.(map[string]string)
} }
ba, err := json.Marshal(opts) ba, err := json.Marshal(opts)
if err != nil { if err != nil {

View File

@ -288,7 +288,12 @@ func (nDB *NetworkDB) rejoinClusterBootStrap() {
return return
} }
myself, _ := nDB.nodes[nDB.config.NodeID] myself, ok := nDB.nodes[nDB.config.NodeID]
if !ok {
nDB.RUnlock()
logrus.Warnf("rejoinClusterBootstrap unable to find local node info using ID:%v", nDB.config.NodeID)
return
}
bootStrapIPs := make([]string, 0, len(nDB.bootStrapIP)) bootStrapIPs := make([]string, 0, len(nDB.bootStrapIP))
for _, bootIP := range nDB.bootStrapIP { for _, bootIP := range nDB.bootStrapIP {
// botostrap IPs are usually IP:port from the Join // botostrap IPs are usually IP:port from the Join
@ -352,7 +357,7 @@ func (nDB *NetworkDB) reconnectNode() {
nDB.bulkSync([]string{node.Name}, true) nDB.bulkSync([]string{node.Name}, true)
} }
// For timing the entry deletion in the repaer APIs that doesn't use monotonic clock // For timing the entry deletion in the reaper APIs that doesn't use monotonic clock
// source (time.Now, Sub etc.) should be avoided. Hence we use reapTime in every // source (time.Now, Sub etc.) should be avoided. Hence we use reapTime in every
// entry which is set initially to reapInterval and decremented by reapPeriod every time // entry which is set initially to reapInterval and decremented by reapPeriod every time
// the reaper runs. NOTE nDB.reapTableEntries updates the reapTime with a readlock. This // the reaper runs. NOTE nDB.reapTableEntries updates the reapTime with a readlock. This