Skip to content

feat: AI 支持获取可选功能接口,支持分区资源管理 #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/curvy-bananas-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@scow/scow-scheduler-adapter-interface": minor
---

在 AI 中增加获取支持的可选功能的接口, 增加封锁解封账户分区的相关接口
在 AI 中优化QueryAccountBlockStatus接口返回信息
122 changes: 122 additions & 0 deletions protos/account.proto
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,26 @@ message QueryAccountBlockStatusRequest {
string account_name = 1;
}

message AccountStatusInPartition {
string partition = 1;
bool blocked = 2;
}

message QueryAccountBlockStatusResponse {
// In k8s-adapter versions 1.7.0 and earlier:
// - The account's status is uniformly consistent across all partitions by default.
// - false: The queried account is unblocked in all partitions.
// - true: The queried account has no available partitions.

// In k8s-adapter versions later than 1.7.0:
// - The field "blocked" represents whether the account is completely blocked across all partitions:
// - true: The account is fully blocked in all partitions.
// - false: The account has one or more partitions where it is not blocked.
bool blocked = 1;

// the details of account blocked status in every partition
// only returns in k8s-adapter version later than 1.7.0
repeated AccountStatusInPartition account_blocked_details = 2;
}

message DeleteAccountRequest {
Expand All @@ -79,6 +97,70 @@ message DeleteAccountRequest {
message DeleteAccountResponse {
}

// ************ Below is the interfaces for optional feature: RESOURCE_MANAGEMENT ***************
message BlockAccountWithPartitionsRequest {
string account_name = 1;
// when the value exists: block specified partition(s) of the account
// when the value is [] or undefined: block the account in all partitions
repeated string blocked_partitions = 2;
}

message BlockAccountWithPartitionsResponse {
}

message UnblockAccountWithPartitionsRequest {
string account_name = 1;
// specify the available partition(s) when executing unblock
// when the value is [] or undefined: use all partitions
repeated string unblocked_partitions = 2;
}

message UnblockAccountWithPartitionsResponse {
}

message QueryAccountBlockStatusWithPartitionsRequest {
string account_name = 1;
// query in specified partition(s)
// when the value is [] or undefined, return all partitions blocked details
repeated string queried_partitions = 2;
}

message QueryAccountBlockStatusWithPartitionsResponse {
// return the overall blocked_status in all partitions
// false: when the queried account has one or more available partitions
// true: when the queried account has no available partitions
bool blocked = 1;
// the details of account blocked status in every partition
repeated AccountStatusInPartition account_blocked_details = 2;
}

message ClusterAccountInfoWithBlockedDetails {
message UserInAccount {
string user_id = 1;
string user_name = 2;
bool blocked = 3;
}
string account_name = 1;
repeated UserInAccount users = 2;
optional string owner = 3;
// return the overall blocked_status in all partitions
// false: when the queried account has one or more available partitions
// true: when the queried account has no available partitions
bool blocked = 4;
// the details of account blocked status in every partition
repeated AccountStatusInPartition account_blocked_details = 5;
}

message GetAllAccountsWithUsersAndBlockedDetailsRequest {

}

message GetAllAccountsWithUsersAndBlockedDetailsResponse {
repeated ClusterAccountInfoWithBlockedDetails accounts = 1;
}
// ********** Above is the interfaces for optional feature: RESOURCE_MANAGEMENT ***************


service AccountService {

/**
Expand Down Expand Up @@ -141,4 +223,44 @@ service AccountService {
* NOT_FOUND, ACCOUNT_NOT_FOUND, {}
*/
rpc DeleteAccount(DeleteAccountRequest) returns (DeleteAccountResponse);


// ********** Below is the rpcs for optional feature: RESOURCE_MANAGEMENT ***************
/*
* FOR OPTIONAL FEATURE: RESOURCE_MANAGEMENT
* description: block an account with specified partitions
* errors:
* - account not exist
* NOT_FOUND, ACCOUNT_NOT_FOUND, {}
* special case:
* - account already blocked, don't throw error
*/
rpc BlockAccountWithPartitions(BlockAccountWithPartitionsRequest) returns (BlockAccountWithPartitionsResponse);
/*
* FOR OPTIONAL FEATURE: RESOURCE_MANAGEMENT
* description: unblock an account with specified partitions
* errors:
* - account not exist
* NOT_FOUND, ACCOUNT_NOT_FOUND, {}
* special case:
* - account already unblocked, don't throw error
*/
rpc UnblockAccountWithPartitions(UnblockAccountWithPartitionsRequest) returns (UnblockAccountWithPartitionsResponse);
/*
* FOR OPTIONAL FEATURE: RESOURCE_MANAGEMENT
* description: query if an account is blocked with specified partitions
* errors:
* - account not exist
* NOT_FOUND, ACCOUNT_NOT_FOUND, {}
*/
rpc QueryAccountBlockStatusWithPartitions(QueryAccountBlockStatusWithPartitionsRequest) returns (QueryAccountBlockStatusWithPartitionsResponse);
/*
* FOR OPTIONAL FEATURE: RESOURCE_MANAGEMENT
* description: get all accounts with blocked partitions' detail and all associated users
* special case:
* - account no users, exclude this account
*/
rpc GetAllAccountsWithUsersAndBlockedDetails(GetAllAccountsWithUsersAndBlockedDetailsRequest) returns (GetAllAccountsWithUsersAndBlockedDetailsResponse);
// ********** Above is the interfaces for optional feature: RESOURCE_MANAGEMENT ***************

}
16 changes: 16 additions & 0 deletions protos/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ message GetClusterNodesInfoResponse {
repeated NodeInfo nodes = 1;
}

message ListImplementedOptionalFeaturesRequest {}

enum OptionalFeatures {
UNKNOWN = 0;
RESOURCE_MANAGEMENT = 1;
}

message ListImplementedOptionalFeaturesResponse {
repeated OptionalFeatures features = 1;
}

service ConfigService {
/*
* description: get cluster config
Expand All @@ -158,4 +169,9 @@ service ConfigService {
* description: get cluster nodes information
*/
rpc GetClusterNodesInfo(GetClusterNodesInfoRequest) returns (GetClusterNodesInfoResponse);

/*
* description: List optional features implemented by this scheduler adapter
*/
rpc ListImplementedOptionalFeatures(ListImplementedOptionalFeaturesRequest) returns (ListImplementedOptionalFeaturesResponse);
}