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

Dev/account multi refactor #426

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft

Dev/account multi refactor #426

wants to merge 13 commits into from

Conversation

huerni
Copy link
Collaborator

@huerni huerni commented Jan 24, 2025

No description provided.

@huerni huerni marked this pull request as ready for review February 8, 2025 07:44
@huerni huerni marked this pull request as draft February 8, 2025 08:25
@huerni huerni force-pushed the dev/account_multi_refactor branch from d0ba76c to e61cd33 Compare February 10, 2025 06:38
@huerni huerni marked this pull request as ready for review February 11, 2025 01:50
@huerni huerni requested review from RileyWen and Nativu5 February 11, 2025 01:55
if (!user_result) return std::unexpected(user_result.error());
const User* op_user = user_result.value();
result = CheckIfUserHasPermOnUserOfAccountNoLock_(*op_user, p,
&actual_account, false);
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
Collaborator Author

Choose a reason for hiding this comment

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

这个不太好改,参数都是必需的,除非把这个函数拆了

@huerni huerni mentioned this pull request Feb 14, 2025
@huerni huerni linked an issue Feb 14, 2025 that may be closed by this pull request
@L-Xiafeng L-Xiafeng added the enhancement New feature or request label Feb 16, 2025
@huerni huerni added build Build system change and removed build Build system change labels Feb 17, 2025
@huerni huerni requested review from RileyWen and L-Xiafeng February 18, 2025 05:54
request->uid(), request->name(), qos_list, request->force());
if (!rich_res)
response->mutable_rich_error_list()->Add()->CopyFrom(rich_res.error());
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里后面加一个else std::unreachable

Copy link
Collaborator

Choose a reason for hiding this comment

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

不是 这地方参数有点套娃了吧 直接统一unordered set就好了 不需要list和set转来转去

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

partition 可以用unordered set,SetAccountAllowedQos 需要保证顺序,这里是和SetAccountAllowedQos 保持统一了

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

也不是保证顺序,因为SetAccountAllowedQos需要设置default_qos 都换成unordered set也可以,default_qos可以在request中摘出来,然后单独传进去

Copy link
Collaborator

@L-Xiafeng L-Xiafeng Mar 6, 2025

Choose a reason for hiding this comment

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

这里defaultqos也不支持批量吧?default和普通的走不一样的逻辑就好了。
把defaultqos直接作为user的属性,然后可以普通的换成unorderedset

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

原逻辑是 SetAccountAllowedQos时,如果default_qos需要更换, 是把传入的第一个作为default qos,我这里遵循了原逻辑为了保证顺序所以这么写的 整体换成unorderedset也可以,只要在换成unorderedset之前确定default_qos,就能和原逻辑打平了

Copy link
Collaborator

Choose a reason for hiding this comment

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

这里还是改一下吧,这样依赖顺序感觉有点怪?我看其他的default情况都不是这样的

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

这里改成两个参数,一个std optional default_qos,一个set是普通的qos

@huerni huerni force-pushed the dev/account_multi_refactor branch from 86ef8d9 to 4831cd3 Compare March 3, 2025 04:01
@huerni huerni force-pushed the dev/account_multi_refactor branch from 4831cd3 to 0e44e23 Compare March 6, 2025 05:48
@RileyWen RileyWen force-pushed the dev/account_multi_refactor branch from adc6fad to f2251d4 Compare March 8, 2025 14:14
@@ -352,7 +352,7 @@ message QueryAccountInfoReply {

message QueryUserInfoRequest {
uint32 uid = 1;
string name = 2;
repeated string user_list = 2;
string account = 3;
Copy link
Collaborator

Choose a reason for hiding this comment

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

为什么上面是list 但是account不是list

Copy link
Collaborator

Choose a reason for hiding this comment

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

这个account是default account吗

@@ -377,13 +377,13 @@ message BlockAccountOrUserRequest {
uint32 uid = 1;
bool block = 2;
EntityType entity_type = 3;
string name = 4;
repeated string entity_list = 4;
string account = 5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

同上的问题

@@ -335,6 +335,11 @@ message TrimmedPartitionInfo {
repeated TrimmedCranedInfo craned_lists = 3;
}

message RichError {
string description = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Code在前 description在后

auto res = g_account_manager->DeleteAccount(request->uid(), request->name());
if (res) {
for (const auto &account_name : request->account_list()) {
auto res = g_account_manager->DeleteAccount(request->uid(), account_name);
Copy link
Collaborator

Choose a reason for hiding this comment

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

为啥有的地方是里面for循环 有的地方是外面for循环

util::write_lock_guard user_guard(m_rw_user_mutex_);
util::read_lock_guard account_guard(m_rw_account_mutex_);

const User* p = GetExistedUserInfoNoLock_(name);
const User* p = GetExistedUserInfoNoLock_(username);
Copy link
Collaborator

Choose a reason for hiding this comment

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

这种地方不要获取了指针但是又是在另外一个函数的里面检查这个指针是不是空 很容易漏掉 要么就直接封一个CheckIfUidHasPermOnUserOfAccountNoLock_

}

for (const auto &it : res_user_map) {
for (const auto &it : res.value()) {
const auto &user = it.second;
for (const auto &[account, item] : user.account_to_attrs_map) {
if (!request->account().empty() && account != request->account()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这地方逻辑写的好奇怪 下面account就是一个ranges find就可以解决吧 然后其他user的信息设置提到外面去就行吧

@RileyWen RileyWen marked this pull request as draft March 8, 2025 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

新增统一管理账号接口
3 participants