Skip to content

Commit

Permalink
Moved the cluster provider to Moby
Browse files Browse the repository at this point in the history
Moved the cluster provider interface definition from
libnetwork to moby

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
  • Loading branch information
Flavio Crisciani committed May 24, 2017
1 parent eb0c1ea commit 627da8b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 52 deletions.
4 changes: 2 additions & 2 deletions libnetwork/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"sync"

"github.com/Sirupsen/logrus"
"github.com/docker/docker/daemon/cluster/provider"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/go-events"
"github.com/docker/libnetwork/cluster"
"github.com/docker/libnetwork/datastore"
"github.com/docker/libnetwork/discoverapi"
"github.com/docker/libnetwork/driverapi"
Expand Down Expand Up @@ -193,7 +193,7 @@ func (c *controller) handleKeyChange(keys []*types.EncryptionKey) error {
return nil
}

func (c *controller) agentSetup(clusterProvider cluster.Provider) error {
func (c *controller) agentSetup(clusterProvider provider.Cluster) error {
agent := c.getAgent()

// If the agent is already present there is no need to try to initilize it again
Expand Down
36 changes: 0 additions & 36 deletions libnetwork/cluster/provider.go

This file was deleted.

10 changes: 5 additions & 5 deletions libnetwork/cmd/dnet/dnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (

"github.com/Sirupsen/logrus"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/daemon/cluster/provider"
"github.com/docker/docker/pkg/term"
"github.com/docker/libnetwork"
"github.com/docker/libnetwork/api"
"github.com/docker/libnetwork/cluster"
"github.com/docker/libnetwork/config"
"github.com/docker/libnetwork/datastore"
"github.com/docker/libnetwork/driverapi"
Expand Down Expand Up @@ -235,7 +235,7 @@ type dnetConnection struct {
// addr holds the client address.
addr string
Orchestration *NetworkOrchestration
configEvent chan cluster.ConfigEventType
configEvent chan provider.ClusterConfigEventType
}

// NetworkOrchestration exported
Expand Down Expand Up @@ -276,7 +276,7 @@ func (d *dnetConnection) dnetDaemon(cfgFile string) error {
controller.SetClusterProvider(d)

if d.Orchestration.Agent || d.Orchestration.Manager {
d.configEvent <- cluster.EventNodeReady
d.configEvent <- provider.ClusterEventNodeReady
}

createDefaultNetwork(controller)
Expand Down Expand Up @@ -336,7 +336,7 @@ func (d *dnetConnection) GetNetworkKeys() []*types.EncryptionKey {
func (d *dnetConnection) SetNetworkKeys([]*types.EncryptionKey) {
}

func (d *dnetConnection) ListenClusterEvents() <-chan cluster.ConfigEventType {
func (d *dnetConnection) ListenClusterEvents() <-chan provider.ClusterConfigEventType {
return d.configEvent
}

Expand Down Expand Up @@ -439,7 +439,7 @@ func newDnetConnection(val string) (*dnetConnection, error) {
return nil, errors.New("dnet currently only supports tcp transport")
}

return &dnetConnection{protoAddrParts[0], protoAddrParts[1], &NetworkOrchestration{}, make(chan cluster.ConfigEventType, 10)}, nil
return &dnetConnection{protoAddrParts[0], protoAddrParts[1], &NetworkOrchestration{}, make(chan provider.ClusterConfigEventType, 10)}, nil
}

func (d *dnetConnection) httpCall(method, path string, data interface{}, headers map[string][]string) (io.ReadCloser, http.Header, int, error) {
Expand Down
4 changes: 2 additions & 2 deletions libnetwork/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (

"github.com/BurntSushi/toml"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/daemon/cluster/provider"
"github.com/docker/docker/pkg/discovery"
"github.com/docker/docker/pkg/plugingetter"
"github.com/docker/go-connections/tlsconfig"
"github.com/docker/libkv/store"
"github.com/docker/libnetwork/cluster"
"github.com/docker/libnetwork/datastore"
"github.com/docker/libnetwork/netlabel"
"github.com/docker/libnetwork/osl"
Expand All @@ -33,7 +33,7 @@ type DaemonCfg struct {
DefaultDriver string
Labels []string
DriverCfg map[string]interface{}
ClusterProvider cluster.Provider
ClusterProvider provider.Cluster
}

// ClusterCfg represents cluster configuration
Expand Down
14 changes: 7 additions & 7 deletions libnetwork/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ import (
"time"

"github.com/Sirupsen/logrus"
"github.com/docker/docker/daemon/cluster/provider"
"github.com/docker/docker/pkg/discovery"
"github.com/docker/docker/pkg/locker"
"github.com/docker/docker/pkg/plugingetter"
"github.com/docker/docker/pkg/plugins"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/libnetwork/cluster"
"github.com/docker/libnetwork/config"
"github.com/docker/libnetwork/datastore"
"github.com/docker/libnetwork/discoverapi"
Expand Down Expand Up @@ -123,7 +123,7 @@ type NetworkController interface {
ReloadConfiguration(cfgOptions ...config.Option) error

// SetClusterProvider sets cluster provider
SetClusterProvider(provider cluster.Provider)
SetClusterProvider(provider provider.Cluster)

// Wait for agent initialization complete in libnetwork controller
AgentInitWait()
Expand Down Expand Up @@ -243,7 +243,7 @@ func New(cfgOptions ...config.Option) (NetworkController, error) {
return c, nil
}

func (c *controller) SetClusterProvider(provider cluster.Provider) {
func (c *controller) SetClusterProvider(provider provider.Cluster) {
var sameProvider bool
c.Lock()
// Avoids to spawn multiple goroutine for the same cluster provider
Expand Down Expand Up @@ -307,17 +307,17 @@ func (c *controller) clusterAgentInit() {
var keysAvailable bool
for {
eventType := <-clusterProvider.ListenClusterEvents()
// The events: EventSocketChange, EventNodeReady and EventNetworkKeysAvailable are not ordered
// The events: ClusterEventSocketChange, ClusterEventNodeReady and ClusterEventNetworkKeysAvailable are not ordered
// when all the condition for the agent initialization are met then proceed with it
switch eventType {
case cluster.EventNetworkKeysAvailable:
case provider.ClusterEventNetworkKeysAvailable:
// Validates that the keys are actually available before starting the initialization
// This will handle old spurious messages left on the channel
c.Lock()
keysAvailable = c.keys != nil
c.Unlock()
fallthrough
case cluster.EventSocketChange, cluster.EventNodeReady:
case provider.ClusterEventSocketChange, provider.ClusterEventNodeReady:
if keysAvailable && !c.isDistributedControl() {
c.agentOperationStart()
if err := c.agentSetup(clusterProvider); err != nil {
Expand All @@ -326,7 +326,7 @@ func (c *controller) clusterAgentInit() {
c.agentInitComplete()
}
}
case cluster.EventNodeLeave:
case provider.ClusterEventNodeLeave:
keysAvailable = false
c.agentOperationStart()
c.Lock()
Expand Down

0 comments on commit 627da8b

Please sign in to comment.