diff --git a/src/CraneCtld/CtldGrpcServer.cpp b/src/CraneCtld/CtldGrpcServer.cpp index d8942731c..bf327e372 100644 --- a/src/CraneCtld/CtldGrpcServer.cpp +++ b/src/CraneCtld/CtldGrpcServer.cpp @@ -978,8 +978,8 @@ CtldServer::SubmitTaskToScheduler(std::unique_ptr task) { return {std::move(future)}; } - CRANE_DEBUG("Task submission failed. Reason: {}.", result.error().second); - return result::fail(result.error().second); + CRANE_DEBUG("Task submission failed. Reason: {}.", result.error()); + return result::fail(result.error()); } } // namespace Ctld diff --git a/src/CraneCtld/TaskScheduler.cpp b/src/CraneCtld/TaskScheduler.cpp index 7732e59d2..776a8efcf 100644 --- a/src/CraneCtld/TaskScheduler.cpp +++ b/src/CraneCtld/TaskScheduler.cpp @@ -102,9 +102,9 @@ bool TaskScheduler::Init() { CRANE_INFO( "Failed to acquire task attributes for restored running task " "#{}. " - "Error Code: {}. " + "Error Reason: {}. " "Mark it as FAILED and move it to the ended queue.", - task_id, CraneErrStr(result.error().first)); + task_id, result.error()); else { CRANE_INFO("Mark running interactive task {} as FAILED.", task_id); for (const CranedId& craned_id : task->CranedIds()) { @@ -2723,13 +2723,12 @@ void TaskScheduler::PersistAndTransferTasksToMongodb_( } } -result::result> -TaskScheduler::AcquireTaskAttributes(TaskInCtld* task) { +result::result TaskScheduler::AcquireTaskAttributes( + TaskInCtld* task) { auto part_it = g_config.Partitions.find(task->partition_id); if (part_it == g_config.Partitions.end()) - return result::fail(std::make_pair( - CraneErr::kInvalidParam, - fmt::format("Partition {} doesn't exist", task->partition_id))); + return result::fail( + fmt::format("Partition {} doesn't exist", task->partition_id)); task->partition_priority = part_it->second.priority; @@ -2760,17 +2759,15 @@ TaskScheduler::AcquireTaskAttributes(TaskInCtld* task) { if (check_qos_result.has_error()) { CRANE_ERROR("Failed to call CheckAndApplyQosLimitOnTask: {}", check_qos_result.error()); - return result::fail( - std::make_pair(CraneErr::kInvalidParam, check_qos_result.error())); + return result::fail(check_qos_result.error()); } if (!task->TaskToCtld().nodelist().empty() && task->included_nodes.empty()) { std::list nodes; bool ok = util::ParseHostList(task->TaskToCtld().nodelist(), &nodes); if (!ok) - return result::fail(std::make_pair( - CraneErr::kInvalidParam, - fmt::format("nodelist {} error", task->TaskToCtld().nodelist()))); + return result::fail( + fmt::format("nodelist {} error", task->TaskToCtld().nodelist())); for (auto&& node : nodes) task->included_nodes.emplace(std::move(node)); } @@ -2779,9 +2776,8 @@ TaskScheduler::AcquireTaskAttributes(TaskInCtld* task) { std::list nodes; bool ok = util::ParseHostList(task->TaskToCtld().excludes(), &nodes); if (!ok) - return result::fail(std::make_pair( - CraneErr::kInvalidParam, fmt::format("excludes nodelist {} error", - task->TaskToCtld().excludes()))); + return result::fail(fmt::format("excludes nodelist {} error", + task->TaskToCtld().excludes())); for (auto&& node : nodes) task->excluded_nodes.emplace(std::move(node)); } diff --git a/src/CraneCtld/TaskScheduler.h b/src/CraneCtld/TaskScheduler.h index 552df185b..0278949b4 100644 --- a/src/CraneCtld/TaskScheduler.h +++ b/src/CraneCtld/TaskScheduler.h @@ -282,11 +282,10 @@ class TaskScheduler { return TerminateRunningTaskNoLock_(iter->second.get()); } - static result::result> - AcquireTaskAttributes(TaskInCtld* task); + static result::result AcquireTaskAttributes( + TaskInCtld* task); - static result::result - CheckTaskValidity(TaskInCtld* task); + static result::result CheckTaskValidity(TaskInCtld* task); private: template