Skip to content

Commit

Permalink
feat: User adds password information.
Browse files Browse the repository at this point in the history
  • Loading branch information
huerni committed Nov 1, 2024
1 parent b34153f commit c987b4b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 30 deletions.
64 changes: 34 additions & 30 deletions protos/PublicDefs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@ message AllocatableResource {
uint64 memory_sw_limit_bytes = 3;
}

message TypeCountMap{
map <string/*Type*/, uint64> type_count_map = 1;
message TypeCountMap {
map<string /*Type*/, uint64> type_count_map = 1;
uint64 total = 2;
}

message DeviceMap{
message DeviceMap {
map<string /*name*/, TypeCountMap> name_type_map = 1;
}

message Slots{
message Slots {
repeated string slots = 1;
}

message DeviceTypeSlotsMap{
message DeviceTypeSlotsMap {
map<string /*Type*/, Slots /*index of slot*/> type_slots_map = 1;
}

message DedicatedResourceInNode{
map <string /*device name*/, DeviceTypeSlotsMap> name_type_map = 1;
message DedicatedResourceInNode {
map<string /*device name*/, DeviceTypeSlotsMap> name_type_map = 1;
}

message ResourceInNode {
Expand All @@ -63,7 +63,7 @@ message ResourceInNode {
}

message ResourceV2 {
map <string /*craned id*/, ResourceInNode> each_node_res = 1;
map<string /*craned id*/, ResourceInNode> each_node_res = 1;
}

message ResourceView {
Expand Down Expand Up @@ -137,7 +137,7 @@ message TaskToCtld {
string extra_attr = 23;

string cmd_line = 31;
string cwd = 32; // Current working directory
string cwd = 32; // Current working directory
map<string, string> env = 33;

string excludes = 34;
Expand Down Expand Up @@ -180,7 +180,7 @@ message TaskToD {
// If this task is PENDING, start_time is either not set (default constructed)
// or an estimated start time.
// If this task is RUNNING, start_time is the actual starting time.
google.protobuf.Timestamp start_time = 5; // Currently Only used in CraneCtld
google.protobuf.Timestamp start_time = 5; // Currently Only used in CraneCtld
google.protobuf.Duration time_limit = 6;

string partition = 8;
Expand Down Expand Up @@ -216,7 +216,7 @@ message BatchTaskAdditionalMeta {
string error_file_pattern = 4;
}

message InteractiveTaskAdditionalMeta{
message InteractiveTaskAdditionalMeta {
string cfored_name = 1;
string sh_script = 2;
string term_env = 3;
Expand Down Expand Up @@ -261,10 +261,11 @@ message TaskInfo {
string craned_list = 36;
}

// The time of different nodes across the whole cluster might not always be synchronized.
// If the time on the front end node is more than several seconds ahead of the CraneCtld node,
// a negative elapsed time might occur.
// To avoid this, the elapsed time of a task is calculated on the CraneCtld side.
// The time of different nodes across the whole cluster might not always be
// synchronized. If the time on the front end node is more than several
// seconds ahead of the CraneCtld node, a negative elapsed time might occur.
// To avoid this, the elapsed time of a task is calculated on the CraneCtld
// side.
google.protobuf.Duration elapsed_time = 37;
repeated string execution_node = 38;
}
Expand Down Expand Up @@ -333,35 +334,38 @@ message AccountInfo {
bool blocked = 10;
}

// Note: UserInfo DIFFERS from the `User` struct in C++ code and database representation
// and is ONLY used for communication between CraneCtld and cacctmgr command.
// If an user belongs to multiple accounts, There will be multiple `UserInfo`
// messages with `account` pointing to each account.
// Note: UserInfo DIFFERS from the `User` struct in C++ code and database
// representation
// and is ONLY used for communication between CraneCtld and cacctmgr
// command. If an user belongs to multiple accounts, There will be
// multiple `UserInfo` messages with `account` pointing to each account.
// For example, if a user (uid=1) belongs to accounts `1,2,3`,
// there will be three `UserInfo` messages: (uid=1, account=1), (uid=1, account=2),
// (uid=1, account=3).
// The c++ code and database representation use a Map<account name, AttrsInAccount> to contain
// in ONE UserInfo message all the information belonging to different accounts.
// there will be three `UserInfo` messages: (uid=1, account=1), (uid=1,
// account=2), (uid=1, account=3). The c++ code and database
// representation use a Map<account name, AttrsInAccount> to contain in
// ONE UserInfo message all the information belonging to different
// accounts.
message UserInfo {
enum AdminLevel{
enum AdminLevel {
None = 0;
Operator = 1;
Admin = 2;
Root = 3;
};
message AllowedPartitionQos{
message AllowedPartitionQos {
string partition_name = 1;
repeated string qos_list = 2;
string default_qos = 3;
}

uint32 uid = 1;
string name = 2;
string account = 3;
bool blocked = 4;
repeated AllowedPartitionQos allowed_partition_qos_list = 5;
repeated string coordinator_accounts = 6;
AdminLevel admin_level = 7;
string password = 3;
string account = 4;
bool blocked = 5;
repeated AllowedPartitionQos allowed_partition_qos_list = 6;
repeated string coordinator_accounts = 7;
AdminLevel admin_level = 8;
}

message QosInfo {
Expand Down
9 changes: 9 additions & 0 deletions src/CraneCtld/CtldGrpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ grpc::Status CraneCtldServiceImpl::AddUser(
const crane::grpc::UserInfo *user_info = &request->user();

user.name = user_info->name();
user.password = user_info->password();
user.uid = user_info->uid();
user.default_account = user_info->account();
user.admin_level = User::AdminLevel(user_info->admin_level());
Expand Down Expand Up @@ -969,6 +970,14 @@ CtldServer::CtldServer(const Config::CraneCtldListenConf &listen_conf) {
listen_conf.CraneCtldListenPort);
}

// std::vector<
// std::unique_ptr<grpc::experimental::ServerInterceptorFactoryInterface>>
// creators;
// creators.push_back(
// std::unique_ptr<grpc::experimental::ServerInterceptorFactoryInterface>(
// new AuthInterceptorFactory()));

// builder.experimental().SetInterceptorCreators(std::move(creators));
builder.RegisterService(m_service_impl_.get());

m_server_ = builder.BuildAndStart();
Expand Down
1 change: 1 addition & 0 deletions src/CraneCtld/CtldPublicDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ struct User {
bool deleted = false;
uid_t uid;
std::string name;
std::string password;
std::string default_account;
AccountToAttrsMap account_to_attrs_map;
std::list<std::string> coordinator_accounts;
Expand Down
1 change: 1 addition & 0 deletions src/CraneCtld/DbClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ bool MongodbClient::CheckDefaultRootAccountUserAndInit_() {
CRANE_TRACE("Default user ROOT not found. Insert it into DB.");

root_user.name = "root";
root_user.password = "root";
root_user.default_account = "ROOT";
root_user.admin_level = User::Root;
root_user.uid = 0;
Expand Down

0 comments on commit c987b4b

Please sign in to comment.