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 77db1c4 Add the failure count to the probe log message (#163)
77db1c4 is described below
commit 77db1c4b73f68dced284c65c231822db56a3e0e0
Author: hulk <[email protected]>
AuthorDate: Mon Apr 15 17:16:40 2024 +0800
Add the failure count to the probe log message (#163)
---
controller/probe/cluster.go | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/controller/probe/cluster.go b/controller/probe/cluster.go
index 6586383..de9beec 100644
--- a/controller/probe/cluster.go
+++ b/controller/probe/cluster.go
@@ -79,7 +79,7 @@ func (c *Cluster) probeNode(ctx context.Context, node
*metadata.NodeInfo) (int64
return info.ClusterCurrentEpoch, nil
}
-func (c *Cluster) increaseFailureCount(index int, node *metadata.NodeInfo) {
+func (c *Cluster) increaseFailureCount(index int, node *metadata.NodeInfo)
int64 {
log := logger.Get().With(
zap.String("id", node.ID),
zap.String("role", node.Role),
@@ -98,10 +98,11 @@ func (c *Cluster) increaseFailureCount(index int, node
*metadata.NodeInfo) {
err := c.failOver.AddNode(c.namespace, c.cluster, index, *node,
failover.AutoType)
if err != nil {
log.With(zap.Error(err)).Warn("Failed to add the node
into the fail over candidates")
- return
+ } else {
+ log.With(zap.Int64("failure_count", count)).Info("Add
the node into the fail over candidates")
}
- log.Info("Add the node into the fail over candidates")
}
+ return count
}
func (c *Cluster) resetFailureCount(node *metadata.NodeInfo) {
@@ -121,11 +122,13 @@ func (c *Cluster) probe(ctx context.Context, cluster
*metadata.Cluster) {
)
version, err := c.probeNode(ctx, &node)
if err != nil && !errors.Is(err,
ErrClusterNotInitialized) {
- c.increaseFailureCount(shardIdx, &node)
- log.With(zap.Error(err)).Error("Failed
to probe the node")
+ failureCount :=
c.increaseFailureCount(shardIdx, &node)
+ log.With(zap.Error(err),
+ zap.Int64("failure_count",
failureCount),
+ ).Error("Failed to probe the node")
return
}
- log.Debug("Probe the cluster node ")
+ log.Debug("Probe the cluster node")
if version < cluster.Version {
// sync the cluster to the latest
version