Fix use of proxy
This commit is contained in:
parent
8dcda07fc1
commit
e306d20d55
@ -73,12 +73,14 @@ func (c *cluster) recoverCluster(ctx context.Context, interval time.Duration) {
|
||||
break
|
||||
}
|
||||
|
||||
c.nodesLock.RLock()
|
||||
for id, node := range c.nodes {
|
||||
nodes := c.manager.NodeList()
|
||||
for _, node := range nodes {
|
||||
if _, err := node.Status(); err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
id := node.About().ID
|
||||
|
||||
for _, server := range servers {
|
||||
if server.ID == id && server.ID != c.nodeID {
|
||||
peers = append(peers, raft.Peer{
|
||||
@ -88,7 +90,6 @@ func (c *cluster) recoverCluster(ctx context.Context, interval time.Duration) {
|
||||
}
|
||||
}
|
||||
}
|
||||
c.nodesLock.RUnlock()
|
||||
|
||||
c.logger.Warn().WithField("peers", peers).Log("Recovering raft")
|
||||
|
||||
|
||||
@ -318,7 +318,7 @@ func (c *cluster) clearDeadNodes(ctx context.Context, interval, nodeRecoverTimeo
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
nodes := c.proxy.ListNodes()
|
||||
nodes := c.manager.NodeList()
|
||||
for _, node := range nodes {
|
||||
about := node.About()
|
||||
if time.Since(about.SpawnedAt) > nodeRecoverTimeout && time.Since(about.LastContact) > nodeRecoverTimeout {
|
||||
|
||||
@ -16,10 +16,11 @@ import (
|
||||
)
|
||||
|
||||
type Node struct {
|
||||
id string
|
||||
address string
|
||||
ips []string
|
||||
version string
|
||||
id string
|
||||
address string
|
||||
ips []string
|
||||
version string
|
||||
spawnedAt time.Time
|
||||
|
||||
node client.APIClient
|
||||
nodeAbout About
|
||||
@ -57,9 +58,10 @@ func New(config Config) *Node {
|
||||
tr.IdleConnTimeout = 30 * time.Second
|
||||
|
||||
n := &Node{
|
||||
id: config.ID,
|
||||
address: config.Address,
|
||||
version: "0.0.0",
|
||||
id: config.ID,
|
||||
address: config.Address,
|
||||
version: "0.0.0",
|
||||
spawnedAt: time.Now(),
|
||||
node: client.APIClient{
|
||||
Address: config.Address,
|
||||
Client: &http.Client{
|
||||
@ -138,6 +140,7 @@ type About struct {
|
||||
Error error
|
||||
Core CoreAbout
|
||||
Resources Resources
|
||||
SpawnedAt time.Time
|
||||
}
|
||||
|
||||
type Resources struct {
|
||||
@ -155,9 +158,10 @@ func (n *Node) About() About {
|
||||
defer n.lock.RUnlock()
|
||||
|
||||
a := About{
|
||||
ID: n.id,
|
||||
Version: n.version,
|
||||
Address: n.address,
|
||||
ID: n.id,
|
||||
Version: n.version,
|
||||
Address: n.address,
|
||||
SpawnedAt: n.spawnedAt,
|
||||
}
|
||||
|
||||
a.Name = n.coreAbout.Name
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user