Skip to content

Commit

Permalink
chore: Sync protos
Browse files Browse the repository at this point in the history
  • Loading branch information
Nativu5 committed Dec 11, 2024
1 parent c4540ed commit b20fcb3
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 55 deletions.
2 changes: 1 addition & 1 deletion protos/Plugin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ message EndHookReply {
message CreateCgroupHookRequest {
uint32 task_id = 1;
string cgroup = 2;
DedicatedResourceInNode request_res = 3;
DedicatedResourceInNode resource = 3;
}

message CreateCgroupHookReply {
Expand Down
70 changes: 35 additions & 35 deletions protos/PublicDefs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -320,45 +320,45 @@ message TrimmedPartitionInfo {
enum ErrCode {
SUCCESS = 0; // Success

ERR_INVALID_UID = 10001;
ERR_INVALID_OP_USER = 10002;
ERR_INVALID_USER = 10003;
ERR_PERMISSION_USER = 10004;
ERR_USER_DUPLICATE_ACCOUNT = 10005;
ERR_USER_ALLOWED_ACCOUNT = 10006;
ERR_INVALID_ADMIN_LEVEL = 10007;
ERR_USER_ACCOUNT_MISMATCH = 10008;
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_USER_DUPLICATE_ACCOUNT = 10005; // User duplicate account insertion
ERR_USER_ALLOWED_ACCOUNT = 10006; // User does not have permission for the account
ERR_INVALID_ADMIN_LEVEL = 10007; // Invalid permission level
ERR_USER_ACCOUNT_MISMATCH = 10008; // User does not belong to the account
ERR_NO_ACCOUNT_SPECIFIED = 10009;

ERR_INVALID_ACCOUNT = 10010;
ERR_DUPLICATE_ACCOUNT = 10011;
ERR_INVALID_PARENTACCOUNT = 10012;
ERR_DELETE_ACCOUNT = 10013;

ERR_INVALID_PARTITION = 10014;
ERR_ALLOWED_PARTITION = 10015;
ERR_DUPLICATE_PARTITION = 10016;
ERR_PARENT_ALLOWED_PARTITION = 10017;
ERR_USER_EMPTY_PARTITION = 10018;
ERR_CHILD_HAS_PARTITION = 10019;

ERR_INVALID_QOS = 10020;
ERR_DB_DUPLICATE_QOS = 10021;
ERR_DELETE_QOS = 10022;
ERR_CONVERT_TO_INTERGER = 10023;
ERR_TIME_LIMIT = 10024;
ERR_ALLOWED_QOS = 10025;
ERR_DUPLICATE_QOS = 10026;
ERR_PARENT_ALLOWED_QOS = 10027;
ERR_SET_ALLOWED_QOS = 10028;
ERR_ALLOWED_DEFAULT_QOS = 10029;
ERR_DUPLICATE_DEFAULT_QOS = 10030;
ERR_CHILD_HAS_DEFAULT_QOS = 10031;
ERR_SET_ACCOUNT_QOS = 10032;
ERR_SET_DEFAULT_QOS = 10033;
ERR_INVALID_ACCOUNT = 10010; // Invalid account
ERR_DUPLICATE_ACCOUNT = 10011; // Duplicate account insertion
ERR_INVALID_PARENTACCOUNT = 10012; // Invalid parent account
ERR_DELETE_ACCOUNT = 10013; // Account has child nodes

ERR_INVALID_PARTITION = 10014; // Invalid partition, partition does not exist
ERR_ALLOWED_PARTITION = 10015; // Account/user does not include this partition
ERR_DUPLICATE_PARTITION = 10016; // Account/user duplicate insertion
ERR_PARENT_ALLOWED_PARTITION = 10017; // Parent account does not include this partition
ERR_USER_EMPTY_PARTITION = 10018; // Cannot add QoS when user has no partition
ERR_CHILD_HAS_PARTITION = 10019; // Partition '{}' is used by some descendant node of the account '{}'. Ignoring this constraint with forced operation.

ERR_INVALID_QOS = 10020; // Invalid QoS, QoS does not exist
ERR_DB_DUPLICATE_QOS = 10021; // Duplicate QoS insertion in the database.
ERR_DELETE_QOS = 10022; // QoS reference count is not zero.
ERR_CONVERT_TO_INTERGER = 10023; // String to integer conversion failed
ERR_TIME_LIMIT = 10024; // Invalid time value
ERR_ALLOWED_QOS = 10025; // Account/user does not include this QoS.
ERR_DUPLICATE_QOS = 10026; // Account/user duplicate insertion.
ERR_PARENT_ALLOWED_QOS = 10027; // Parent account does not include this QoS.
ERR_SET_ALLOWED_QOS = 10028; // QoS '{}' is the default QoS of partition '{}', but not found in the new QoS list.
ERR_ALLOWED_DEFAULT_QOS = 10029; // Default QoS is not in the allowed QoS list
ERR_DUPLICATE_DEFAULT_QOS = 10030; // Duplicate default QoS setting
ERR_CHILD_HAS_DEFAULT_QOS = 10031; // 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 = 10032; // QoS '{}' is used by some descendant node or itself of the account '{}'. Ignoring this constraint with forced operation.
ERR_SET_DEFAULT_QOS = 10033; // Qos '{}' not in allowed qos list or is already the default qos
ERR_IS_DEFAULT_QOS = 10034;

ERR_UPDATE_DATABASE = 10035;
ERR_UPDATE_DATABASE = 10035; // Database update failed

ERR_GENERIC_FAILURE = 10100;
ERR_NO_RESOURCE = 10101;
Expand Down
32 changes: 17 additions & 15 deletions src/Utilities/PluginClient/PluginClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ grpc::Status PluginClient::SendStartHook_(grpc::ClientContext* context,

auto* request = dynamic_cast<StartHookRequest*>(msg);
CRANE_ASSERT(request != nullptr);

StartHookReply reply;

CRANE_TRACE("[Plugin] Sending StartHook.");
Expand All @@ -146,35 +146,35 @@ grpc::Status PluginClient::SendEndHook_(grpc::ClientContext* context,

auto* request = dynamic_cast<EndHookRequest*>(msg);
CRANE_ASSERT(request != nullptr);

EndHookReply reply;

CRANE_TRACE("[Plugin] Sending EndHook.");
return m_stub_->EndHook(context, *request, &reply);
}

grpc::Status PluginClient::SendCreateCgroupHook_(grpc::ClientContext* context,
google::protobuf::Message* msg) {
grpc::Status PluginClient::SendCreateCgroupHook_(
grpc::ClientContext* context, google::protobuf::Message* msg) {
using crane::grpc::plugin::CreateCgroupHookReply;
using crane::grpc::plugin::CreateCgroupHookRequest;

auto* request = dynamic_cast<CreateCgroupHookRequest*>(msg);
CRANE_ASSERT(request != nullptr);

CreateCgroupHookReply reply;

CRANE_TRACE("[Plugin] Sending CreateCgroupHook.");
return m_stub_->CreateCgroupHook(context, *request, &reply);
}

grpc::Status PluginClient::SendDestroyCgroupHook_(grpc::ClientContext* context,
google::protobuf::Message* msg) {
grpc::Status PluginClient::SendDestroyCgroupHook_(
grpc::ClientContext* context, google::protobuf::Message* msg) {
using crane::grpc::plugin::DestroyCgroupHookReply;
using crane::grpc::plugin::DestroyCgroupHookRequest;

auto* request = dynamic_cast<DestroyCgroupHookRequest*>(msg);
CRANE_ASSERT(request != nullptr);

DestroyCgroupHookReply reply;

CRANE_TRACE("[Plugin] Sending DestroyCgroupHook.");
Expand Down Expand Up @@ -211,22 +211,24 @@ void PluginClient::EndHookAsync(std::vector<crane::grpc::TaskInfo> tasks) {
m_event_queue_.enqueue(std::move(e));
}

void PluginClient::CreateCgroupHookAsync(task_id_t task_id,
const std::string& cgroup,
const crane::grpc::DedicatedResourceInNode &request_resource) {
auto request = std::make_unique<crane::grpc::plugin::CreateCgroupHookRequest>();
void PluginClient::CreateCgroupHookAsync(
task_id_t task_id, const std::string& cgroup,
const crane::grpc::DedicatedResourceInNode& resource) {
auto request =
std::make_unique<crane::grpc::plugin::CreateCgroupHookRequest>();
request->set_task_id(task_id);
request->set_cgroup(cgroup);
request->mutable_request_res()->CopyFrom(request_resource);
request->mutable_resource()->CopyFrom(resource);

HookEvent e{HookType::CREATE_CGROUP,
std::unique_ptr<google::protobuf::Message>(std::move(request))};
m_event_queue_.enqueue(std::move(e));
}

void PluginClient::DestroyCgroupHookAsync(task_id_t task_id,
const std::string& cgroup) {
auto request = std::make_unique<crane::grpc::plugin::DestroyCgroupHookRequest>();
const std::string& cgroup) {
auto request =
std::make_unique<crane::grpc::plugin::DestroyCgroupHookRequest>();
request->set_task_id(task_id);
request->set_cgroup(cgroup);

Expand Down
9 changes: 5 additions & 4 deletions src/Utilities/PluginClient/include/crane/PluginClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ class PluginClient {
void EndHookAsync(std::vector<crane::grpc::TaskInfo> tasks);

// Launched by Craned
void CreateCgroupHookAsync(task_id_t task_id, const std::string& cgroup,
const crane::grpc::DedicatedResourceInNode &request_resource);
void CreateCgroupHookAsync(
task_id_t task_id, const std::string& cgroup,
const crane::grpc::DedicatedResourceInNode& resource);
void DestroyCgroupHookAsync(task_id_t task_id, const std::string& cgroup);

private:
Expand All @@ -82,9 +83,9 @@ class PluginClient {
grpc::Status SendEndHook_(grpc::ClientContext* context,
google::protobuf::Message* msg);
grpc::Status SendCreateCgroupHook_(grpc::ClientContext* context,
google::protobuf::Message* msg);
google::protobuf::Message* msg);
grpc::Status SendDestroyCgroupHook_(grpc::ClientContext* context,
google::protobuf::Message* msg);
google::protobuf::Message* msg);

void AsyncSendThread_();

Expand Down

0 comments on commit b20fcb3

Please sign in to comment.