diff options
author | Marina Preskokova <mpereskokova@ytsaurus.tech> | 2024-06-11 19:37:24 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-06-12 11:20:50 +0300 |
commit | 9994490ac611e1e098a265c37f833f6ff7974d68 (patch) | |
tree | 2f5a28d02cb42534746c85813fcfa512ed85e275 | |
parent | f916f06348b500917c61c50b571aaa9ee095f982 (diff) | |
download | ydb-9994490ac611e1e098a265c37f833f6ff7974d68.tar.gz |
QT; Multiple ACOs
No description
---
0309ad6d3e31b25f24aa81607fa7aac6ed9f0d9d
Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/635
Co-authored-by: mpereskokova <mpereskokova@yandex-team.com>
-rw-r--r-- | yt/yt/client/api/query_tracker_client.cpp | 3 | ||||
-rw-r--r-- | yt/yt/client/api/query_tracker_client.h | 9 | ||||
-rw-r--r-- | yt/yt/client/api/rpc_proxy/client_impl.cpp | 12 | ||||
-rw-r--r-- | yt/yt/client/api/rpc_proxy/helpers.cpp | 7 | ||||
-rw-r--r-- | yt/yt/client/driver/query_commands.cpp | 14 | ||||
-rw-r--r-- | yt/yt/client/query_tracker_client/public.h | 1 | ||||
-rw-r--r-- | yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto | 19 |
7 files changed, 58 insertions, 7 deletions
diff --git a/yt/yt/client/api/query_tracker_client.cpp b/yt/yt/client/api/query_tracker_client.cpp index 48f8ea8d22..86633c206b 100644 --- a/yt/yt/client/api/query_tracker_client.cpp +++ b/yt/yt/client/api/query_tracker_client.cpp @@ -24,7 +24,7 @@ void TQueryFile::Register(TRegistrar registrar) void Serialize(const TQuery& query, NYson::IYsonConsumer* consumer) { - static_assert(pfr::tuple_size<TQuery>::value == 15); + static_assert(pfr::tuple_size<TQuery>::value == 16); BuildYsonFluently(consumer) .BeginMap() .OptionalItem("id", query.Id) @@ -36,6 +36,7 @@ void Serialize(const TQuery& query, NYson::IYsonConsumer* consumer) .OptionalItem("settings", query.Settings) .OptionalItem("user", query.User) .OptionalItem("access_control_object", query.AccessControlObject) + .OptionalItem("access_control_objects", query.AccessControlObjects) .OptionalItem("state", query.State) .OptionalItem("result_count", query.ResultCount) .OptionalItem("progress", query.Progress) diff --git a/yt/yt/client/api/query_tracker_client.h b/yt/yt/client/api/query_tracker_client.h index e2cb81d27e..13abe6902f 100644 --- a/yt/yt/client/api/query_tracker_client.h +++ b/yt/yt/client/api/query_tracker_client.h @@ -42,7 +42,8 @@ struct TStartQueryOptions bool Draft = false; NYTree::IMapNodePtr Annotations; std::vector<TQueryFilePtr> Files; - std::optional<TString> AccessControlObject; + std::optional<TString> AccessControlObject; // deprecated + std::optional<std::vector<TString>> AccessControlObjects; }; struct TAbortQueryOptions @@ -102,7 +103,8 @@ struct TQuery std::optional<TInstant> FinishTime; NYson::TYsonString Settings; std::optional<TString> User; - std::optional<TString> AccessControlObject; + std::optional<TString> AccessControlObject; // deprecated + std::optional<NYson::TYsonString> AccessControlObjects; std::optional<NQueryTrackerClient::EQueryState> State; std::optional<i64> ResultCount; NYson::TYsonString Progress; @@ -137,7 +139,8 @@ struct TAlterQueryOptions , public TQueryTrackerOptions { NYTree::IMapNodePtr Annotations; - std::optional<TString> AccessControlObject; + std::optional<TString> AccessControlObject; // deprecated + std::optional<std::vector<TString>> AccessControlObjects; }; struct TGetQueryTrackerInfoOptions diff --git a/yt/yt/client/api/rpc_proxy/client_impl.cpp b/yt/yt/client/api/rpc_proxy/client_impl.cpp index 01713fc678..d83f53e37a 100644 --- a/yt/yt/client/api/rpc_proxy/client_impl.cpp +++ b/yt/yt/client/api/rpc_proxy/client_impl.cpp @@ -2136,6 +2136,12 @@ TFuture<NQueryTrackerClient::TQueryId> TClient::StartQuery( if (options.AccessControlObject) { req->set_access_control_object(*options.AccessControlObject); } + if (options.AccessControlObjects) { + auto* protoAccessControlObjects = req->mutable_access_control_objects(); + for (const auto& aco : *options.AccessControlObjects) { + protoAccessControlObjects->add_items(aco); + } + } for (const auto& file : options.Files) { auto* protoFile = req->add_files(); @@ -2319,6 +2325,12 @@ TFuture<void> TClient::AlterQuery( if (options.AccessControlObject) { req->set_access_control_object(*options.AccessControlObject); } + if (options.AccessControlObjects) { + auto* protoAccessControlObjects = req->mutable_access_control_objects(); + for (const auto& aco : *options.AccessControlObjects) { + protoAccessControlObjects->add_items(aco); + } + } return req->Invoke().AsVoid(); } diff --git a/yt/yt/client/api/rpc_proxy/helpers.cpp b/yt/yt/client/api/rpc_proxy/helpers.cpp index e7df8861c5..f73bfe9715 100644 --- a/yt/yt/client/api/rpc_proxy/helpers.cpp +++ b/yt/yt/client/api/rpc_proxy/helpers.cpp @@ -1366,6 +1366,8 @@ void ToProto( if (query.AccessControlObject) { protoQuery->set_access_control_object(*query.AccessControlObject); } + protoQuery->set_access_control_objects(query.AccessControlObjects->ToString()); + if (query.State) { protoQuery->set_state(ConvertQueryStateToProto(*query.State)); } @@ -1432,6 +1434,11 @@ void FromProto( } else { query->AccessControlObject.reset(); } + if (protoQuery.has_access_control_objects()) { + query->AccessControlObjects = TYsonString(protoQuery.access_control_objects()); + } else { + query->AccessControlObjects.reset(); + } if (protoQuery.has_state()) { query->State = ConvertQueryStateFromProto(protoQuery.state()); } else { diff --git a/yt/yt/client/driver/query_commands.cpp b/yt/yt/client/driver/query_commands.cpp index bdeaf9ffff..024ee93c85 100644 --- a/yt/yt/client/driver/query_commands.cpp +++ b/yt/yt/client/driver/query_commands.cpp @@ -69,6 +69,13 @@ void TStartQueryCommand::Register(TRegistrar registrar) return command->Options.AccessControlObject; }) .Optional(/*init*/ false); + + registrar.ParameterWithUniversalAccessor<std::optional<std::vector<TString>>>( + "access_control_objects", + [] (TThis* command) -> auto& { + return command->Options.AccessControlObjects; + }) + .Optional(/*init*/ false); } void TStartQueryCommand::DoExecute(ICommandContextPtr context) @@ -331,6 +338,13 @@ void TAlterQueryCommand::Register(TRegistrar registrar) }) .Optional(/*init*/ false); + registrar.ParameterWithUniversalAccessor<std::optional<std::vector<TString>>>( + "access_control_objects", + [] (TThis* command) -> auto& { + return command->Options.AccessControlObjects; + }) + .Optional(/*init*/ false); + registrar.ParameterWithUniversalAccessor<TString>( "stage", [] (TThis* command) -> auto& { diff --git a/yt/yt/client/query_tracker_client/public.h b/yt/yt/client/query_tracker_client/public.h index d3f468a490..bfaf0c8a89 100644 --- a/yt/yt/client/query_tracker_client/public.h +++ b/yt/yt/client/query_tracker_client/public.h @@ -12,6 +12,7 @@ YT_DEFINE_ERROR_ENUM( ((IncarnationMismatch) (3900)) ((QueryNotFound) (3901)) ((QueryResultNotFound) (3902)) + ((TooManyAcos) (3903)) ); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto b/yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto index 2ca9463db2..929bf21229 100644 --- a/yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto +++ b/yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto @@ -3168,6 +3168,11 @@ message TReqStartQuery required EContentType type = 3; } + message TAccessControlObjects + { + repeated string items = 1; + } + required string query_tracker_stage = 1; required EQueryEngine engine = 2; required string query = 3; @@ -3175,7 +3180,8 @@ message TReqStartQuery optional bool draft = 5; optional bytes annotations = 6; // YSON repeated TQueryFile files = 7; - optional string access_control_object = 8; + optional string access_control_object = 8; // deprecated + optional TAccessControlObjects access_control_objects = 9; } message TRspStartQuery @@ -3249,13 +3255,14 @@ message TQuery optional uint64 finish_time = 6; // TInstant optional bytes settings = 7; // YSON optional string user = 8; - optional string access_control_object = 9; + optional string access_control_object = 9; // deprecated optional EQueryState state = 10; optional int64 result_count = 11; optional bytes progress = 12; // YSON optional NYT.NProto.TError error = 13; optional bytes annotations = 14; // YSON optional NYT.NYTree.NProto.TAttributeDictionary other_attributes = 15; + optional bytes access_control_objects = 16; // YSON } //////////////////////////////////////////////////////////////////////////////// @@ -3301,10 +3308,16 @@ message TRspListQueries message TReqAlterQuery { + message TAccessControlObjects + { + repeated string items = 1; + } + required string query_tracker_stage = 1; required NYT.NProto.TGuid query_id = 2; optional bytes annotations = 3; // YSON - optional string access_control_object = 4; + optional string access_control_object = 4; // deprecated + optional TAccessControlObjects access_control_objects = 5; } message TRspAlterQuery |