Moved the cluster provider to Moby
Moved the cluster provider interface definition from libnetwork to moby Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
This commit is contained in:
parent
eb0c1ea00c
commit
627da8bf04
5 changed files with 16 additions and 52 deletions
|
@ -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"
|
||||
|
@ -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
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package cluster
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
const (
|
||||
// EventSocketChange control socket changed
|
||||
EventSocketChange = iota
|
||||
// EventNodeReady cluster node in ready state
|
||||
EventNodeReady
|
||||
// EventNodeLeave node is leaving the cluster
|
||||
EventNodeLeave
|
||||
// EventNetworkKeysAvailable network keys correctly configured in the networking layer
|
||||
EventNetworkKeysAvailable
|
||||
)
|
||||
|
||||
// ConfigEventType type of the event produced by the cluster
|
||||
type ConfigEventType uint8
|
||||
|
||||
// Provider provides clustering config details
|
||||
type Provider interface {
|
||||
IsManager() bool
|
||||
IsAgent() bool
|
||||
GetLocalAddress() string
|
||||
GetListenAddress() string
|
||||
GetAdvertiseAddress() string
|
||||
GetDataPathAddress() string
|
||||
GetRemoteAddressList() []string
|
||||
ListenClusterEvents() <-chan ConfigEventType
|
||||
AttachNetwork(string, string, []string) (*network.NetworkingConfig, error)
|
||||
DetachNetwork(string, string) error
|
||||
UpdateAttachment(string, string, *network.NetworkingConfig) error
|
||||
WaitForDetachment(context.Context, string, string, string, string) error
|
||||
}
|
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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"
|
||||
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -326,7 +326,7 @@ func (c *controller) clusterAgentInit() {
|
|||
c.agentInitComplete()
|
||||
}
|
||||
}
|
||||
case cluster.EventNodeLeave:
|
||||
case provider.ClusterEventNodeLeave:
|
||||
keysAvailable = false
|
||||
c.agentOperationStart()
|
||||
c.Lock()
|
||||
|
|
Loading…
Reference in a new issue