diff --git a/protos/PublicDefs.proto b/protos/PublicDefs.proto index 7e96a3aa..801b857f 100644 --- a/protos/PublicDefs.proto +++ b/protos/PublicDefs.proto @@ -130,6 +130,7 @@ message TaskToCtld { bool requeue_if_failed = 12; bool get_user_env = 13; + uint32 priority = 14; oneof payload { BatchTaskAdditionalMeta batch_meta = 21; diff --git a/src/CraneCtld/DbClient.cpp b/src/CraneCtld/DbClient.cpp index 1bef5af9..62b0c546 100644 --- a/src/CraneCtld/DbClient.cpp +++ b/src/CraneCtld/DbClient.cpp @@ -348,6 +348,8 @@ bool MongodbClient::FetchJobRecords( task->set_type((crane::grpc::TaskType)view["type"].get_int32().value); task->set_extra_attr(view["extra_attr"].get_string().value.data()); + + task->set_priority(view["priority"].get_int64().value); } } catch (const bsoncxx::exception& e) { PrintError_(e.what()); @@ -869,7 +871,7 @@ MongodbClient::document MongodbClient::TaskInEmbeddedDbToDocument_( util::HostNameListToStr(runtime_attr.craned_ids()), runtime_attr.craned_ids().size(), 0, task_to_ctld.partition_name(), // 15-19 - 0, 0, runtime_attr.start_time().seconds(), + task_to_ctld.priority(), 0, runtime_attr.start_time().seconds(), runtime_attr.end_time().seconds(), 0, // 20-24 task_to_ctld.batch_meta().sh_script(), runtime_attr.status(), @@ -942,7 +944,7 @@ MongodbClient::document MongodbClient::TaskInCtldToDocument_(TaskInCtld* task) { static_cast(task->Gid()), task->allocated_craneds_regex, static_cast(task->nodes_alloc), 0, task->partition_id, // 15-19 - 0, 0, task->StartTimeInUnixSecond(), task->EndTimeInUnixSecond(), + static_cast(task->cached_priority), 0, task->StartTimeInUnixSecond(), task->EndTimeInUnixSecond(), 0, // 20-24 script, task->Status(), absl::ToInt64Seconds(task->time_limit), diff --git a/src/CraneCtld/TaskScheduler.cpp b/src/CraneCtld/TaskScheduler.cpp index 46835eb2..0a2b5d38 100644 --- a/src/CraneCtld/TaskScheduler.cpp +++ b/src/CraneCtld/TaskScheduler.cpp @@ -2904,6 +2904,9 @@ std::vector MultiFactorPriority::GetOrderedTaskIdList( task->cached_priority = priority; task->pending_reason = "Priority"; task_priority_vec.emplace_back(task.get(), priority); + task->MutableTaskToCtld()->set_priority(priority); + g_embedded_db_client->UpdateTaskToCtldIfExists(0, task->TaskDbId(), + task->TaskToCtld()); } std::sort(task_priority_vec.begin(), task_priority_vec.end(),