From 0f54c24fa04c60d3e582e570d650e1a206daf7e4 Mon Sep 17 00:00:00 2001 From: DuodenumL Date: Tue, 18 Jan 2022 17:39:33 +0800 Subject: [PATCH] try to make client when node is not available (#538) --- engine/factory/factory.go | 2 +- store/etcdv3/node.go | 10 ++++------ store/redis/node.go | 10 ++++------ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/engine/factory/factory.go b/engine/factory/factory.go index af6c253a5..c3f028c9c 100644 --- a/engine/factory/factory.go +++ b/engine/factory/factory.go @@ -33,7 +33,7 @@ var ( ) func getEngineCacheKey(endpoint, ca, cert, key string) string { - return endpoint + utils.SHA256(fmt.Sprintf(":%v:%v:%v", ca, cert, key))[:8] + return endpoint + "-" + utils.SHA256(fmt.Sprintf(":%v:%v:%v", ca, cert, key))[:8] } // EngineCacheChecker checks if the engine in cache is available diff --git a/store/etcdv3/node.go b/store/etcdv3/node.go index 315276e14..267f7939c 100644 --- a/store/etcdv3/node.go +++ b/store/etcdv3/node.go @@ -322,12 +322,10 @@ func (m *Mercury) doGetNodes(ctx context.Context, kvs []*mvccpb.KeyValue, labels } nodeChan <- node - if node.Available { - if client, err := m.makeClient(ctx, node); err != nil { - log.Errorf(ctx, "[doGetNodes] failed to make client for %v, err: %v", node.Name, err) - } else { - node.Engine = client - } + if client, err := m.makeClient(ctx, node); err != nil { + log.Errorf(ctx, "[doGetNodes] failed to make client for %v, err: %v", node.Name, err) + } else { + node.Engine = client } }) } diff --git a/store/redis/node.go b/store/redis/node.go index ed629f305..19ab2fffc 100644 --- a/store/redis/node.go +++ b/store/redis/node.go @@ -312,12 +312,10 @@ func (r *Rediaron) doGetNodes(ctx context.Context, kvs map[string]string, labels } nodeChan <- node - if node.Available { - if client, err := r.makeClient(ctx, node); err != nil { - log.Errorf(ctx, "[doGetNodes] failed to make client for %v, err: %v", node.Name, err) - } else { - node.Engine = client - } + if client, err := r.makeClient(ctx, node); err != nil { + log.Errorf(ctx, "[doGetNodes] failed to make client for %v, err: %v", node.Name, err) + } else { + node.Engine = client } }) }