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 dcf7c8d commit 72ed5c0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
52 changes: 24 additions & 28 deletions src/CraneCtld/TaskScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2789,11 +2789,10 @@ TaskScheduler::AcquireTaskAttributes(TaskInCtld* task) {
return {};
}

result::result<void, std::pair<CraneErr, std::string>>
TaskScheduler::CheckTaskValidity(TaskInCtld* task) {
result::result<void, std::string> TaskScheduler::CheckTaskValidity(
TaskInCtld* task) {
if (!CheckIfTimeLimitIsValid(task->time_limit))
return result::fail(std::make_pair(
CraneErr::kInvalidParam, fmt::format("task time_limit is invalid")));
return result::fail(fmt::format("task time_limit is invalid"));

// Check whether the selected partition is able to run this task.
std::unordered_set<std::string> avail_nodes;
Expand Down Expand Up @@ -2823,35 +2822,34 @@ TaskScheduler::CheckTaskValidity(TaskInCtld* task) {
.memory_sw_bytes),
util::ReadableTypedDeviceMap(
metas_ptr->partition_global_meta.res_total.GetDeviceMap()));
return result::fail(std::make_pair(
CraneErr::kNoResource,
fmt::format(
"Resource not enough for task #{}. "
"Partition total: cpu {}, mem: {}, mem+sw: {}, gres: {}",
task->TaskId(),
return result::fail(fmt::format(
"Resource not enough for task #{}. "
"Partition total: cpu {}, mem: {}, mem+sw: {}, gres: {}",
task->TaskId(),
metas_ptr->partition_global_meta.res_total_inc_dead
.GetAllocatableRes()
.cpu_count,
util::ReadableMemory(
metas_ptr->partition_global_meta.res_total_inc_dead
.GetAllocatableRes()
.cpu_count,
util::ReadableMemory(metas_ptr->partition_global_meta
.res_total_inc_dead.GetAllocatableRes()
.memory_bytes),
util::ReadableMemory(metas_ptr->partition_global_meta
.res_total_inc_dead.GetAllocatableRes()
.memory_sw_bytes),
util::ReadableTypedDeviceMap(
metas_ptr->partition_global_meta.res_total.GetDeviceMap()))));
.memory_bytes),
util::ReadableMemory(
metas_ptr->partition_global_meta.res_total_inc_dead
.GetAllocatableRes()
.memory_sw_bytes),
util::ReadableTypedDeviceMap(
metas_ptr->partition_global_meta.res_total.GetDeviceMap())));
}

if (task->node_num > metas_ptr->craned_ids.size()) {
CRANE_TRACE(
"Nodes not enough for task #{}. "
"Partition total Nodes: {}",
task->TaskId(), metas_ptr->craned_ids.size());
return result::fail(std::make_pair(
CraneErr::kInvalidNodeNum,
return result::fail(
fmt::format("Nodes not enough for task #{}. "
"Partition total Nodes: {}",
task->TaskId(), metas_ptr->craned_ids.size())));
task->TaskId(), metas_ptr->craned_ids.size()));
}

auto craned_meta_map = g_meta_container->GetCranedMetaMapConstPtr();
Expand All @@ -2873,12 +2871,10 @@ 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 result::fail(std::make_pair(
CraneErr::kNoAvailNode,
fmt::format(
"Resource not enough. Task #{} needs {} nodes, while only {} "
"nodes satisfy its requirement",
task->TaskId(), task->node_num, avail_nodes.size())));
return result::fail(fmt::format(
"Resource not enough. Task #{} needs {} nodes, while only {} "
"nodes satisfy its requirement",
task->TaskId(), task->node_num, avail_nodes.size()));
}

return {};
Expand Down
2 changes: 1 addition & 1 deletion src/CraneCtld/TaskScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class TaskScheduler {
static result::result<void, std::pair<CraneErr, std::string>>
AcquireTaskAttributes(TaskInCtld* task);

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

private:
Expand Down

0 comments on commit 72ed5c0

Please sign in to comment.