-
Notifications
You must be signed in to change notification settings - Fork 20
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
base: master
Are you sure you want to change the base?
Conversation
d0ba76c
to
e61cd33
Compare
if (!user_result) return std::unexpected(user_result.error()); | ||
const User* op_user = user_result.value(); | ||
result = CheckIfUserHasPermOnUserOfAccountNoLock_(*op_user, p, | ||
&actual_account, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个地方还是语义太松了 啥东西都往参数里塞后面这东西没法维护
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个不太好改,参数都是必需的,除非把这个函数拆了
src/CraneCtld/CtldGrpcServer.cpp
Outdated
request->uid(), request->name(), qos_list, request->force()); | ||
if (!rich_res) | ||
response->mutable_rich_error_list()->Add()->CopyFrom(rich_res.error()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里后面加一个else std::unreachable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不是 这地方参数有点套娃了吧 直接统一unordered set就好了 不需要list和set转来转去
There was a problem hiding this comment.
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 保持统一了
There was a problem hiding this comment.
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中摘出来,然后单独传进去
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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,就能和原逻辑打平了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里还是改一下吧,这样依赖顺序感觉有点怪?我看其他的default情况都不是这样的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好
There was a problem hiding this comment.
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
86ef8d9
to
4831cd3
Compare
4831cd3
to
0e44e23
Compare
adc6fad
to
f2251d4
Compare
@@ -352,7 +352,7 @@ message QueryAccountInfoReply { | |||
|
|||
message QueryUserInfoRequest { | |||
uint32 uid = 1; | |||
string name = 2; | |||
repeated string user_list = 2; | |||
string account = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么上面是list 但是account不是list
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这地方逻辑写的好奇怪 下面account就是一个ranges find就可以解决吧 然后其他user的信息设置提到外面去就行吧
No description provided.