Add API for setting node status, respect it in leader tasks

This commit is contained in:
Ingo Oppermann
2024-06-24 16:50:15 +02:00
parent 166e313642
commit c032cdf5c7
19 changed files with 1219 additions and 126 deletions

View File

@@ -90,6 +90,9 @@ type Cluster interface {
GetKV(origin, key string, stale bool) (string, time.Time, error)
ListKV(prefix string) map[string]store.Value
ListNodes() map[string]store.Node
SetNodeState(origin, id, state string) error
ProxyReader() proxy.ProxyReader
CertManager() autocert.Manager
}
@@ -1476,6 +1479,8 @@ func (c *cluster) About() (ClusterAbout, error) {
}
}
storeNodes := c.ListNodes()
c.nodesLock.RLock()
for id, node := range c.nodes {
nodeAbout := node.About()
@@ -1515,6 +1520,12 @@ func (c *cluster) About() (ClusterAbout, error) {
node.Leader = s.Leader
}
if storeNode, hasStoreNode := storeNodes[id]; hasStoreNode {
if storeNode.State == "maintenance" {
node.Status = storeNode.State
}
}
about.Nodes = append(about.Nodes, node)
}
c.nodesLock.RUnlock()