From c271f949d9158afb27ff9ae1d4fd1f5e96d0f9bb Mon Sep 17 00:00:00 2001 From: liurong Date: Fri, 10 Nov 2023 14:35:36 +0800 Subject: [PATCH 1/3] add log for naming selectInstances --- clients/naming_client/naming_client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/clients/naming_client/naming_client.go b/clients/naming_client/naming_client.go index 24f8b761..a2257e1a 100644 --- a/clients/naming_client/naming_client.go +++ b/clients/naming_client/naming_client.go @@ -265,6 +265,7 @@ func (sc *NamingClient) selectInstances(service model.Service, healthy bool) ([] } hosts := service.Hosts var result []model.Instance + logger.Infof("select instances with options: [healthy:<%s>], with service:<%s>", healthy, util.GetGroupName(service.Name, service.GroupName)) for _, host := range hosts { if host.Healthy == healthy && host.Enable && host.Weight > 0 { result = append(result, host) From 9b246b282b81af3ec7538c97d62d4bf03f2bb2aa Mon Sep 17 00:00:00 2001 From: liurong Date: Fri, 10 Nov 2023 15:11:19 +0800 Subject: [PATCH 2/3] add some error logs for config --- clients/config_client/config_client.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/clients/config_client/config_client.go b/clients/config_client/config_client.go index 4f12b23e..d78f80f3 100644 --- a/clients/config_client/config_client.go +++ b/clients/config_client/config_client.go @@ -247,6 +247,9 @@ func (client *ConfigClient) getConfigInner(param *vo.ConfigParam) (content strin logger.Warnf("read config from cache success, dataId=%s, group=%s, namespaceId=%s", param.DataId, param.Group, clientConfig.NamespaceId) return cacheContent, nil } + if response != nil && !response.IsSuccess() { + return response.Content, errors.New(response.GetMessage()) + } param.EncryptedDataKey = response.EncryptedDataKey param.Content = response.Content return response.Content, nil @@ -281,8 +284,11 @@ func (client *ConfigClient) PublishConfig(param vo.ConfigParam) (published bool, request.AdditionMap["encryptedDataKey"] = param.EncryptedDataKey rpcClient := client.configProxy.getRpcClient(client) response, err := client.configProxy.requestProxy(rpcClient, request, constant.DEFAULT_TIMEOUT_MILLS) + if err != nil { + return false, err + } if response != nil { - return response.IsSuccess(), err + return client.buildResponse(response) } return false, err } @@ -301,8 +307,11 @@ func (client *ConfigClient) DeleteConfig(param vo.ConfigParam) (deleted bool, er request := rpc_request.NewConfigRemoveRequest(param.Group, param.DataId, clientConfig.NamespaceId) rpcClient := client.configProxy.getRpcClient(client) response, err := client.configProxy.requestProxy(rpcClient, request, constant.DEFAULT_TIMEOUT_MILLS) + if err != nil { + return false, err + } if response != nil { - return response.IsSuccess(), err + return client.buildResponse(response) } return false, err } @@ -509,6 +518,11 @@ func (client *ConfigClient) refreshContentAndCheck(cacheData cacheData, notify b cacheData.group, cacheData.tenant) return } + if configQueryResponse != nil && !configQueryResponse.IsSuccess() { + logger.Errorf("refresh cached config from server error:%v, dataId=%s, group=%s", configQueryResponse.GetMessage(), + cacheData.dataId, cacheData.group) + return + } cacheData.content = configQueryResponse.Content cacheData.contentType = configQueryResponse.ContentType cacheData.encryptedDataKey = configQueryResponse.EncryptedDataKey @@ -551,3 +565,10 @@ func (client *ConfigClient) asyncNotifyListenConfig() { client.listenExecute <- struct{}{} }() } + +func (client *ConfigClient) buildResponse(response rpc_response.IResponse) (bool, error) { + if response.IsSuccess() { + return response.IsSuccess(), nil + } + return false, errors.New(response.GetMessage()) +} From 196a59450cfe8687f86b1c61bb794a8d60f58adb Mon Sep 17 00:00:00 2001 From: liurong Date: Fri, 10 Nov 2023 15:25:40 +0800 Subject: [PATCH 3/3] fix up --- clients/config_client/config_client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/config_client/config_client.go b/clients/config_client/config_client.go index d78f80f3..54ee973e 100644 --- a/clients/config_client/config_client.go +++ b/clients/config_client/config_client.go @@ -247,7 +247,7 @@ func (client *ConfigClient) getConfigInner(param *vo.ConfigParam) (content strin logger.Warnf("read config from cache success, dataId=%s, group=%s, namespaceId=%s", param.DataId, param.Group, clientConfig.NamespaceId) return cacheContent, nil } - if response != nil && !response.IsSuccess() { + if response != nil && response.Response != nil && !response.IsSuccess() { return response.Content, errors.New(response.GetMessage()) } param.EncryptedDataKey = response.EncryptedDataKey @@ -518,7 +518,7 @@ func (client *ConfigClient) refreshContentAndCheck(cacheData cacheData, notify b cacheData.group, cacheData.tenant) return } - if configQueryResponse != nil && !configQueryResponse.IsSuccess() { + if configQueryResponse != nil && configQueryResponse.Response != nil && !configQueryResponse.IsSuccess() { logger.Errorf("refresh cached config from server error:%v, dataId=%s, group=%s", configQueryResponse.GetMessage(), cacheData.dataId, cacheData.group) return