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/partition allow accounts #404

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

huerni
Copy link
Collaborator

@huerni huerni commented Dec 19, 2024

  1. config文件partition添加AllowAccounts设置,AllowAccounts=,ctld启动时读取配置。
  2. 命令行修改partition的AllowAccounts,无需持久化,持久化只能在config文件进行定义。
  3. ccontrol show partition 添加AllowAccounts条目展示。
  4. 提交任务时判断account是否在partition的AllowAccounts中

@huerni huerni linked an issue Dec 19, 2024 that may be closed by this pull request
@huerni huerni added the enhancement New feature or request label Dec 19, 2024
std::string allow_accounts_str =
partition["AllowAccounts"].as<std::string>();
std::vector<std::string> allow_accounts =
absl::StrSplit(allow_accounts_str, ",");
Copy link
Collaborator

Choose a reason for hiding this comment

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

trim

@@ -283,9 +283,11 @@ void CranedMetaContainer::InitFromConfig(const Config& config) {
part_meta.partition_global_meta.res_total_inc_dead = part_res;
part_meta.partition_global_meta.node_cnt = part_meta.craned_ids.size();
part_meta.partition_global_meta.nodelist_str = partition.nodelist_str;
part_meta.partition_global_meta.allow_accounts = partition.allow_accounts;
Copy link
Collaborator

Choose a reason for hiding this comment

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

allowed_accounts

@@ -976,8 +976,7 @@ std::expected<void, std::string> AccountManager::CheckAndApplyQosLimitOnTask(
return {};
}

std::expected<void, std::string> AccountManager::CheckUidIsAdmin(
uint32_t uid) {
std::expected<void, std::string> AccountManager::CheckUidIsAdmin(uint32_t uid) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这地方也改成返回错误码

const std::unordered_set<std::string>& allow_accounts) {
CraneErrCodeExpected<void> result{};

if (!partition_metas_map_.Contains(partition_name))
Copy link
Collaborator

Choose a reason for hiding this comment

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

这地方有点问题


bool CranedMetaContainer::CheckIfAccountIsAllowedInPartition(
const std::string& partition_name, const std::string& account_name) {
if (!partition_metas_map_.Contains(partition_name)) return false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

锁不连续

allow_accounts.insert(account_name);
}

result = g_account_manager->CheckModifyPartitionAllowAccounts(
Copy link
Collaborator

Choose a reason for hiding this comment

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

错误处理

@@ -980,6 +1013,13 @@ CtldServer::SubmitTaskToScheduler(std::unique_ptr<TaskInCtld> task) {
return std::unexpected(enable_res.error());
}

if (!g_meta_container->CheckIfAccountIsAllowedInPartition(task->partition_id,
Copy link
Collaborator

Choose a reason for hiding this comment

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

这地方有问题吧

@huerni huerni force-pushed the dev/partition_allow_account branch from 59671e1 to e7314d1 Compare January 18, 2025 04:53
@huerni huerni force-pushed the dev/partition_allow_account branch from e7314d1 to 60d444f Compare January 20, 2025 09:21
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.

Partition AllowAccounts
2 participants