From 6fac61808aa4c6700f1df606889bcf7c1b75fe50 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 24 Nov 2022 17:20:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/rpc/rpc_client.go | 6 +++++- internal/web/actions/actionutils/parent_action.go | 5 +---- web/views/@default/clusters/cluster/node/detail.html | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/rpc/rpc_client.go b/internal/rpc/rpc_client.go index cd8c8b13..1be879d9 100644 --- a/internal/rpc/rpc_client.go +++ b/internal/rpc/rpc_client.go @@ -571,7 +571,11 @@ func (this *RPCClient) pickConn() *grpc.ClientConn { defer this.locker.Unlock() // 检查连接状态 - if len(this.conns) > 0 { + var countConns = len(this.conns) + if countConns > 0 { + if countConns == 1 { + return this.conns[0] + } for _, state := range []connectivity.State{ connectivity.Ready, connectivity.Idle, diff --git a/internal/web/actions/actionutils/parent_action.go b/internal/web/actions/actionutils/parent_action.go index fcc7c379..22ce6833 100644 --- a/internal/web/actions/actionutils/parent_action.go +++ b/internal/web/actions/actionutils/parent_action.go @@ -130,11 +130,8 @@ func (this *ParentAction) RPC() *rpc.RPCClient { } // AdminContext 获取Context +// 每个请求的context都必须是一个新的实例 func (this *ParentAction) AdminContext() context.Context { - if this.ctx != nil { - return this.ctx - } - if this.rpcClient == nil { rpcClient, err := rpc.SharedRPC() if err != nil { diff --git a/web/views/@default/clusters/cluster/node/detail.html b/web/views/@default/clusters/cluster/node/detail.html index 1e29c8f8..32b329ba 100644 --- a/web/views/@default/clusters/cluster/node/detail.html +++ b/web/views/@default/clusters/cluster/node/detail.html @@ -249,7 +249,7 @@ 连接非常慢(平均{{round(node.status.apiAvgCostSeconds)}}秒),请改善当前节点和API节点之间通讯 - 尚未连接 + 尚未上报数据