This is an automated email from the ASF dual-hosted git repository.

hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks-controller.git


The following commit(s) were added to refs/heads/unstable by this push:
     new df2f23c  Don't add the node into the failover candidates if it's not a 
master node (#164)
df2f23c is described below

commit df2f23cc199cd108740c5d9612041c1a10578379
Author: hulk <[email protected]>
AuthorDate: Mon Apr 15 21:50:03 2024 +0800

    Don't add the node into the failover candidates if it's not a master node 
(#164)
---
 controller/probe/cluster.go | 5 +++++
 server/cluster.go           | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/controller/probe/cluster.go b/controller/probe/cluster.go
index de9beec..c35421e 100644
--- a/controller/probe/cluster.go
+++ b/controller/probe/cluster.go
@@ -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 {
diff --git a/server/cluster.go b/server/cluster.go
index fdea094..92333a3 100644
--- a/server/cluster.go
+++ b/server/cluster.go
@@ -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 {
@@ -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
        }

Reply via email to