Skip to content

Commit

Permalink
Don't add the node into the failover candidates if it's not a master …
Browse files Browse the repository at this point in the history
…node
  • Loading branch information
git-hulk committed Apr 15, 2024
1 parent 77db1c4 commit dc14323
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions controller/probe/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ func (c *Cluster) increaseFailureCount(index int, node *metadata.NodeInfo) int64
count := c.failureCounts[node.Addr]
c.failureMu.Unlock()

/// don't add the node into the failover candidates if it's not a master node
if node.Role != metadata.RoleMaster {
return count
}

if count%c.failOver.Config().MaxPingCount == 0 {
err := c.failOver.AddNode(c.namespace, c.cluster, index, *node, failover.AutoType)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (handler *ClusterHandler) Remove(c *gin.Context) {
responseOK(c, "ok")
}

func (hander *ClusterHandler) Import(c *gin.Context) {
func (handler *ClusterHandler) Import(c *gin.Context) {
namespace := c.Param("namespace")
clusterName := c.Param("cluster")
var req struct {
Expand Down Expand Up @@ -198,7 +198,7 @@ func (hander *ClusterHandler) Import(c *gin.Context) {
clusterInfo.SetPassword(req.Password)

clusterInfo.Name = clusterName
if err := hander.storage.CreateCluster(c, namespace, clusterInfo); err != nil {
if err := handler.storage.CreateCluster(c, namespace, clusterInfo); err != nil {
responseError(c, err)
return
}
Expand Down

0 comments on commit dc14323

Please sign in to comment.