From 535868118e675a47e20189a3a600bbaa6afa638d Mon Sep 17 00:00:00 2001 From: db <1301189887@qq.com> Date: Mon, 16 Dec 2024 10:33:39 +0800 Subject: [PATCH] fix conflicts --- protos/PublicDefs.proto | 141 +++++++++--------- src/CraneCtld/AccountManager.cpp | 14 +- src/CraneCtld/CtldGrpcServer.cpp | 7 +- src/CraneCtld/TaskScheduler.cpp | 17 ++- .../PublicHeader/include/crane/PublicHeader.h | 136 +++++++++-------- 5 files changed, 163 insertions(+), 152 deletions(-) diff --git a/protos/PublicDefs.proto b/protos/PublicDefs.proto index 4e3d4196..0f1f9c23 100644 --- a/protos/PublicDefs.proto +++ b/protos/PublicDefs.proto @@ -319,76 +319,77 @@ message TrimmedPartitionInfo { enum ErrCode { SUCCESS = 0; // Success - ERR_INVALID_UID = 10001; // Invalid UID passed - ERR_INVALID_OP_USER = 10002; // Invalid operation user - ERR_INVALID_USER = 10003; // Invalid user - ERR_PERMISSION_USER = 10004; // User permissions too low, no permission to operate - ERR_BLOCKED_USER = 10005; - ERR_USER_DUPLICATE_ACCOUNT= 10006; // User duplicate account insertion - ERR_USER_ALLOWED_ACCOUNT = 10007; // User does not have permission for the account - ERR_INVALID_ADMIN_LEVEL = 10008; // Invalid permission level - ERR_USER_ACCOUNT_MISMATCH = 10009; // User does not belong to the account - ERR_NO_ACCOUNT_SPECIFIED = 10010; - - ERR_INVALID_ACCOUNT = 10011; // Invalid account - ERR_DUPLICATE_ACCOUNT = 10012; // Duplicate account insertion - ERR_INVALID_PARENTACCOUNT = 10013; // Invalid parent account - ERR_DELETE_ACCOUNT = 10014; // Account has child nodes - ERR_BLOCKED_ACCOUNT = 10015; - - ERR_INVALID_PARTITION = 10016; // Invalid partition, partition does not exist - ERR_ALLOWED_PARTITION = 10017; // Account/user does not include this partition - ERR_DUPLICATE_PARTITION = 10018; // Account/user duplicate insertion - ERR_PARENT_ALLOWED_PARTITION = 10019; // Parent account does not include this partition - ERR_USER_EMPTY_PARTITION = 10020; // Cannot add QoS when user has no partition - ERR_CHILD_HAS_PARTITION = 10021; // Partition '{}' is used by some descendant node of the account '{}'. Ignoring this constraint with forced operation. - ERR_HAS_NO_QOS_IN_PARTITION = 10022; - ERR_HAS_ALLOWED_QOS_IN_PARTITION = 10023; - - ERR_INVALID_QOS = 10024; // Invalid QoS, QoS does not exist - ERR_DB_DUPLICATE_QOS = 10025; // Duplicate QoS insertion in the database. - ERR_DELETE_QOS = 10026; // QoS reference count is not zero. - ERR_CONVERT_TO_INTERGER = 10027; // String to integer conversion failed - ERR_TIME_LIMIT = 10028; // Invalid time value - ERR_ALLOWED_QOS = 10029; // Account/user does not include this QoS. - ERR_DUPLICATE_QOS = 10030; // Account/user duplicate insertion. - ERR_PARENT_ALLOWED_QOS = 10031; // Parent account does not include this QoS. - ERR_SET_ALLOWED_QOS = 10032; // QoS '{}' is the default QoS of partition '{}', but not found in the new QoS list. - ERR_ALLOWED_DEFAULT_QOS = 10033; // Default QoS is not in the allowed QoS list - ERR_DUPLICATE_DEFAULT_QOS = 10034; // Duplicate default QoS setting - ERR_CHILD_HAS_DEFAULT_QOS = 10035; // Someone is using QoS '{}' as default QoS. Ignoring this constraint with forced deletion, the deleted default QoS is randomly replaced with one of the remaining items in the QoS list. - ERR_SET_ACCOUNT_QOS = 10036; // QoS '{}' is used by some descendant node or itself of the account '{}'. Ignoring this constraint with forced operation. - ERR_SET_DEFAULT_QOS = 10037; // Qos '{}' not in allowed qos list or is already the default qos - ERR_IS_DEFAULT_QOS = 10038; - - ERR_UPDATE_DATABASE = 10039; // Database update failed - - ERR_GENERIC_FAILURE = 10100; - ERR_NO_RESOURCE = 10101; - ERR_NON_EXISTENT = 10102; - ERR_INVALID_NODE_NUM = 10103; - ERR_INVAILD_NODE_LIST = 10104; - ERR_INVAILD_EX_NODE_LIST = 10105; - ERR_TIME_TIMIT_BEYOND = 10106; - ERR_CPUS_PER_TASK_BEYOND = 10107; - ERR_NO_ENOUGH_NODE = 10108; - - ERR_SYSTEM_ERR = 10109; - ERR_EXISTING_TASK = 10110; - ERR_BEYOND_TASK_ID = 10111; - ERR_INVALID_PARAM = 10112; - ERR_STOP = 10113; - ERR_PERMISSION_DENIED = 10114; - ERR_CONNECTION_TIMEOUT = 10115; - ERR_CONNECTION_ABORTED = 10116; - ERR_RPC_FAILURE = 10117; - ERR_TOKEN_REQUEST_FAILURE = 10118; - ERR_STREAM_BROKEN = 10119; - ERR_INVALID_STUB = 10120; - ERR_CGROUP = 10121; - ERR_PROTOBUF = 10122; - ERR_LIB_EVENT = 10123; - ERR_NO_AVAIL_NODE = 10124; + ERR_INVALID_UID = 1; // Invalid UID passed + ERR_INVALID_OP_USER = 2; // Invalid operation user + ERR_INVALID_USER = 3; // Invalid user + ERR_PERMISSION_USER = 4; // User permissions too low, no permission to operate + ERR_BLOCKED_USER = 5; + ERR_USER_DUPLICATE_ACCOUNT= 6; // User duplicate account insertion + ERR_USER_ALLOWED_ACCOUNT = 7; // User does not have permission for the account + ERR_INVALID_ADMIN_LEVEL = 8; // Invalid permission level + ERR_USER_ACCOUNT_MISMATCH = 9; // User does not belong to the account + ERR_NO_ACCOUNT_SPECIFIED = 10; + + ERR_INVALID_ACCOUNT = 11; // Invalid account + ERR_DUPLICATE_ACCOUNT = 12; // Duplicate account insertion + ERR_INVALID_PARENTACCOUNT = 13; // Invalid parent account + ERR_DELETE_ACCOUNT = 14; // Account has child nodes + ERR_BLOCKED_ACCOUNT = 15; + + ERR_INVALID_PARTITION = 16; // Invalid partition, partition does not exist + ERR_ALLOWED_PARTITION = 17; // Account/user does not include this partition + ERR_DUPLICATE_PARTITION = 18; // Account/user duplicate insertion + ERR_PARENT_ALLOWED_PARTITION = 19; // Parent account does not include this partition + ERR_USER_EMPTY_PARTITION = 20; // Cannot add QoS when user has no partition + ERR_CHILD_HAS_PARTITION = 21; // Partition '{}' is used by some descendant node of the account '{}'. Ignoring this constraint with forced operation. + ERR_HAS_NO_QOS_IN_PARTITION = 22; + ERR_HAS_ALLOWED_QOS_IN_PARTITION = 23; + + ERR_INVALID_QOS = 24; // Invalid QoS, QoS does not exist + ERR_DB_DUPLICATE_QOS = 25; // Duplicate QoS insertion in the database. + ERR_DELETE_QOS = 26; // QoS reference count is not zero. + ERR_CONVERT_TO_INTERGER = 27; // String to integer conversion failed + ERR_TIME_LIMIT = 28; // Invalid time value + ERR_ALLOWED_QOS = 29; // Account/user does not include this QoS. + ERR_DUPLICATE_QOS = 30; // Account/user duplicate insertion. + ERR_PARENT_ALLOWED_QOS = 31; // Parent account does not include this QoS. + ERR_SET_ALLOWED_QOS = 32; // QoS '{}' is the default QoS of partition '{}', but not found in the new QoS list. + ERR_ALLOWED_DEFAULT_QOS = 33; // Default QoS is not in the allowed QoS list + ERR_DUPLICATE_DEFAULT_QOS = 34; // Duplicate default QoS setting + ERR_CHILD_HAS_DEFAULT_QOS = 35; // Someone is using QoS '{}' as default QoS. Ignoring this constraint with forced deletion, the deleted default QoS is randomly replaced with one of the remaining items in the QoS list. + ERR_SET_ACCOUNT_QOS = 36; // QoS '{}' is used by some descendant node or itself of the account '{}'. Ignoring this constraint with forced operation. + ERR_SET_DEFAULT_QOS = 37; // Qos '{}' not in allowed qos list or is already the default qos + ERR_IS_DEFAULT_QOS = 38; + + ERR_UPDATE_DATABASE = 39; // Database update failed + + ERR_GENERIC_FAILURE = 40; + ERR_NO_RESOURCE = 41; + ERR_NON_EXISTENT = 42; + ERR_INVALID_NODE_NUM = 43; + ERR_INVAILD_NODE_LIST = 44; + ERR_INVAILD_EX_NODE_LIST = 45; + ERR_TIME_TIMIT_BEYOND = 46; + ERR_CPUS_PER_TASK_BEYOND = 47; + ERR_NO_ENOUGH_NODE = 48; + + ERR_SYSTEM_ERR = 49; + ERR_EXISTING_TASK = 50; + ERR_BEYOND_TASK_ID = 51; + ERR_INVALID_PARAM = 52; + ERR_STOP = 53; + ERR_PERMISSION_DENIED = 54; + ERR_CONNECTION_TIMEOUT = 55; + ERR_CONNECTION_ABORTED = 56; + ERR_RPC_FAILURE = 57; + ERR_TOKEN_REQUEST_FAILURE = 58; + ERR_STREAM_BROKEN = 59; + ERR_INVALID_STUB = 60; + ERR_CGROUP = 61; + ERR_PROTOBUF = 62; + ERR_LIB_EVENT = 63; + ERR_NO_AVAIL_NODE = 64; + ERR_CODE_COUNT = 65; } enum EntityType { diff --git a/src/CraneCtld/AccountManager.cpp b/src/CraneCtld/AccountManager.cpp index 820f7c76..091092b4 100644 --- a/src/CraneCtld/AccountManager.cpp +++ b/src/CraneCtld/AccountManager.cpp @@ -907,6 +907,8 @@ CraneErrCodeExpected AccountManager::CheckIfUserOfAccountIsEnabled( do { const Account* account_ptr = GetExistedAccountInfoNoLock_(account_name); if (account_ptr->blocked) { + CRANE_ERROR("Ancestor account '{}' is blocked", + account_ptr->name); return std::unexpected(crane::grpc::ErrCode::ERR_BLOCKED_ACCOUNT); } account_name = account_ptr->parent_account; @@ -914,20 +916,20 @@ CraneErrCodeExpected AccountManager::CheckIfUserOfAccountIsEnabled( const User* user_ptr = GetExistedUserInfoNoLock_(user); if (user_ptr->account_to_attrs_map.at(account).blocked) { + CRANE_ERROR("User '{}' is blocked", user_ptr->name); return std::unexpected(crane::grpc::ErrCode::ERR_BLOCKED_USER); } return {}; } -AccountManager::CraneExpected AccountManager::CheckAndApplyQosLimitOnTask(const std::string& user, - const std::string& account, - TaskInCtld* task) { +AccountManager::CraneExpected AccountManager::CheckAndApplyQosLimitOnTask( + const std::string& user, const std::string& account, TaskInCtld* task) { util::read_lock_guard user_guard(m_rw_user_mutex_); util::read_lock_guard qos_guard(m_rw_qos_mutex_); const User* user_share_ptr = GetExistedUserInfoNoLock_(user); if (!user_share_ptr) { - CRANE_ERROR("CheckAndApplyQosLimitOnTask error: Unknown user {}", user); + CRANE_ERROR("Unknown user {}", user); return std::unexpected(CraneErrCode::ERR_INVALID_OP_USER); } @@ -937,9 +939,7 @@ AccountManager::CraneExpected AccountManager::CheckAndApplyQosLimitOnTask( if (partition_it == user_share_ptr->account_to_attrs_map.at(account) .allowed_partition_qos_map.end()) { - CRANE_ERROR( - "CheckAndApplyQosLimitOnTask error: Partition is not allowed for " - "this user"); + CRANE_ERROR("Partition is not allowed for this user"); return std::unexpected(CraneErrCode::ERR_ALLOWED_PARTITION); } if (task->qos.empty()) { diff --git a/src/CraneCtld/CtldGrpcServer.cpp b/src/CraneCtld/CtldGrpcServer.cpp index a28816fc..cd84f9f8 100644 --- a/src/CraneCtld/CtldGrpcServer.cpp +++ b/src/CraneCtld/CtldGrpcServer.cpp @@ -938,6 +938,7 @@ CraneErrCodeExpected > CtldServer::SubmitTaskToScheduler(std::unique_ptr task) { if (!task->password_entry->Valid()) { + CRANE_ERROR("Uid {} not found on the controller node", task->uid); return std::unexpected(crane::grpc::ErrCode::ERR_INVALID_UID); } task->SetUsername(task->password_entry->Username()); @@ -946,6 +947,7 @@ CtldServer::SubmitTaskToScheduler(std::unique_ptr task) { auto user_scoped_ptr = g_account_manager->GetExistedUserInfo(task->Username()); if (!user_scoped_ptr) { + CRANE_ERROR("User '{}' not found in the account database", task->Username()); return std::unexpected(crane::grpc::ErrCode::ERR_INVALID_USER); } @@ -954,6 +956,7 @@ CtldServer::SubmitTaskToScheduler(std::unique_ptr task) { task->MutableTaskToCtld()->set_account(user_scoped_ptr->default_account); } else { if (!user_scoped_ptr->account_to_attrs_map.contains(task->account)) { + CRANE_ERROR("Account '{}' is not in your account list", task->account); return std::unexpected(crane::grpc::ErrCode::ERR_USER_ACCOUNT_MISMATCH); } } @@ -961,7 +964,9 @@ CtldServer::SubmitTaskToScheduler(std::unique_ptr task) { if (!g_account_manager->CheckUserPermissionToPartition( task->Username(), task->account, task->partition_id)) { - return std::unexpected(crane::grpc::ErrCode::ERR_ALLOWED_PARTITION); + CRANE_ERROR("User '{}' doesn't have permission to use partition '{}' when using account '{}'", + task->Username(), task->partition_id, task->account); + return std::unexpected(crane::grpc::ErrCode::ERR_ALLOWED_PARTITION); } auto enable_res = g_account_manager->CheckIfUserOfAccountIsEnabled( diff --git a/src/CraneCtld/TaskScheduler.cpp b/src/CraneCtld/TaskScheduler.cpp index 86e5752b..8b7d5323 100644 --- a/src/CraneCtld/TaskScheduler.cpp +++ b/src/CraneCtld/TaskScheduler.cpp @@ -2720,8 +2720,11 @@ void TaskScheduler::PersistAndTransferTasksToMongodb_( CraneErrCodeExpected TaskScheduler::AcquireTaskAttributes(TaskInCtld* task) { auto part_it = g_config.Partitions.find(task->partition_id); - if (part_it == g_config.Partitions.end()) + if (part_it == g_config.Partitions.end()) { + CRANE_ERROR("Failed to call AcquireTaskAttributes: {}", + CraneErrCodeStr(crane::grpc::ErrCode::ERR_INVALID_PARTITION)); return std::unexpected(crane::grpc::ErrCode::ERR_INVALID_PARTITION); + } task->partition_priority = part_it->second.priority; @@ -2749,7 +2752,11 @@ CraneErrCodeExpected TaskScheduler::AcquireTaskAttributes(TaskInCtld* task auto check_qos_result = g_account_manager->CheckAndApplyQosLimitOnTask( task->Username(), task->account, task); - if (!check_qos_result) return check_qos_result; + if (!check_qos_result) { + CRANE_ERROR("Failed to call CheckAndApplyQosLimitOnTask: {}", + CraneErrCodeStr(check_qos_result.error())); + return check_qos_result; + } if (!task->TaskToCtld().nodelist().empty() && task->included_nodes.empty()) { std::list nodes; @@ -2802,7 +2809,7 @@ CraneErrCodeExpected TaskScheduler::CheckTaskValidity(TaskInCtld* task) { .memory_sw_bytes), util::ReadableTypedDeviceMap( metas_ptr->partition_global_meta.res_total.GetDeviceMap())); - return std::unexpected(crane::grpc::ErrCode::ERR_NO_RESOURCE) ; + return std::unexpected(crane::grpc::ErrCode::ERR_NO_RESOURCE); } if (task->node_num > metas_ptr->craned_ids.size()) { @@ -2810,7 +2817,7 @@ CraneErrCodeExpected TaskScheduler::CheckTaskValidity(TaskInCtld* task) { "Nodes not enough for task #{}. " "Partition total Nodes: {}", task->TaskId(), metas_ptr->craned_ids.size()); - return std::unexpected(crane::grpc::ErrCode::ERR_INVALID_NODE_NUM); + return std::unexpected(crane::grpc::ErrCode::ERR_INVALID_NODE_NUM); } auto craned_meta_map = g_meta_container->GetCranedMetaMapConstPtr(); @@ -2832,7 +2839,7 @@ CraneErrCodeExpected TaskScheduler::CheckTaskValidity(TaskInCtld* task) { "Resource not enough. Task #{} needs {} nodes, while only {} " "nodes satisfy its requirement.", task->TaskId(), task->node_num, avail_nodes.size()); - return std::unexpected(crane::grpc::ErrCode::ERR_NO_ENOUGH_NODE); + return std::unexpected(crane::grpc::ErrCode::ERR_NO_ENOUGH_NODE); } return {}; diff --git a/src/Utilities/PublicHeader/include/crane/PublicHeader.h b/src/Utilities/PublicHeader/include/crane/PublicHeader.h index 5d9a5dd0..2771bb2c 100644 --- a/src/Utilities/PublicHeader/include/crane/PublicHeader.h +++ b/src/Utilities/PublicHeader/include/crane/PublicHeader.h @@ -151,70 +151,72 @@ constexpr std::array "Not enough nodes which satisfy resource requirements", }; -const std::unordered_map ErrCodeStrMap = { - {crane::grpc::ErrCode::SUCCESS, "Success"}, - {crane::grpc::ErrCode::ERR_INVALID_UID, "Invalid UID"}, - {crane::grpc::ErrCode::ERR_INVALID_OP_USER, "You are not a user of Crane"}, - {crane::grpc::ErrCode::ERR_INVALID_USER, "The entered user is not a user of Crane"}, - {crane::grpc::ErrCode::ERR_PERMISSION_USER, "Your permission is insufficient"}, - {crane::grpc::ErrCode::ERR_USER_DUPLICATE_ACCOUNT, "The user already exists in this account"}, - {crane::grpc::ErrCode::ERR_USER_ALLOWED_ACCOUNT, "he user is not allowed to access account"}, - {crane::grpc::ErrCode::ERR_INVALID_ADMIN_LEVEL, "Unknown admin level"}, - {crane::grpc::ErrCode::ERR_USER_ACCOUNT_MISMATCH, "The user does not belong to this account"}, - {crane::grpc::ErrCode::ERR_NO_ACCOUNT_SPECIFIED, "No account is specified for the user"}, - {crane::grpc::ErrCode::ERR_INVALID_ACCOUNT, "The entered account does not exist"}, - {crane::grpc::ErrCode::ERR_DUPLICATE_ACCOUNT, "The account already exists in the crane"}, - {crane::grpc::ErrCode::ERR_INVALID_PARENTACCOUNT, "The parent account of the entered account does not exist"}, - {crane::grpc::ErrCode::ERR_DELETE_ACCOUNT, "The account has child account or users, unable to delete"}, - {crane::grpc::ErrCode::ERR_INVALID_PARTITION, "The entered partition does not exist"}, - {crane::grpc::ErrCode::ERR_ALLOWED_PARTITION, "The entered account or user does not include this partition"}, - {crane::grpc::ErrCode::ERR_DUPLICATE_PARTITION, "The partition already exists in the account or user"}, - {crane::grpc::ErrCode::ERR_PARENT_ALLOWED_PARTITION, "Parent account does not include the partition"}, - {crane::grpc::ErrCode::ERR_USER_EMPTY_PARTITION, "The user does not contain any partitions, operation cannot be performed"}, - {crane::grpc::ErrCode::ERR_CHILD_HAS_PARTITION, "Child has partiton error"}, - {crane::grpc::ErrCode::ERR_HAS_NO_QOS_IN_PARTITION, "The user has no QoS available for this partition to be used"}, - {crane::grpc::ErrCode::ERR_HAS_ALLOWED_QOS_IN_PARTITION, "The qos you set is not in partition's allowed qos list"}, - {crane::grpc::ErrCode::ERR_INVALID_QOS, "The entered qos does not exist"}, - {crane::grpc::ErrCode::ERR_DB_DUPLICATE_QOS, "Qos already exists in the crane"}, - {crane::grpc::ErrCode::ERR_DELETE_QOS, "QoS is still being used by accounts or users, unable to delete"}, - {crane::grpc::ErrCode::ERR_CONVERT_TO_INTERGER, "Failed to convert value to integer"}, - {crane::grpc::ErrCode::ERR_TIME_LIMIT, "Invalid time limit value"}, - {crane::grpc::ErrCode::ERR_ALLOWED_QOS, "The entered account or user does not include this qos"}, - {crane::grpc::ErrCode::ERR_DUPLICATE_QOS, "The Qos already exists in the account or user"}, - {crane::grpc::ErrCode::ERR_PARENT_ALLOWED_QOS, "Parent account does not include the qos"}, - {crane::grpc::ErrCode::ERR_SET_ALLOWED_QOS, "Set allowed qos error"}, - {crane::grpc::ErrCode::ERR_ALLOWED_DEFAULT_QOS, "The entered default_qos is not allowed"}, - {crane::grpc::ErrCode::ERR_DUPLICATE_DEFAULT_QOS, "The QoS is already the default QoS for the account or specified partition of the user"}, - {crane::grpc::ErrCode::ERR_CHILD_HAS_DEFAULT_QOS, "child accounts has default error"}, - {crane::grpc::ErrCode::ERR_SET_ACCOUNT_QOS, "set account qos error"}, - {crane::grpc::ErrCode::ERR_SET_DEFAULT_QOS, "The Qos not allowed or is already the default qos"}, - {crane::grpc::ErrCode::ERR_IS_DEFAULT_QOS, "Is default qos error"}, - {crane::grpc::ErrCode::ERR_UPDATE_DATABASE, "Fail to update data in database"}, - {crane::grpc::ErrCode::ERR_GENERIC_FAILURE, "Generic Failure"}, - {crane::grpc::ErrCode::ERR_NO_RESOURCE, "Resource not enough for task"}, - {crane::grpc::ErrCode::ERR_NON_EXISTENT, "Non-existent Error"}, - {crane::grpc::ErrCode::ERR_INVALID_NODE_NUM, "Nodes partition not enough for task"}, - {crane::grpc::ErrCode::ERR_INVAILD_NODE_LIST, "Invalid node list"}, - {crane::grpc::ErrCode::ERR_INVAILD_EX_NODE_LIST, "Invalid exclude node list"}, - {crane::grpc::ErrCode::ERR_TIME_TIMIT_BEYOND, "Time-limit reached the user's limit"}, - {crane::grpc::ErrCode::ERR_CPUS_PER_TASK_BEYOND, "cpus-per-task reached the user's limit"}, - {crane::grpc::ErrCode::ERR_NO_ENOUGH_NODE, "Nodes num not enough for task"}, - {crane::grpc::ErrCode::ERR_SYSTEM_ERR, "System Error"}, - {crane::grpc::ErrCode::ERR_EXISTING_TASK, "Existing Task"}, - {crane::grpc::ErrCode::ERR_BEYOND_TASK_ID, "System error occurred or the number of pending tasks exceeded maximum value"}, - {crane::grpc::ErrCode::ERR_INVALID_PARAM, "Invalid Parameter"}, - {crane::grpc::ErrCode::ERR_STOP, "Stop Error"}, - {crane::grpc::ErrCode::ERR_PERMISSION_DENIED, "Permission Denied"}, - {crane::grpc::ErrCode::ERR_CONNECTION_TIMEOUT, "Connection Timeout"}, - {crane::grpc::ErrCode::ERR_CONNECTION_ABORTED, "Connection Aborted"}, - {crane::grpc::ErrCode::ERR_RPC_FAILURE, "RPC Failure"}, - {crane::grpc::ErrCode::ERR_TOKEN_REQUEST_FAILURE, "Token Request Failure"}, - {crane::grpc::ErrCode::ERR_STREAM_BROKEN, "Stream Broken"}, - {crane::grpc::ErrCode::ERR_INVALID_STUB, "Invalid Stub"}, - {crane::grpc::ErrCode::ERR_CGROUP, "CGroup Error"}, - {crane::grpc::ErrCode::ERR_PROTOBUF, "Protobuf Error"}, - {crane::grpc::ErrCode::ERR_LIB_EVENT, "Lib Event Error"}, - {crane::grpc::ErrCode::ERR_NO_AVAIL_NODE, "No Available Node"} +constexpr std::array ErrCodeStrArray = { + "Success", + "Invalid UID", + "You are not a user of Crane", + "The entered user is not a user of Crane", + "Your permission is insufficient", + "The user has been blocked", + "The user already exists in this account", + "he user is not allowed to access account", + "Unknown admin level", + "The user does not belong to this account", + "No account is specified for the user", + "The entered account does not exist", + "The account already exists in the crane", + "The parent account of the entered account does not exist", + "The account has child account or users, unable to delete", + "The account has been blocked", + "The entered partition does not exist", + "The entered account or user does not include this partition", + "The partition already exists in the account or user", + "Parent account does not include the partition", + "The user does not contain any partitions, operation cannot be performed", + "Child has partiton error", + "The user has no QoS available for this partition to be used", + "The qos you set is not in partition's allowed qos list", + "The entered qos does not exist", + "Qos already exists in the crane", + "QoS is still being used by accounts or users, unable to delete", + "Failed to convert value to integer", + "Invalid time limit value", + "The entered account or user does not include this qos", + "The Qos already exists in the account or user", + "Parent account does not include the qos", + "Set allowed qos error", + "The entered default_qos is not allowed", + "The QoS is already the default QoS for the account or specified partition of the user", + "child accounts has default error", + "set account qos error", + "The Qos not allowed or is already the default qos", + "Is default qos error", + "Fail to update data in database", + "Generic Failure", + "Resource not enough for task", + "Non-existent Error", + "Nodes partition not enough for task", + "Invalid node list", + "Invalid exclude node list", + "Time-limit reached the user's limit", + "cpus-per-task reached the user's limit", + "Nodes num not enough for task", + "System Error", + "Existing Task", + "System error occurred or the number of pending tasks exceeded maximum value", + "Invalid Parameter", + "Stop Error", + "Permission Denied", + "Connection Timeout", + "Connection Aborted", + "RPC Failure", + "Token Request Failure", + "Stream Broken", + "Invalid Stub", + "CGroup Error", + "Protobuf Error", + "Lib Event Error", + "No Available Node" }; } @@ -224,11 +226,7 @@ inline std::string_view CraneErrStr(CraneErr err) { } inline std::string_view CraneErrCodeStr(crane::grpc::ErrCode err) { - auto it = Internal::ErrCodeStrMap.find(err); - if (it != Internal::ErrCodeStrMap.end()) { - return it->second; - } - return "Unknown Error"; + return Internal::CraneErrStrArr[uint16_t(err)]; } /* ----------- Public definitions for all components */