Change GetRemoteAddr to return all managers
Respect the new provider interface Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
This commit is contained in:
parent
68a5336b61
commit
441e861095
2 changed files with 18 additions and 10 deletions
|
@ -280,27 +280,29 @@ func (c *Cluster) GetDataPathAddress() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRemoteAddress returns a known advertise address of a remote manager if
|
// GetRemoteAddressList returns the advertise address for each of the remote managers if
|
||||||
// available.
|
// available.
|
||||||
// todo: change to array/connect with info
|
func (c *Cluster) GetRemoteAddressList() []string {
|
||||||
func (c *Cluster) GetRemoteAddress() string {
|
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
defer c.mu.RUnlock()
|
defer c.mu.RUnlock()
|
||||||
return c.getRemoteAddress()
|
return c.getRemoteAddressList()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) getRemoteAddress() string {
|
func (c *Cluster) getRemoteAddressList() []string {
|
||||||
state := c.currentNodeState()
|
state := c.currentNodeState()
|
||||||
if state.swarmNode == nil {
|
if state.swarmNode == nil {
|
||||||
return ""
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeID := state.swarmNode.NodeID()
|
nodeID := state.swarmNode.NodeID()
|
||||||
for _, r := range state.swarmNode.Remotes() {
|
remotes := state.swarmNode.Remotes()
|
||||||
|
addressList := make([]string, 0, len(remotes))
|
||||||
|
for _, r := range remotes {
|
||||||
if r.NodeID != nodeID {
|
if r.NodeID != nodeID {
|
||||||
return r.Addr
|
addressList = append(addressList, r.Addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ""
|
return addressList
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListenClusterEvents returns a channel that receives messages on cluster
|
// ListenClusterEvents returns a channel that receives messages on cluster
|
||||||
|
|
|
@ -271,7 +271,13 @@ func (n *nodeRunner) enableReconnectWatcher() {
|
||||||
if n.stopping {
|
if n.stopping {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
config.RemoteAddr = n.cluster.getRemoteAddress()
|
remotes := n.cluster.getRemoteAddressList()
|
||||||
|
if len(remotes) > 0 {
|
||||||
|
config.RemoteAddr = remotes[0]
|
||||||
|
} else {
|
||||||
|
config.RemoteAddr = ""
|
||||||
|
}
|
||||||
|
|
||||||
config.joinAddr = config.RemoteAddr
|
config.joinAddr = config.RemoteAddr
|
||||||
if err := n.start(config); err != nil {
|
if err := n.start(config); err != nil {
|
||||||
n.err = err
|
n.err = err
|
||||||
|
|
Loading…
Reference in a new issue