Skip to content

Commit

Permalink
refactor errcode
Browse files Browse the repository at this point in the history
  • Loading branch information
huerni committed Mar 5, 2025
1 parent 8c755ce commit e95a29b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions protos/PublicDefs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ enum ErrCode {

ERR_MAX_JOB_COUNT_PER_USER = 65;
ERR_USER_NO_PRIVILEGE = 66;
ERR_ALLOWEDLIST_MISSING = 67; // The current account is not in the allowed account list for the partition.
ERR_DENYLIST_HIT = 68; // The current account has been explicitly added to the deny list for the partition.
ERR_NOT_IN_ALLOWED_LIST = 67; // The current account is not in the allowed account list for the partition.
ERR_IN_DENIED_LIST = 68; // The current account has been explicitly added to the deny list for the partition.
}

enum EntityType {
Expand Down
8 changes: 4 additions & 4 deletions src/CraneCtld/CraneCtld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,17 +470,17 @@ void ParseConfig(int argc, char** argv) {
auto allowed_accounts_str =
partition["AllowedAccounts"].as<std::string>();
std::vector<std::string> allowed_accounts =
absl::StrSplit(absl::StripAsciiWhitespace(allowed_accounts_str).data(), ",");
absl::StrSplit(allowed_accounts_str.data(), ",");
for (const auto& account_name : allowed_accounts) {
part.allowed_accounts.insert(account_name);
part.allowed_accounts.insert(absl::StripAsciiWhitespace(account_name).data());
}
}

if (partition["DeniedAccounts"] && !partition["DeniedAccounts"].IsNull()) {
auto denied_accounts_str = partition["DeniedAccounts"].as<std::string>();
std::vector<std::string> denied_accounts = absl::StrSplit(absl::StripAsciiWhitespace(denied_accounts_str).data(), ",");
std::vector<std::string> denied_accounts = absl::StrSplit(denied_accounts_str, ",");
for (const auto& account_name : denied_accounts) {
part.denied_accounts.insert(account_name);
part.denied_accounts.insert(absl::StripAsciiWhitespace(account_name).data());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/CraneCtld/CranedMetaContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,15 +648,15 @@ CraneExpected<void> CranedMetaContainer::CheckIfAccountIsAllowedInPartition(
"The account {} is not in the AllowedAccounts of the partition {}"
"specified for the task, submission of the task is prohibited.",
account_name, partition_name);
return std::unexpected(CraneErrCode::ERR_ALLOWEDLIST_MISSING);
return std::unexpected(CraneErrCode::ERR_NOT_IN_ALLOWED_LIST);
}
} else if (!denied_accounts.empty()) {
if (denied_accounts.contains(account_name)) {
CRANE_DEBUG(
"The account {} is in the DeniedAccounts of the partition {}"
"specified for the task, submission of the task is prohibited.",
account_name, partition_name);
return std::unexpected(CraneErrCode::ERR_DENYLIST_HIT);
return std::unexpected(CraneErrCode::ERR_IN_DENIED_LIST);
}
}

Expand Down

0 comments on commit e95a29b

Please sign in to comment.