From b2e609176d1233eb845785dfdd72b4b747171178 Mon Sep 17 00:00:00 2001 From: Madhu Venugopal Date: Wed, 10 Feb 2016 18:09:33 -0800 Subject: [PATCH] Vendor libnetwork v0.7.0-dev.2 - Expose EnableIPV6 option - discoverapi refactoring - Fixed a few typos & docs update - Fixes https://github.com/docker/docker/issues/20140 Signed-off-by: Madhu Venugopal --- hack/vendor.sh | 2 +- .../github.com/docker/libnetwork/CHANGELOG.md | 10 +++- .../github.com/docker/libnetwork/MAINTAINERS | 6 +++ .../docker/libnetwork/config/config.go | 2 +- .../docker/libnetwork/controller.go | 7 +-- .../libnetwork/default_gateway_linux.go | 9 ++-- .../libnetwork/discoverapi/discoverapi.go | 34 ++++++++++++++ .../docker/libnetwork/driverapi/driverapi.go | 28 +++-------- .../libnetwork/drivers/bridge/bridge.go | 5 +- .../docker/libnetwork/drivers/host/host.go | 5 +- .../docker/libnetwork/drivers/null/null.go | 5 +- .../libnetwork/drivers/overlay/overlay.go | 16 ++----- .../libnetwork/drivers/remote/api/api.go | 3 +- .../libnetwork/drivers/remote/driver.go | 9 ++-- .../libnetwork/drivers/windows/windows.go | 5 +- .../github.com/docker/libnetwork/endpoint.go | 6 +-- .../docker/libnetwork/ipam/allocator.go | 2 +- .../docker/libnetwork/ipamapi/contract.go | 2 +- .../github.com/docker/libnetwork/network.go | 47 +++++++++++++------ .../github.com/docker/libnetwork/sandbox.go | 2 +- .../src/github.com/docker/libnetwork/store.go | 5 +- 21 files changed, 132 insertions(+), 78 deletions(-) create mode 100644 vendor/src/github.com/docker/libnetwork/discoverapi/discoverapi.go diff --git a/hack/vendor.sh b/hack/vendor.sh index 17a3847b89..b858a879f7 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -29,7 +29,7 @@ clone git github.com/RackSec/srslog 6eb773f331e46fbba8eecb8e794e635e75fc04de clone git github.com/imdario/mergo 0.2.1 #get libnetwork packages -clone git github.com/docker/libnetwork v0.6.1-rc2 +clone git github.com/docker/libnetwork v0.7.0-dev.2 clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec clone git github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b clone git github.com/hashicorp/memberlist 9a1e242e454d2443df330bdd51a436d5a9058fc4 diff --git a/vendor/src/github.com/docker/libnetwork/CHANGELOG.md b/vendor/src/github.com/docker/libnetwork/CHANGELOG.md index 2c66eaa575..177eee6c79 100644 --- a/vendor/src/github.com/docker/libnetwork/CHANGELOG.md +++ b/vendor/src/github.com/docker/libnetwork/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.7.0-dev.2 (2016-02-11) +- Fixes https://github.com/docker/docker/issues/20140 + +## 0.7.0-dev.1 (2016-02-10) +- Expose EnableIPV6 option +- discoverapi refactoring +- Fixed a few typos & docs update + ## 0.6.1-rc2 (2016-02-09) - Fixes https://github.com/docker/docker/issues/20132 - Fixes https://github.com/docker/docker/issues/20140 @@ -87,6 +95,6 @@ - Fixed a bunch of issues with osl namespace mgmt ## 0.3.0 (2015-05-27) - + - Introduce CNM (Container Networking Model) - Replace docker networking with CNM & Bridge driver diff --git a/vendor/src/github.com/docker/libnetwork/MAINTAINERS b/vendor/src/github.com/docker/libnetwork/MAINTAINERS index 33f2dd2e18..1e68125010 100644 --- a/vendor/src/github.com/docker/libnetwork/MAINTAINERS +++ b/vendor/src/github.com/docker/libnetwork/MAINTAINERS @@ -16,6 +16,7 @@ "icecrime", "mrjana", "mavenugo", + "sanimej", ] [people] @@ -50,3 +51,8 @@ Name = "Madhu Venugopal" Email = "madhu@docker.com" GitHub = "mavenugo" + + [people.sanimej] + Name = "Santhosh Manohar" + Email = "santhosh@docker.com" + GitHub = "sanimej" diff --git a/vendor/src/github.com/docker/libnetwork/config/config.go b/vendor/src/github.com/docker/libnetwork/config/config.go index 80d2fc3af7..320eb39e00 100644 --- a/vendor/src/github.com/docker/libnetwork/config/config.go +++ b/vendor/src/github.com/docker/libnetwork/config/config.go @@ -61,7 +61,7 @@ func ParseConfig(tomlCfgFile string) (*Config, error) { return cfg, nil } -// Option is a option setter function type used to pass varios configurations +// Option is an option setter function type used to pass various configurations // to the controller type Option func(c *Config) diff --git a/vendor/src/github.com/docker/libnetwork/controller.go b/vendor/src/github.com/docker/libnetwork/controller.go index ef214fd2ce..274eab2861 100644 --- a/vendor/src/github.com/docker/libnetwork/controller.go +++ b/vendor/src/github.com/docker/libnetwork/controller.go @@ -56,6 +56,7 @@ import ( "github.com/docker/docker/pkg/stringid" "github.com/docker/libnetwork/config" "github.com/docker/libnetwork/datastore" + "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/hostdiscovery" "github.com/docker/libnetwork/ipamapi" @@ -288,12 +289,12 @@ func (c *controller) pushNodeDiscovery(d *driverData, nodes []net.IP, add bool) return } for _, node := range nodes { - nodeData := driverapi.NodeDiscoveryData{Address: node.String(), Self: node.Equal(self)} + nodeData := discoverapi.NodeDiscoveryData{Address: node.String(), Self: node.Equal(self)} var err error if add { - err = d.driver.DiscoverNew(driverapi.NodeDiscovery, nodeData) + err = d.driver.DiscoverNew(discoverapi.NodeDiscovery, nodeData) } else { - err = d.driver.DiscoverDelete(driverapi.NodeDiscovery, nodeData) + err = d.driver.DiscoverDelete(discoverapi.NodeDiscovery, nodeData) } if err != nil { log.Debugf("discovery notification error : %v", err) diff --git a/vendor/src/github.com/docker/libnetwork/default_gateway_linux.go b/vendor/src/github.com/docker/libnetwork/default_gateway_linux.go index c7f812778f..9376922a21 100644 --- a/vendor/src/github.com/docker/libnetwork/default_gateway_linux.go +++ b/vendor/src/github.com/docker/libnetwork/default_gateway_linux.go @@ -5,8 +5,6 @@ import ( "strconv" "github.com/docker/libnetwork/drivers/bridge" - "github.com/docker/libnetwork/netlabel" - "github.com/docker/libnetwork/options" ) func (c *controller) createGWNetwork() (Network, error) { @@ -17,10 +15,9 @@ func (c *controller) createGWNetwork() (Network, error) { } n, err := c.NewNetwork("bridge", libnGWNetwork, - NetworkOptionGeneric(options.Generic{ - netlabel.GenericData: netOption, - netlabel.EnableIPv6: false, - })) + NetworkOptionDriverOpts(netOption), + NetworkOptionEnableIPv6(false), + ) if err != nil { return nil, fmt.Errorf("error creating external connectivity network: %v", err) diff --git a/vendor/src/github.com/docker/libnetwork/discoverapi/discoverapi.go b/vendor/src/github.com/docker/libnetwork/discoverapi/discoverapi.go new file mode 100644 index 0000000000..27993ec1bc --- /dev/null +++ b/vendor/src/github.com/docker/libnetwork/discoverapi/discoverapi.go @@ -0,0 +1,34 @@ +package discoverapi + +// Discover is an interface to be implemented by the componenet interested in receiving discover events +// like new node joining the cluster or datastore updates +type Discover interface { + // DiscoverNew is a notification for a new discovery event, Example:a new node joining a cluster + DiscoverNew(dType DiscoveryType, data interface{}) error + + // DiscoverDelete is a notification for a discovery delete event, Example:a node leaving a cluster + DiscoverDelete(dType DiscoveryType, data interface{}) error +} + +// DiscoveryType represents the type of discovery element the DiscoverNew function is invoked on +type DiscoveryType int + +const ( + // NodeDiscovery represents Node join/leave events provided by discovery + NodeDiscovery = iota + 1 + // DatastoreUpdate represents a add/remove datastore event + DatastoreUpdate +) + +// NodeDiscoveryData represents the structure backing the node discovery data json string +type NodeDiscoveryData struct { + Address string + Self bool +} + +// DatastoreUpdateData is the data for the datastore update event message +type DatastoreUpdateData struct { + Provider string + Address string + Config interface{} +} diff --git a/vendor/src/github.com/docker/libnetwork/driverapi/driverapi.go b/vendor/src/github.com/docker/libnetwork/driverapi/driverapi.go index 44a937fb73..884e23e914 100644 --- a/vendor/src/github.com/docker/libnetwork/driverapi/driverapi.go +++ b/vendor/src/github.com/docker/libnetwork/driverapi/driverapi.go @@ -1,12 +1,18 @@ package driverapi -import "net" +import ( + "net" + + "github.com/docker/libnetwork/discoverapi" +) // NetworkPluginEndpointType represents the Endpoint Type used by Plugin system const NetworkPluginEndpointType = "NetworkDriver" // Driver is an interface that every plugin driver needs to implement. type Driver interface { + discoverapi.Discover + // CreateNetwork invokes the driver method to create a network passing // the network id and network specific config. The config mechanism will // eventually be replaced with labels which are yet to be introduced. @@ -36,12 +42,6 @@ type Driver interface { // Leave method is invoked when a Sandbox detaches from an endpoint. Leave(nid, eid string) error - // DiscoverNew is a notification for a new discovery event, Example:a new node joining a cluster - DiscoverNew(dType DiscoveryType, data interface{}) error - - // DiscoverDelete is a notification for a discovery delete event, Example:a node leaving a cluster - DiscoverDelete(dType DiscoveryType, data interface{}) error - // Type returns the the type of this driver, the network type this driver manages Type() string } @@ -107,20 +107,6 @@ type Capability struct { DataScope string } -// DiscoveryType represents the type of discovery element the DiscoverNew function is invoked on -type DiscoveryType int - -const ( - // NodeDiscovery represents Node join/leave events provided by discovery - NodeDiscovery = iota + 1 -) - -// NodeDiscoveryData represents the structure backing the node discovery data json string -type NodeDiscoveryData struct { - Address string - Self bool -} - // IPAMData represents the per-network ip related // operational information libnetwork will send // to the network driver during CreateNetwork() diff --git a/vendor/src/github.com/docker/libnetwork/drivers/bridge/bridge.go b/vendor/src/github.com/docker/libnetwork/drivers/bridge/bridge.go index 2bb4350e9d..b93d984ebd 100644 --- a/vendor/src/github.com/docker/libnetwork/drivers/bridge/bridge.go +++ b/vendor/src/github.com/docker/libnetwork/drivers/bridge/bridge.go @@ -15,6 +15,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" + "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/iptables" "github.com/docker/libnetwork/netlabel" @@ -1283,12 +1284,12 @@ func (d *driver) Type() string { } // DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster -func (d *driver) DiscoverNew(dType driverapi.DiscoveryType, data interface{}) error { +func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error { return nil } // DiscoverDelete is a notification for a discovery delete event, such as a node leaving a cluster -func (d *driver) DiscoverDelete(dType driverapi.DiscoveryType, data interface{}) error { +func (d *driver) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error { return nil } diff --git a/vendor/src/github.com/docker/libnetwork/drivers/host/host.go b/vendor/src/github.com/docker/libnetwork/drivers/host/host.go index 340cb2e6f0..66fd9ebdb8 100644 --- a/vendor/src/github.com/docker/libnetwork/drivers/host/host.go +++ b/vendor/src/github.com/docker/libnetwork/drivers/host/host.go @@ -4,6 +4,7 @@ import ( "sync" "github.com/docker/libnetwork/datastore" + "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/types" ) @@ -67,11 +68,11 @@ func (d *driver) Type() string { } // DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster -func (d *driver) DiscoverNew(dType driverapi.DiscoveryType, data interface{}) error { +func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error { return nil } // DiscoverDelete is a notification for a discovery delete event, such as a node leaving a cluster -func (d *driver) DiscoverDelete(dType driverapi.DiscoveryType, data interface{}) error { +func (d *driver) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error { return nil } diff --git a/vendor/src/github.com/docker/libnetwork/drivers/null/null.go b/vendor/src/github.com/docker/libnetwork/drivers/null/null.go index 5fbdd12956..b64c9e995d 100644 --- a/vendor/src/github.com/docker/libnetwork/drivers/null/null.go +++ b/vendor/src/github.com/docker/libnetwork/drivers/null/null.go @@ -4,6 +4,7 @@ import ( "sync" "github.com/docker/libnetwork/datastore" + "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/types" ) @@ -67,11 +68,11 @@ func (d *driver) Type() string { } // DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster -func (d *driver) DiscoverNew(dType driverapi.DiscoveryType, data interface{}) error { +func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error { return nil } // DiscoverDelete is a notification for a discovery delete event, such as a node leaving a cluster -func (d *driver) DiscoverDelete(dType driverapi.DiscoveryType, data interface{}) error { +func (d *driver) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error { return nil } diff --git a/vendor/src/github.com/docker/libnetwork/drivers/overlay/overlay.go b/vendor/src/github.com/docker/libnetwork/drivers/overlay/overlay.go index 9e5eba4013..f58ecd8b29 100644 --- a/vendor/src/github.com/docker/libnetwork/drivers/overlay/overlay.go +++ b/vendor/src/github.com/docker/libnetwork/drivers/overlay/overlay.go @@ -8,6 +8,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/libkv/store" "github.com/docker/libnetwork/datastore" + "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/idm" "github.com/docker/libnetwork/netlabel" @@ -35,7 +36,6 @@ type driver struct { serfInstance *serf.Serf networks networkTable store datastore.DataStore - ipAllocator *idm.Idm vxlanIdm *idm.Idm once sync.Once joinOnce sync.Once @@ -106,12 +106,6 @@ func (d *driver) configure() error { err = fmt.Errorf("failed to initialize vxlan id manager: %v", err) return } - - d.ipAllocator, err = idm.New(d.store, "ipam-id", 1, 0xFFFF-2) - if err != nil { - err = fmt.Errorf("failed to initalize ipam id manager: %v", err) - return - } }) return err @@ -192,9 +186,9 @@ func (d *driver) pushLocalEndpointEvent(action, nid, eid string) { } // DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster -func (d *driver) DiscoverNew(dType driverapi.DiscoveryType, data interface{}) error { - if dType == driverapi.NodeDiscovery { - nodeData, ok := data.(driverapi.NodeDiscoveryData) +func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error { + if dType == discoverapi.NodeDiscovery { + nodeData, ok := data.(discoverapi.NodeDiscoveryData) if !ok || nodeData.Address == "" { return fmt.Errorf("invalid discovery data") } @@ -204,6 +198,6 @@ func (d *driver) DiscoverNew(dType driverapi.DiscoveryType, data interface{}) er } // DiscoverDelete is a notification for a discovery delete event, such as a node leaving a cluster -func (d *driver) DiscoverDelete(dType driverapi.DiscoveryType, data interface{}) error { +func (d *driver) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error { return nil } diff --git a/vendor/src/github.com/docker/libnetwork/drivers/remote/api/api.go b/vendor/src/github.com/docker/libnetwork/drivers/remote/api/api.go index 6c9fb09521..7dc877fc66 100644 --- a/vendor/src/github.com/docker/libnetwork/drivers/remote/api/api.go +++ b/vendor/src/github.com/docker/libnetwork/drivers/remote/api/api.go @@ -7,6 +7,7 @@ package api import ( "net" + "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" ) @@ -154,7 +155,7 @@ type LeaveResponse struct { // DiscoveryNotification represents a discovery notification type DiscoveryNotification struct { - DiscoveryType driverapi.DiscoveryType + DiscoveryType discoverapi.DiscoveryType DiscoveryData interface{} } diff --git a/vendor/src/github.com/docker/libnetwork/drivers/remote/driver.go b/vendor/src/github.com/docker/libnetwork/drivers/remote/driver.go index 0a7ab1865c..c55915ce97 100644 --- a/vendor/src/github.com/docker/libnetwork/drivers/remote/driver.go +++ b/vendor/src/github.com/docker/libnetwork/drivers/remote/driver.go @@ -7,6 +7,7 @@ import ( log "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/plugins" "github.com/docker/libnetwork/datastore" + "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/drivers/remote/api" "github.com/docker/libnetwork/types" @@ -251,8 +252,8 @@ func (d *driver) Type() string { } // DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster -func (d *driver) DiscoverNew(dType driverapi.DiscoveryType, data interface{}) error { - if dType != driverapi.NodeDiscovery { +func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error { + if dType != discoverapi.NodeDiscovery { return fmt.Errorf("Unknown discovery type : %v", dType) } notif := &api.DiscoveryNotification{ @@ -263,8 +264,8 @@ func (d *driver) DiscoverNew(dType driverapi.DiscoveryType, data interface{}) er } // DiscoverDelete is a notification for a discovery delete event, such as a node leaving a cluster -func (d *driver) DiscoverDelete(dType driverapi.DiscoveryType, data interface{}) error { - if dType != driverapi.NodeDiscovery { +func (d *driver) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error { + if dType != discoverapi.NodeDiscovery { return fmt.Errorf("Unknown discovery type : %v", dType) } notif := &api.DiscoveryNotification{ diff --git a/vendor/src/github.com/docker/libnetwork/drivers/windows/windows.go b/vendor/src/github.com/docker/libnetwork/drivers/windows/windows.go index 5464a5f070..e51da7dca2 100644 --- a/vendor/src/github.com/docker/libnetwork/drivers/windows/windows.go +++ b/vendor/src/github.com/docker/libnetwork/drivers/windows/windows.go @@ -2,6 +2,7 @@ package windows import ( "github.com/docker/libnetwork/datastore" + "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" ) @@ -54,11 +55,11 @@ func (d *driver) Type() string { } // DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster -func (d *driver) DiscoverNew(dType driverapi.DiscoveryType, data interface{}) error { +func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error { return nil } // DiscoverDelete is a notification for a discovery delete event, such as a node leaving a cluster -func (d *driver) DiscoverDelete(dType driverapi.DiscoveryType, data interface{}) error { +func (d *driver) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error { return nil } diff --git a/vendor/src/github.com/docker/libnetwork/endpoint.go b/vendor/src/github.com/docker/libnetwork/endpoint.go index 6455686a32..38506c82a8 100644 --- a/vendor/src/github.com/docker/libnetwork/endpoint.go +++ b/vendor/src/github.com/docker/libnetwork/endpoint.go @@ -44,7 +44,7 @@ type Endpoint interface { Delete(force bool) error } -// EndpointOption is a option setter function type used to pass varios options to Network +// EndpointOption is an option setter function type used to pass various options to Network // and Endpoint interfaces methods. The various setter functions of type EndpointOption are // provided by libnetwork, they look like Option[...](...) type EndpointOption func(ep *endpoint) @@ -343,7 +343,7 @@ func (ep *endpoint) getNetworkFromStore() (*network, error) { return nil, fmt.Errorf("invalid network object in endpoint %s", ep.Name()) } - return ep.network.ctrlr.getNetworkFromStore(ep.network.id) + return ep.network.getController().getNetworkFromStore(ep.network.id) } func (ep *endpoint) Join(sbox Sandbox, options ...EndpointOption) error { @@ -911,7 +911,7 @@ func (ep *endpoint) assignAddressVersion(ipVer int, ipam ipamapi.Ipam) error { } } if progAdd != nil { - return types.BadRequestErrorf("Invalid preferred address %s: It does not belong to any of this network's subnets", prefAdd) + return types.BadRequestErrorf("Invalid address %s: It does not belong to any of this network's subnets", prefAdd) } return fmt.Errorf("no available IPv%d addresses on this network's address pools: %s (%s)", ipVer, n.Name(), n.ID()) } diff --git a/vendor/src/github.com/docker/libnetwork/ipam/allocator.go b/vendor/src/github.com/docker/libnetwork/ipam/allocator.go index 4fa7e1e972..bbaa7d11d2 100644 --- a/vendor/src/github.com/docker/libnetwork/ipam/allocator.go +++ b/vendor/src/github.com/docker/libnetwork/ipam/allocator.go @@ -489,7 +489,7 @@ func (a *Allocator) getAddress(nw *net.IPNet, bitmask *bitseq.Handle, prefAddres } else if prefAddress != nil { hostPart, e := types.GetHostPartIP(prefAddress, base.Mask) if e != nil { - return nil, types.InternalErrorf("failed to allocate preferred address %s: %v", prefAddress.String(), e) + return nil, types.InternalErrorf("failed to allocate requested address %s: %v", prefAddress.String(), e) } ordinal = ipToUint64(types.GetMinimalIP(hostPart)) err = bitmask.Set(ordinal) diff --git a/vendor/src/github.com/docker/libnetwork/ipamapi/contract.go b/vendor/src/github.com/docker/libnetwork/ipamapi/contract.go index 5d561d81df..812bdbc068 100644 --- a/vendor/src/github.com/docker/libnetwork/ipamapi/contract.go +++ b/vendor/src/github.com/docker/libnetwork/ipamapi/contract.go @@ -67,7 +67,7 @@ type Ipam interface { RequestPool(addressSpace, pool, subPool string, options map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error) // ReleasePool releases the address pool identified by the passed id ReleasePool(poolID string) error - // Request address from the specified pool ID. Input options or preferred IP can be passed. + // Request address from the specified pool ID. Input options or required IP can be passed. RequestAddress(string, net.IP, map[string]string) (*net.IPNet, map[string]string, error) // Release the address from the specified pool ID ReleaseAddress(string, net.IP) error diff --git a/vendor/src/github.com/docker/libnetwork/network.go b/vendor/src/github.com/docker/libnetwork/network.go index aa32cb8d68..d995072f9c 100644 --- a/vendor/src/github.com/docker/libnetwork/network.go +++ b/vendor/src/github.com/docker/libnetwork/network.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "net" - "strconv" "strings" "sync" @@ -62,6 +61,7 @@ type NetworkInfo interface { IpamInfo() ([]*IpamInfo, []*IpamInfo) DriverOptions() map[string]string Scope() string + IPv6Enabled() bool Internal() bool } @@ -466,7 +466,7 @@ func (n *network) UnmarshalJSON(b []byte) (err error) { return nil } -// NetworkOption is a option setter function type used to pass varios options to +// NetworkOption is an option setter function type used to pass various options to // NewNetwork method. The various setter functions of type NetworkOption are // provided by libnetwork, they look like NetworkOptionXXXX(...) type NetworkOption func(n *network) @@ -475,9 +475,17 @@ type NetworkOption func(n *network) // in a Dictionary of Key-Value pair func NetworkOptionGeneric(generic map[string]interface{}) NetworkOption { return func(n *network) { - n.generic = generic - if _, ok := generic[netlabel.EnableIPv6]; ok { - n.enableIPv6 = generic[netlabel.EnableIPv6].(bool) + if n.generic == nil { + n.generic = make(map[string]interface{}) + } + if val, ok := generic[netlabel.EnableIPv6]; ok { + n.enableIPv6 = val.(bool) + } + if val, ok := generic[netlabel.Internal]; ok { + n.internal = val.(bool) + } + for k, v := range generic { + n.generic[k] = v } } } @@ -489,14 +497,25 @@ func NetworkOptionPersist(persist bool) NetworkOption { } } +// NetworkOptionEnableIPv6 returns an option setter to explicitly configure IPv6 +func NetworkOptionEnableIPv6(enableIPv6 bool) NetworkOption { + return func(n *network) { + if n.generic == nil { + n.generic = make(map[string]interface{}) + } + n.enableIPv6 = enableIPv6 + n.generic[netlabel.EnableIPv6] = enableIPv6 + } +} + // NetworkOptionInternalNetwork returns an option setter to config the network // to be internal which disables default gateway service func NetworkOptionInternalNetwork() NetworkOption { return func(n *network) { - n.internal = true if n.generic == nil { n.generic = make(map[string]interface{}) } + n.internal = true n.generic[netlabel.Internal] = true } } @@ -525,13 +544,6 @@ func NetworkOptionDriverOpts(opts map[string]string) NetworkOption { } // Store the options n.generic[netlabel.GenericData] = opts - // Decode and store the endpoint options of libnetwork interest - if val, ok := opts[netlabel.EnableIPv6]; ok { - var err error - if n.enableIPv6, err = strconv.ParseBool(val); err != nil { - log.Warnf("Failed to parse %s' value: %s (%s)", netlabel.EnableIPv6, val, err.Error()) - } - } } } @@ -692,7 +704,7 @@ func (n *network) CreateEndpoint(name string, options ...EndpointOption) (Endpoi ep.id = stringid.GenerateRandomID() // Initialize ep.network with a possibly stale copy of n. We need this to get network from - // store. But once we get it from store we will have the most uptodate copy possible. + // store. But once we get it from store we will have the most uptodate copy possibly. ep.network = n ep.locator = n.getController().clusterHostID() ep.network, err = ep.getNetworkFromStore() @@ -1237,3 +1249,10 @@ func (n *network) Internal() bool { return n.internal } + +func (n *network) IPv6Enabled() bool { + n.Lock() + defer n.Unlock() + + return n.enableIPv6 +} diff --git a/vendor/src/github.com/docker/libnetwork/sandbox.go b/vendor/src/github.com/docker/libnetwork/sandbox.go index 71c8ebb753..ae11665773 100644 --- a/vendor/src/github.com/docker/libnetwork/sandbox.go +++ b/vendor/src/github.com/docker/libnetwork/sandbox.go @@ -51,7 +51,7 @@ type Sandbox interface { Endpoints() []Endpoint } -// SandboxOption is a option setter function type used to pass varios options to +// SandboxOption is an option setter function type used to pass various options to // NewNetContainer method. The various setter functions of type SandboxOption are // provided by libnetwork, they look like ContainerOptionXXXX(...) type SandboxOption func(sb *sandbox) diff --git a/vendor/src/github.com/docker/libnetwork/store.go b/vendor/src/github.com/docker/libnetwork/store.go index dbfdaa0371..c7c6928dbf 100644 --- a/vendor/src/github.com/docker/libnetwork/store.go +++ b/vendor/src/github.com/docker/libnetwork/store.go @@ -139,11 +139,14 @@ func (c *controller) getNetworksFromStore() ([]*network, error) { ec := &endpointCnt{n: n} err = store.GetObject(datastore.Key(ec.Key()...), ec) if err != nil { - return nil, fmt.Errorf("could not find endpoint count key %s for network %s while listing: %v", datastore.Key(ec.Key()...), n.Name(), err) + log.Warnf("could not find endpoint count key %s for network %s while listing: %v", datastore.Key(ec.Key()...), n.Name(), err) + continue } + n.Lock() n.epCnt = ec n.scope = store.Scope() + n.Unlock() nl = append(nl, n) } }