зеркало из https://github.com/microsoft/docker.git
Vendor in docker/libnetwork.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
This commit is contained in:
Родитель
d89fb40e1c
Коммит
2b0f0d0d71
|
@ -70,7 +70,7 @@ clone git github.com/RackSec/srslog 365bf33cd9acc21ae1c355209865f17228ca534e
|
|||
clone git github.com/imdario/mergo 0.2.1
|
||||
|
||||
#get libnetwork packages
|
||||
clone git github.com/docker/libnetwork bf3d9ccfb8ebf768843691143c66d137743cc5e9
|
||||
clone git github.com/docker/libnetwork 66764992b5bff765a5aa2318ca3768ad22c4ce95
|
||||
clone git github.com/docker/go-events 18b43f1bc85d9cdd42c05a6cd2d444c7a200a894
|
||||
clone git github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
|
||||
clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
|
||||
|
|
|
@ -191,8 +191,7 @@ func (c *controller) agentSetup() error {
|
|||
|
||||
if remoteAddr != "" {
|
||||
if err := c.agentJoin(remoteAddr); err != nil {
|
||||
logrus.Errorf("Error in agentJoin : %v", err)
|
||||
return nil
|
||||
logrus.Errorf("Error in joining gossip cluster : %v(join will be retried in background)", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/BurntSushi/toml"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/pkg/discovery"
|
||||
"github.com/docker/docker/plugin/getter"
|
||||
"github.com/docker/go-connections/tlsconfig"
|
||||
"github.com/docker/libkv/store"
|
||||
"github.com/docker/libnetwork/cluster"
|
||||
|
@ -20,6 +21,7 @@ type Config struct {
|
|||
Cluster ClusterCfg
|
||||
Scopes map[string]*datastore.ScopeCfg
|
||||
ActiveSandboxes map[string]interface{}
|
||||
PluginGetter getter.PluginGetter
|
||||
}
|
||||
|
||||
// DaemonCfg represents libnetwork core configuration
|
||||
|
@ -205,6 +207,13 @@ func OptionExecRoot(execRoot string) Option {
|
|||
}
|
||||
}
|
||||
|
||||
// OptionPluginGetter returns a plugingetter for remote drivers.
|
||||
func OptionPluginGetter(pg getter.PluginGetter) Option {
|
||||
return func(c *Config) {
|
||||
c.PluginGetter = pg
|
||||
}
|
||||
}
|
||||
|
||||
// ProcessOptions processes options and stores it in config
|
||||
func (c *Config) ProcessOptions(options ...Option) {
|
||||
for _, opt := range options {
|
||||
|
|
|
@ -55,6 +55,7 @@ import (
|
|||
"github.com/docker/docker/pkg/locker"
|
||||
"github.com/docker/docker/pkg/plugins"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/docker/docker/plugin/getter"
|
||||
"github.com/docker/libnetwork/cluster"
|
||||
"github.com/docker/libnetwork/config"
|
||||
"github.com/docker/libnetwork/datastore"
|
||||
|
@ -178,7 +179,7 @@ func New(cfgOptions ...config.Option) (NetworkController, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
drvRegistry, err := drvregistry.New(c.getStore(datastore.LocalScope), c.getStore(datastore.GlobalScope), c.RegisterDriver, nil)
|
||||
drvRegistry, err := drvregistry.New(c.getStore(datastore.LocalScope), c.getStore(datastore.GlobalScope), c.RegisterDriver, nil, c.cfg.PluginGetter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -601,6 +602,10 @@ func (c *controller) isDistributedControl() bool {
|
|||
return !c.isManager() && !c.isAgent()
|
||||
}
|
||||
|
||||
func (c *controller) GetPluginGetter() getter.PluginGetter {
|
||||
return c.drvRegistry.GetPluginGetter()
|
||||
}
|
||||
|
||||
func (c *controller) RegisterDriver(networkType string, driver driverapi.Driver, capability driverapi.Capability) error {
|
||||
c.Lock()
|
||||
hd := c.discovery
|
||||
|
@ -1074,7 +1079,7 @@ func (c *controller) loadDriver(networkType string) error {
|
|||
}
|
||||
|
||||
func (c *controller) loadIPAMDriver(name string) error {
|
||||
if _, err := plugins.Get(name, ipamapi.PluginEndpointType); err != nil {
|
||||
if _, err := c.GetPluginGetter().Get(name, ipamapi.PluginEndpointType, getter.LOOKUP); err != nil {
|
||||
if err == plugins.ErrNotFound {
|
||||
return types.NotFoundErrorf(err.Error())
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package driverapi
|
|||
import (
|
||||
"net"
|
||||
|
||||
"github.com/docker/docker/plugin/getter"
|
||||
"github.com/docker/libnetwork/discoverapi"
|
||||
)
|
||||
|
||||
|
@ -139,6 +140,8 @@ type JoinInfo interface {
|
|||
|
||||
// DriverCallback provides a Callback interface for Drivers into LibNetwork
|
||||
type DriverCallback interface {
|
||||
// GetPluginGetter returns the pluginv2 getter.
|
||||
GetPluginGetter() getter.PluginGetter
|
||||
// RegisterDriver provides a way for Remote drivers to dynamically register new NetworkType and associate with a driver instance
|
||||
RegisterDriver(name string, driver Driver, capability Capability) error
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ type configuration struct {
|
|||
EnableIPForwarding bool
|
||||
EnableIPTables bool
|
||||
EnableUserlandProxy bool
|
||||
UserlandProxyPath string
|
||||
}
|
||||
|
||||
// networkConfiguration for network specific configuration
|
||||
|
@ -638,7 +639,7 @@ func (d *driver) createNetwork(config *networkConfiguration) error {
|
|||
id: config.ID,
|
||||
endpoints: make(map[string]*bridgeEndpoint),
|
||||
config: config,
|
||||
portMapper: portmapper.New(),
|
||||
portMapper: portmapper.New(d.config.UserlandProxyPath),
|
||||
driver: d,
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,12 @@ func newDriver(name string, client *plugins.Client) driverapi.Driver {
|
|||
// Init makes sure a remote driver is registered when a network driver
|
||||
// plugin is activated.
|
||||
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
|
||||
plugins.Handle(driverapi.NetworkPluginEndpointType, func(name string, client *plugins.Client) {
|
||||
// Unit test code is unaware of a true PluginStore. So we fall back to v1 plugins.
|
||||
handleFunc := plugins.Handle
|
||||
if pg := dc.GetPluginGetter(); pg != nil {
|
||||
handleFunc = pg.Handle
|
||||
}
|
||||
handleFunc(driverapi.NetworkPluginEndpointType, func(name string, client *plugins.Client) {
|
||||
// negotiate driver capability with client
|
||||
d := newDriver(name, client)
|
||||
c, err := d.(*driver).getCapabilities()
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/docker/docker/plugin/getter"
|
||||
"github.com/docker/libnetwork/driverapi"
|
||||
"github.com/docker/libnetwork/ipamapi"
|
||||
"github.com/docker/libnetwork/types"
|
||||
|
@ -28,10 +29,11 @@ type ipamTable map[string]*ipamData
|
|||
// DrvRegistry holds the registry of all network drivers and IPAM drivers that it knows about.
|
||||
type DrvRegistry struct {
|
||||
sync.Mutex
|
||||
drivers driverTable
|
||||
ipamDrivers ipamTable
|
||||
dfn DriverNotifyFunc
|
||||
ifn IPAMNotifyFunc
|
||||
drivers driverTable
|
||||
ipamDrivers ipamTable
|
||||
dfn DriverNotifyFunc
|
||||
ifn IPAMNotifyFunc
|
||||
pluginGetter getter.PluginGetter
|
||||
}
|
||||
|
||||
// Functors definition
|
||||
|
@ -52,12 +54,13 @@ type IPAMNotifyFunc func(name string, driver ipamapi.Ipam, cap *ipamapi.Capabili
|
|||
type DriverNotifyFunc func(name string, driver driverapi.Driver, capability driverapi.Capability) error
|
||||
|
||||
// New retruns a new driver registry handle.
|
||||
func New(lDs, gDs interface{}, dfn DriverNotifyFunc, ifn IPAMNotifyFunc) (*DrvRegistry, error) {
|
||||
func New(lDs, gDs interface{}, dfn DriverNotifyFunc, ifn IPAMNotifyFunc, pg getter.PluginGetter) (*DrvRegistry, error) {
|
||||
r := &DrvRegistry{
|
||||
drivers: make(driverTable),
|
||||
ipamDrivers: make(ipamTable),
|
||||
dfn: dfn,
|
||||
ifn: ifn,
|
||||
drivers: make(driverTable),
|
||||
ipamDrivers: make(ipamTable),
|
||||
dfn: dfn,
|
||||
ifn: ifn,
|
||||
pluginGetter: pg,
|
||||
}
|
||||
|
||||
return r, nil
|
||||
|
@ -149,6 +152,11 @@ func (r *DrvRegistry) IPAMDefaultAddressSpaces(name string) (string, string, err
|
|||
return i.defaultLocalAddressSpace, i.defaultGlobalAddressSpace, nil
|
||||
}
|
||||
|
||||
// GetPluginGetter returns the plugingetter
|
||||
func (r *DrvRegistry) GetPluginGetter() getter.PluginGetter {
|
||||
return r.pluginGetter
|
||||
}
|
||||
|
||||
// RegisterDriver registers the network driver when it gets discovered.
|
||||
func (r *DrvRegistry) RegisterDriver(ntype string, driver driverapi.Driver, capability driverapi.Capability) error {
|
||||
if strings.TrimSpace(ntype) == "" {
|
||||
|
|
|
@ -4,6 +4,7 @@ package ipamapi
|
|||
import (
|
||||
"net"
|
||||
|
||||
"github.com/docker/docker/plugin/getter"
|
||||
"github.com/docker/libnetwork/discoverapi"
|
||||
"github.com/docker/libnetwork/types"
|
||||
)
|
||||
|
@ -25,6 +26,8 @@ const (
|
|||
|
||||
// Callback provides a Callback interface for registering an IPAM instance into LibNetwork
|
||||
type Callback interface {
|
||||
// GetPluginGetter returns the pluginv2 getter.
|
||||
GetPluginGetter() getter.PluginGetter
|
||||
// RegisterIpamDriver provides a way for Remote drivers to dynamically register with libnetwork
|
||||
RegisterIpamDriver(name string, driver Ipam) error
|
||||
// RegisterIpamDriverWithCapabilities provides a way for Remote drivers to dynamically register with libnetwork and specify capabilities
|
||||
|
|
|
@ -30,7 +30,13 @@ func newAllocator(name string, client *plugins.Client) ipamapi.Ipam {
|
|||
|
||||
// Init registers a remote ipam when its plugin is activated
|
||||
func Init(cb ipamapi.Callback, l, g interface{}) error {
|
||||
plugins.Handle(ipamapi.PluginEndpointType, func(name string, client *plugins.Client) {
|
||||
|
||||
// Unit test code is unaware of a true PluginStore. So we fall back to v1 plugins.
|
||||
handleFunc := plugins.Handle
|
||||
if pg := cb.GetPluginGetter(); pg != nil {
|
||||
handleFunc = pg.Handle
|
||||
}
|
||||
handleFunc(ipamapi.PluginEndpointType, func(name string, client *plugins.Client) {
|
||||
a := newAllocator(name, client)
|
||||
if cps, err := a.(*allocator).getCapabilities(); err == nil {
|
||||
if err := cb.RegisterIpamDriverWithCapabilities(name, a, cps); err != nil {
|
||||
|
|
|
@ -161,6 +161,10 @@ func (nDB *NetworkDB) retryJoin(members []string, stop <-chan struct{}) {
|
|||
logrus.Errorf("Failed to join memberlist %s on retry: %v", members, err)
|
||||
continue
|
||||
}
|
||||
if err := nDB.sendNodeEvent(NodeEventTypeJoin); err != nil {
|
||||
logrus.Errorf("failed to send node join on retry: %v", err)
|
||||
continue
|
||||
}
|
||||
return
|
||||
case <-stop:
|
||||
return
|
||||
|
|
|
@ -38,19 +38,22 @@ type PortMapper struct {
|
|||
currentMappings map[string]*mapping
|
||||
lock sync.Mutex
|
||||
|
||||
proxyPath string
|
||||
|
||||
Allocator *portallocator.PortAllocator
|
||||
}
|
||||
|
||||
// New returns a new instance of PortMapper
|
||||
func New() *PortMapper {
|
||||
return NewWithPortAllocator(portallocator.Get())
|
||||
func New(proxyPath string) *PortMapper {
|
||||
return NewWithPortAllocator(portallocator.Get(), proxyPath)
|
||||
}
|
||||
|
||||
// NewWithPortAllocator returns a new instance of PortMapper which will use the specified PortAllocator
|
||||
func NewWithPortAllocator(allocator *portallocator.PortAllocator) *PortMapper {
|
||||
func NewWithPortAllocator(allocator *portallocator.PortAllocator, proxyPath string) *PortMapper {
|
||||
return &PortMapper{
|
||||
currentMappings: make(map[string]*mapping),
|
||||
Allocator: allocator,
|
||||
proxyPath: proxyPath,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +93,7 @@ func (pm *PortMapper) MapRange(container net.Addr, hostIP net.IP, hostPortStart,
|
|||
}
|
||||
|
||||
if useProxy {
|
||||
m.userlandProxy, err = newProxy(proto, hostIP, allocatedHostPort, container.(*net.TCPAddr).IP, container.(*net.TCPAddr).Port)
|
||||
m.userlandProxy, err = newProxy(proto, hostIP, allocatedHostPort, container.(*net.TCPAddr).IP, container.(*net.TCPAddr).Port, pm.proxyPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -110,7 +113,7 @@ func (pm *PortMapper) MapRange(container net.Addr, hostIP net.IP, hostPortStart,
|
|||
}
|
||||
|
||||
if useProxy {
|
||||
m.userlandProxy, err = newProxy(proto, hostIP, allocatedHostPort, container.(*net.UDPAddr).IP, container.(*net.UDPAddr).Port)
|
||||
m.userlandProxy, err = newProxy(proto, hostIP, allocatedHostPort, container.(*net.UDPAddr).IP, container.(*net.UDPAddr).Port, pm.proxyPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package portmapper
|
|||
|
||||
import "net"
|
||||
|
||||
func newMockProxyCommand(proto string, hostIP net.IP, hostPort int, containerIP net.IP, containerPort int) (userlandProxy, error) {
|
||||
func newMockProxyCommand(proto string, hostIP net.IP, hostPort int, containerIP net.IP, containerPort int, userlandProxyPath string) (userlandProxy, error) {
|
||||
return &mockProxyCommand{}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -25,15 +25,18 @@ type proxyCommand struct {
|
|||
cmd *exec.Cmd
|
||||
}
|
||||
|
||||
func newProxyCommand(proto string, hostIP net.IP, hostPort int, containerIP net.IP, containerPort int) (userlandProxy, error) {
|
||||
cmd, err := exec.LookPath(userlandProxyCommandName)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
func newProxyCommand(proto string, hostIP net.IP, hostPort int, containerIP net.IP, containerPort int, proxyPath string) (userlandProxy, error) {
|
||||
path := proxyPath
|
||||
if proxyPath == "" {
|
||||
cmd, err := exec.LookPath(userlandProxyCommandName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
path = cmd
|
||||
}
|
||||
|
||||
args := []string{
|
||||
cmd,
|
||||
path,
|
||||
"-proto", proto,
|
||||
"-host-ip", hostIP.String(),
|
||||
"-host-port", strconv.Itoa(hostPort),
|
||||
|
@ -43,7 +46,7 @@ func newProxyCommand(proto string, hostIP net.IP, hostPort int, containerIP net.
|
|||
|
||||
return &proxyCommand{
|
||||
cmd: &exec.Cmd{
|
||||
Path: cmd,
|
||||
Path: path,
|
||||
Args: args,
|
||||
SysProcAttr: &syscall.SysProcAttr{
|
||||
Pdeathsig: syscall.SIGTERM, // send a sigterm to the proxy if the daemon process dies
|
||||
|
|
Загрузка…
Ссылка в новой задаче