Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop v2 for config_client #183

Merged
merged 2 commits into from
Oct 31, 2024
Merged

Conversation

Aiswel
Copy link

@Aiswel Aiswel commented Sep 20, 2024

What is the purpose of the change
add nacos v2 config_client and test nacos v2 config_client for ospp-2024

Brief changelog
None

Verifying this change
None

@@ -2,6 +2,9 @@

from v2.nacos.transport.model.rpc_response import Response

class NotifySubscriberResponse(Response):
def get_response_type(self) -> str:
return "ConnectResetResponse"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

类型错误?

@@ -31,4 +31,4 @@ async def test_naming_register(self):
print("success to register")
await asyncio.sleep(1000)
except Exception as e:
print(str(e))
print(str(e),5555)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

测试用例不要填自己个人/无关内容,测试用注释、服务段地址、日志目录等

async def test_config_register(self):
client = await NacosConfigService.create_config_service(client_config)
try:
await asyncio.sleep(5)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

仅保留一个测试类,里面的根据不同测试例子方法名区分开,最好能备注上注释

"username": self.username,
"password": self.password
}

server_list = self.get_server_list()
for server_address in server_list:
url = server_address + "/nacos/v1/auth/users/login"
resp, error = self.http_agent.request(url, "POST", None, params, None)
resp, error = self.http_agent.request(url, "POST", None, None, data)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要直接这样改绕过,需要弄清楚原因

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前这么用不行,今天再改回原来的方法又可以了,已修改为原来的params方案

@@ -11,6 +11,10 @@ class Constants:

LABEL_MODULE = "module"

LABEL_MODULE_CONFIG = "config"

LABEL_MODULE_NAMING = "naming"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经有 NAMING_MODULE CONFIG_MODULE的定义了

params['Spas-AccessKey'] = client_config.access_key

@staticmethod
def get_sign_headers_from_request(cr, secret_key):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参数命名要让用户能看懂,cr , 类型也尽可能标记上,另外不需要传递secret_key,client_config里有

self.logger.error("[config_proxy.query_config] [unkown-error] errer: %s", str(e))
return None

async def request_proxy(self, rpc_client: RpcClient, request: AbstractConfigRequest, timeout_millis: int):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request_proxy 不需要传递rpc_client参数,timeout也不需要,参考naming的 request_naming_server方法,还有返回值的类型校验也可以参考

response = await self.request_proxy(self.get_rpc_client(), config_query_request, timeout)

if not isinstance(response, ConfigQueryResponse):
raise NacosException(SERVER_ERROR, " Server return invalid response")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参考naming的request_naming_server 类型校验

f"[nacos_config_service._get_config_inner] get config from server error, dataId:{param.data_id}, group:{param.group}, namespaceId:{self.namespace_id}, error:{str(e)}")
if self.client_config.disable_use_snap_shot:
self.logger.warning(
"[nacos_config_service._get_config_inner] get config from remote nacos server fail, and is not allowed to read local file, err:%s", str(e))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golang返回error的地方,python里都应该抛NacosException,而不是只打日志返回空值就结束了

"[nacos_config_service._get_config_inner] get config from remote nacos server fail, and is not allowed to read local file, err:%s", str(e))
return "", ""
cache_content, cache_err = disk_cache.read_config_from_file(cache_key, self.config_cache_dir)
if not cache_content:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个地方应该先判断有没有错误吧?这段逻辑仔细参考下golang的实现

grpc protol支持

commit config_client

test publish config

update publish config

add config client and test config client

remove useless comments

remove useless comments

remove useless .vscode

change some test

add ConfigRemoveResponse in grpc_util

remove print

add test for console

fix some bugs based on comments in pr

add kms encryption

remove kms v3 and change readme.md for nacos v2
@CZJCC CZJCC merged commit 38c4e2c into nacos-group:feature/v2 Oct 31, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants