Merge pull request #39018 from mavenugo/moby-libn-vndr

Vendor Libnetwork 48f8463
This commit is contained in:
Sebastiaan van Stijn 2019-04-09 21:46:34 +02:00 committed by GitHub
commit ed68d3ab72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 14 deletions

View file

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

View file

@ -95,7 +95,10 @@ func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key stri
return
}
d.peerAdd(nid, eid, addr.IP, addr.Mask, mac, vtep, true)
err = d.peerAdd(nid, eid, addr.IP, addr.Mask, mac, vtep, true)
if err != nil {
logrus.Errorf("peerAdd failed (%v) for ip %s with mac %s", err, addr.IP.String(), mac.String())
}
}
func (d *driver) DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) {

View file

@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net"
"sync"
"github.com/Microsoft/hcsshim"
"github.com/docker/docker/pkg/system"
@ -29,6 +30,13 @@ type endpoint struct {
portMapping []types.PortBinding // Operation port bindings
}
var (
//Server 2016 (RS1) does not support concurrent add/delete of endpoints. Therefore, we need
//to use this mutex and serialize the add/delete of endpoints on RS1.
endpointMu sync.Mutex
windowsBuild = system.GetOSVersion().Build
)
func validateID(nid, eid string) error {
if nid == "" {
return fmt.Errorf("invalid network id")
@ -77,8 +85,7 @@ func (n *network) removeEndpointWithAddress(addr *net.IPNet) {
if networkEndpoint != nil {
logrus.Debugf("Removing stale endpoint from HNS")
_, err := hcsshim.HNSEndpointRequest("DELETE", networkEndpoint.profileID, "")
_, err := endpointRequest("DELETE", networkEndpoint.profileID, "")
if err != nil {
logrus.Debugf("Failed to delete stale overlay endpoint (%.7s) from hns", networkEndpoint.id)
}
@ -101,8 +108,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
if ep != nil {
logrus.Debugf("Deleting stale endpoint %s", eid)
n.deleteEndpoint(eid)
_, err := hcsshim.HNSEndpointRequest("DELETE", ep.profileID, "")
_, err := endpointRequest("DELETE", ep.profileID, "")
if err != nil {
return err
}
@ -179,7 +185,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
return err
}
hnsresponse, err := hcsshim.HNSEndpointRequest("POST", "", string(configurationb))
hnsresponse, err := endpointRequest("POST", "", string(configurationb))
if err != nil {
return err
}
@ -199,7 +205,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
ep.portMapping, err = windows.ParsePortBindingPolicies(hnsresponse.Policies)
if err != nil {
hcsshim.HNSEndpointRequest("DELETE", hnsresponse.Id, "")
endpointRequest("DELETE", hnsresponse.Id, "")
return err
}
@ -225,7 +231,7 @@ func (d *driver) DeleteEndpoint(nid, eid string) error {
n.deleteEndpoint(eid)
_, err := hcsshim.HNSEndpointRequest("DELETE", ep.profileID, "")
_, err := endpointRequest("DELETE", ep.profileID, "")
if err != nil {
return err
}
@ -263,3 +269,14 @@ func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, erro
return data, nil
}
func endpointRequest(method, path, request string) (*hcsshim.HNSEndpoint, error) {
if windowsBuild == 14393 {
endpointMu.Lock()
}
hnsresponse, err := hcsshim.HNSEndpointRequest(method, path, request)
if windowsBuild == 14393 {
endpointMu.Unlock()
}
return hnsresponse, err
}

View file

@ -67,8 +67,7 @@ func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
}
n.removeEndpointWithAddress(addr)
hnsresponse, err := hcsshim.HNSEndpointRequest("POST", "", string(configurationb))
hnsresponse, err := endpointRequest("POST", "", string(configurationb))
if err != nil {
return err
}
@ -108,7 +107,7 @@ func (d *driver) peerDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMas
}
if updateDb {
_, err := hcsshim.HNSEndpointRequest("DELETE", ep.profileID, "")
_, err := endpointRequest("DELETE", ep.profileID, "")
if err != nil {
return err
}

View file

@ -13,6 +13,7 @@ import (
"github.com/docker/libnetwork/osl"
"github.com/docker/libnetwork/resolvconf"
"github.com/docker/libnetwork/types"
"github.com/pkg/errors"
"github.com/vishvananda/netlink"
)
@ -97,8 +98,7 @@ func ElectInterfaceAddresses(name string) ([]*net.IPNet, []*net.IPNet, error) {
// Choose from predefined local scope networks
v4Net, err := FindAvailableNetwork(ipamutils.PredefinedLocalScopeDefaultNetworks)
if err != nil {
return nil, nil, fmt.Errorf("%s, PredefinedLocalScopeDefaultNetworks List: %+v",
err.Error(),
return nil, nil, errors.Wrapf(err, "PredefinedLocalScopeDefaultNetworks List: %+v",
ipamutils.PredefinedLocalScopeDefaultNetworks)
}
v4Nets = append(v4Nets, v4Net)