From 4d06bbd2e6bf9b10e7bf6fcb30d4d7956e2d682c Mon Sep 17 00:00:00 2001 From: Madhu Venugopal Date: Thu, 4 Jun 2015 04:32:10 -0700 Subject: [PATCH 1/2] Fixing a few go-vet issues Signed-off-by: Madhu Venugopal --- drivers/bridge/bridge_test.go | 2 +- endpoint_info.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/bridge/bridge_test.go b/drivers/bridge/bridge_test.go index aba4697..6597ca1 100644 --- a/drivers/bridge/bridge_test.go +++ b/drivers/bridge/bridge_test.go @@ -159,7 +159,7 @@ func (te *testEndpoint) SetResolvConfPath(path string) error { } func (te *testEndpoint) AddStaticRoute(destination *net.IPNet, routeType int, nextHop net.IP, interfaceID int) error { - te.routes = append(te.routes, types.StaticRoute{destination, routeType, nextHop, interfaceID}) + te.routes = append(te.routes, types.StaticRoute{Destination: destination, RouteType: routeType, NextHop: nextHop, InterfaceID: interfaceID}) return nil } diff --git a/endpoint_info.go b/endpoint_info.go index 1c7a85c..bd989f2 100644 --- a/endpoint_info.go +++ b/endpoint_info.go @@ -155,7 +155,7 @@ func (ep *endpoint) AddStaticRoute(destination *net.IPNet, routeType int, nextHo ep.Lock() defer ep.Unlock() - r := types.StaticRoute{destination, routeType, nextHop, interfaceID} + r := types.StaticRoute{Destination: destination, RouteType: routeType, NextHop: nextHop, InterfaceID: interfaceID} if routeType == types.NEXTHOP { // If the route specifies a next-hop, then it's loosely routed (i.e. not bound to a particular interface). From 29350c906ca3222b325031cd6939be79ab111a92 Mon Sep 17 00:00:00 2001 From: Madhu Venugopal Date: Thu, 4 Jun 2015 04:51:16 -0700 Subject: [PATCH 2/2] Including hostdiscovery conditionaly under a build tag In order to vendor-in libnetwork to docker, we need to remove the swarm dependency even though it is used as library. using this PR, a new build flag libnetwork_discovery is introduced in order to avoid pulling in the unused hostdiscovery functionality into docker. We are working with the Swarm project to see if we can modularize the discovery package to become independent so that we can include them as a vendor-in package in docker. Signed-off-by: Madhu Venugopal --- Makefile | 2 +- hostdiscovery/hostdiscovery.go | 18 ++-------------- hostdiscovery/hostdiscovery_api.go | 23 ++++++++++++++++++++ hostdiscovery/hostdiscovery_disabled.go | 28 +++++++++++++++++++++++++ hostdiscovery/hostdiscovery_test.go | 2 ++ 5 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 hostdiscovery/hostdiscovery_api.go create mode 100644 hostdiscovery/hostdiscovery_disabled.go diff --git a/Makefile b/Makefile index 59c181e..9deb265 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ build: ${build_image}.created ${docker} make build-local build-local: - $(shell which godep) go build -tags experimental ./... + $(shell which godep) go build -tags experimental,libnetwork_discovery ./... check: ${build_image}.created ${docker} make check-local diff --git a/hostdiscovery/hostdiscovery.go b/hostdiscovery/hostdiscovery.go index 550cb95..57a187e 100644 --- a/hostdiscovery/hostdiscovery.go +++ b/hostdiscovery/hostdiscovery.go @@ -1,3 +1,5 @@ +// +build libnetwork_discovery + package hostdiscovery import ( @@ -24,22 +26,6 @@ import ( const defaultHeartbeat = 10 -// JoinCallback provides a callback event for new node joining the cluster -type JoinCallback func(entries []net.IP) - -// LeaveCallback provides a callback event for node leaving the cluster -type LeaveCallback func(entries []net.IP) - -// HostDiscovery primary interface -type HostDiscovery interface { - // StartDiscovery initiates the discovery process and provides appropriate callbacks - StartDiscovery(*config.ClusterCfg, JoinCallback, LeaveCallback) error - // StopDiscovery stops the discovery perocess - StopDiscovery() error - // Fetch returns a list of host IPs that are currently discovered - Fetch() ([]net.IP, error) -} - type hostDiscovery struct { discovery discovery.Discovery nodes mapset.Set diff --git a/hostdiscovery/hostdiscovery_api.go b/hostdiscovery/hostdiscovery_api.go new file mode 100644 index 0000000..09394e0 --- /dev/null +++ b/hostdiscovery/hostdiscovery_api.go @@ -0,0 +1,23 @@ +package hostdiscovery + +import ( + "net" + + "github.com/docker/libnetwork/config" +) + +// JoinCallback provides a callback event for new node joining the cluster +type JoinCallback func(entries []net.IP) + +// LeaveCallback provides a callback event for node leaving the cluster +type LeaveCallback func(entries []net.IP) + +// HostDiscovery primary interface +type HostDiscovery interface { + // StartDiscovery initiates the discovery process and provides appropriate callbacks + StartDiscovery(*config.ClusterCfg, JoinCallback, LeaveCallback) error + // StopDiscovery stops the discovery perocess + StopDiscovery() error + // Fetch returns a list of host IPs that are currently discovered + Fetch() ([]net.IP, error) +} diff --git a/hostdiscovery/hostdiscovery_disabled.go b/hostdiscovery/hostdiscovery_disabled.go new file mode 100644 index 0000000..2dc67cc --- /dev/null +++ b/hostdiscovery/hostdiscovery_disabled.go @@ -0,0 +1,28 @@ +// +build !libnetwork_discovery + +package hostdiscovery + +import ( + "net" + + "github.com/docker/libnetwork/config" +) + +type hostDiscovery struct{} + +// NewHostDiscovery function creates a host discovery object +func NewHostDiscovery() HostDiscovery { + return &hostDiscovery{} +} + +func (h *hostDiscovery) StartDiscovery(cfg *config.ClusterCfg, joinCallback JoinCallback, leaveCallback LeaveCallback) error { + return nil +} + +func (h *hostDiscovery) StopDiscovery() error { + return nil +} + +func (h *hostDiscovery) Fetch() ([]net.IP, error) { + return []net.IP{}, nil +} diff --git a/hostdiscovery/hostdiscovery_test.go b/hostdiscovery/hostdiscovery_test.go index 90eca9d..43b4c82 100644 --- a/hostdiscovery/hostdiscovery_test.go +++ b/hostdiscovery/hostdiscovery_test.go @@ -1,3 +1,5 @@ +// +build libnetwork_discovery + package hostdiscovery import (