Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
1daidai1 committed Nov 29, 2024
1 parent 72ed5c0 commit b65d967
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/CraneCtld/CtldGrpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,8 +978,8 @@ CtldServer::SubmitTaskToScheduler(std::unique_ptr<TaskInCtld> 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
26 changes: 11 additions & 15 deletions src/CraneCtld/TaskScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -2723,13 +2723,12 @@ void TaskScheduler::PersistAndTransferTasksToMongodb_(
}
}

result::result<void, std::pair<CraneErr, std::string>>
TaskScheduler::AcquireTaskAttributes(TaskInCtld* task) {
result::result<void, std::string> 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;

Expand Down Expand Up @@ -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<std::string> 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));
}
Expand All @@ -2779,9 +2776,8 @@ TaskScheduler::AcquireTaskAttributes(TaskInCtld* task) {
std::list<std::string> 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));
}
Expand Down
7 changes: 3 additions & 4 deletions src/CraneCtld/TaskScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,10 @@ class TaskScheduler {
return TerminateRunningTaskNoLock_(iter->second.get());
}

static result::result<void, std::pair<CraneErr, std::string>>
AcquireTaskAttributes(TaskInCtld* task);
static result::result<void, std::string> AcquireTaskAttributes(
TaskInCtld* task);

static result::result<void, std::string>
CheckTaskValidity(TaskInCtld* task);
static result::result<void, std::string> CheckTaskValidity(TaskInCtld* task);

private:
template <class... Ts>
Expand Down

0 comments on commit b65d967

Please sign in to comment.