Skip to content

Commit adb603c

Browse files
authored
Merge a3cd4c9 into 91c2833
2 parents 91c2833 + a3cd4c9 commit adb603c

File tree

12 files changed

+140
-17
lines changed

12 files changed

+140
-17
lines changed

ydb/core/grpc_services/rpc_export_base.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ struct TExportConv {
4646
}
4747

4848
if (exprt.HasStartTime()) {
49-
*operation.mutable_start_time() = exprt.GetStartTime();
49+
*operation.mutable_create_time() = exprt.GetStartTime();
5050
}
5151
if (exprt.HasEndTime()) {
5252
*operation.mutable_end_time() = exprt.GetEndTime();
5353
}
5454

55+
if (exprt.HasUserSID()) {
56+
operation.set_created_by(exprt.GetUserSID());
57+
}
58+
5559
using namespace Ydb::Export;
5660
switch (exprt.GetSettingsCase()) {
5761
case NKikimrExport::TExport::kExportToYtSettings:

ydb/core/grpc_services/rpc_import_base.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ struct TImportConv {
4343
}
4444

4545
if (import.HasStartTime()) {
46-
*operation.mutable_start_time() = import.GetStartTime();
46+
*operation.mutable_create_time() = import.GetStartTime();
4747
}
4848
if (import.HasEndTime()) {
4949
*operation.mutable_end_time() = import.GetEndTime();
5050
}
5151

52+
if (import.HasUserSID()) {
53+
operation.set_created_by(import.GetUserSID());
54+
}
55+
5256
using namespace Ydb::Import;
5357
switch (import.GetSettingsCase()) {
5458
case NKikimrImport::TImport::kImportFromS3Settings:

ydb/core/protos/export.proto

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ message TExport {
2020
Ydb.Export.ExportToYtSettings ExportToYtSettings = 5;
2121
Ydb.Export.ExportToS3Settings ExportToS3Settings = 6;
2222
}
23+
optional string UserSID = 10;
2324
}
2425

2526
message TCreateExportRequest {

ydb/core/protos/import.proto

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ message TImport {
1919
oneof Settings {
2020
Ydb.Import.ImportFromS3Settings ImportFromS3Settings = 6;
2121
}
22+
optional string UserSID = 9;
2223
}
2324

2425
message TCreateImportRequest {

ydb/core/tx/schemeshard/schemeshard_export.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ void TSchemeShard::FromXxportInfo(NKikimrExport::TExport& exprt, const TExportIn
9191
*exprt.MutableEndTime() = SecondsToProtoTimeStamp(exportInfo->EndTime.Seconds());
9292
}
9393

94+
if (exportInfo->UserSID) {
95+
exprt.SetUserSID(*exportInfo->UserSID);
96+
}
97+
9498
switch (exportInfo->State) {
9599
case TExportInfo::EState::CreateExportDir:
96100
case TExportInfo::EState::CopyTables:

ydb/core/tx/schemeshard/schemeshard_import.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ void TSchemeShard::FromXxportInfo(NKikimrImport::TImport& import, const TImportI
5555
*import.MutableEndTime() = SecondsToProtoTimeStamp(importInfo->EndTime.Seconds());
5656
}
5757

58+
if (importInfo->UserSID) {
59+
import.SetUserSID(*importInfo->UserSID);
60+
}
61+
5862
switch (importInfo->State) {
5963
case TImportInfo::EState::Waiting:
6064
switch (GetMinState(importInfo)) {

ydb/core/tx/schemeshard/ut_export/ut_export.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -1965,5 +1965,42 @@ partitioning_settings {
19651965
min_partitions_count: 10
19661966
)"));
19671967
}
1968+
1969+
Y_UNIT_TEST(UserSID) {
1970+
TTestBasicRuntime runtime;
1971+
TTestEnv env(runtime);
1972+
ui64 txId = 100;
1973+
1974+
TestCreateTable(runtime, ++txId, "/MyRoot", R"(
1975+
Name: "Table"
1976+
Columns { Name: "key" Type: "Utf8" }
1977+
Columns { Name: "value" Type: "Utf8" }
1978+
KeyColumnNames: ["key"]
1979+
)");
1980+
env.TestWaitNotification(runtime, txId);
1981+
1982+
TPortManager portManager;
1983+
const ui16 port = portManager.GetPort();
1984+
1985+
TS3Mock s3Mock({}, TS3Mock::TSettings(port));
1986+
UNIT_ASSERT(s3Mock.Start());
19681987

1988+
const TString request = Sprintf(R"(
1989+
ExportToS3Settings {
1990+
endpoint: "localhost:%d"
1991+
scheme: HTTP
1992+
items {
1993+
source_path: "/MyRoot/Table"
1994+
destination_prefix: ""
1995+
}
1996+
}
1997+
)", port);
1998+
const TString userSID = "user@builtin";
1999+
TestExport(runtime, ++txId, "/MyRoot", request, userSID);
2000+
2001+
const auto desc = TestGetExport(runtime, txId, "/MyRoot");
2002+
const auto& entry = desc.GetResponse().GetEntry();
2003+
UNIT_ASSERT_VALUES_EQUAL(entry.GetProgress(), Ydb::Export::ExportProgress::PROGRESS_PREPARING);
2004+
UNIT_ASSERT_VALUES_EQUAL(entry.GetUserSID(), userSID);
2005+
}
19692006
}

ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp

+42
Original file line numberDiff line numberDiff line change
@@ -3451,6 +3451,48 @@ Y_UNIT_TEST_SUITE(TImportTests) {
34513451
UNIT_ASSERT(entry.HasEndTime());
34523452
UNIT_ASSERT_LT(entry.GetStartTime().seconds(), entry.GetEndTime().seconds());
34533453
}
3454+
3455+
Y_UNIT_TEST(UserSID) {
3456+
TTestBasicRuntime runtime;
3457+
TTestEnv env(runtime);
3458+
ui64 txId = 100;
3459+
3460+
const auto data = GenerateTestData(R"(
3461+
columns {
3462+
name: "key"
3463+
type { optional_type { item { type_id: UTF8 } } }
3464+
}
3465+
columns {
3466+
name: "value"
3467+
type { optional_type { item { type_id: UTF8 } } }
3468+
}
3469+
primary_key: "key"
3470+
)", {{"a", 1}});
3471+
3472+
TPortManager portManager;
3473+
const ui16 port = portManager.GetPort();
3474+
3475+
TS3Mock s3Mock(ConvertTestData(data), TS3Mock::TSettings(port));
3476+
UNIT_ASSERT(s3Mock.Start());
3477+
3478+
const TString request = Sprintf(R"(
3479+
ImportFromS3Settings {
3480+
endpoint: "localhost:%d"
3481+
scheme: HTTP
3482+
items {
3483+
source_prefix: ""
3484+
destination_path: "/MyRoot/Table"
3485+
}
3486+
}
3487+
)", port);
3488+
const TString userSID = "user@builtin";
3489+
TestImport(runtime, ++txId, "/MyRoot", request, userSID);
3490+
3491+
const auto desc = TestGetImport(runtime, txId, "/MyRoot");
3492+
const auto& entry = desc.GetResponse().GetEntry();
3493+
UNIT_ASSERT_VALUES_EQUAL(entry.GetProgress(), Ydb::Import::ImportProgress::PROGRESS_PREPARING);
3494+
UNIT_ASSERT_VALUES_EQUAL(entry.GetUserSID(), userSID);
3495+
}
34543496
}
34553497

34563498
Y_UNIT_TEST_SUITE(TImportWithRebootsTests) {

ydb/public/api/protos/ydb_operation.proto

+5-2
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,12 @@ message Operation {
122122
// For operations in progress, it might indicate the current cost of the operation (if supported).
123123
CostInfo cost_info = 7;
124124

125-
// The time at which this operation was started (if supported).
126-
google.protobuf.Timestamp start_time = 8;
125+
// The time at which this operation was created (if supported).
126+
google.protobuf.Timestamp create_time = 8;
127127

128128
// The time at which this operation was completed, doesn't matter successful or not (if supported).
129129
google.protobuf.Timestamp end_time = 9;
130+
131+
// User SID (Security ID) of the user who created this operation (if supported).
132+
string created_by = 10;
130133
}

ydb/public/lib/ydb_cli/common/print_operation.cpp

+18-6
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ namespace {
3737
}
3838
}
3939

40-
if (operation.StartTime() != TInstant::Zero()) {
41-
freeText << "Start time: " << operation.StartTime().ToStringUpToSeconds() << Endl;
40+
if (!operation.CreatedBy().Empty()) {
41+
freeText << "Created by: " << operation.CreatedBy() << Endl;
42+
}
43+
44+
if (operation.CreateTime() != TInstant::Zero()) {
45+
freeText << "Create time: " << operation.CreateTime().ToStringUpToSeconds() << Endl;
4246
}
4347

4448
if (operation.EndTime() != TInstant::Zero()) {
@@ -122,8 +126,12 @@ namespace {
122126

123127
freeText << "TypeV3: " << (settings.UseTypeV3_ ? "true" : "false") << Endl;
124128

125-
if (operation.StartTime() != TInstant::Zero()) {
126-
freeText << "Start time: " << operation.StartTime().ToStringUpToSeconds() << Endl;
129+
if (!operation.CreatedBy().Empty()) {
130+
freeText << "Created by: " << operation.CreatedBy() << Endl;
131+
}
132+
133+
if (operation.CreateTime() != TInstant::Zero()) {
134+
freeText << "Create time: " << operation.CreateTime().ToStringUpToSeconds() << Endl;
127135
}
128136

129137
if (operation.EndTime() != TInstant::Zero()) {
@@ -184,8 +192,12 @@ namespace {
184192
freeText << "Number of retries: " << settings.NumberOfRetries_.GetRef() << Endl;
185193
}
186194

187-
if (operation.StartTime() != TInstant::Zero()) {
188-
freeText << "Start time: " << operation.StartTime().ToStringUpToSeconds() << Endl;
195+
if (!operation.CreatedBy().Empty()) {
196+
freeText << "Created by: " << operation.CreatedBy() << Endl;
197+
}
198+
199+
if (operation.CreateTime() != TInstant::Zero()) {
200+
freeText << "Create time: " << operation.CreateTime().ToStringUpToSeconds() << Endl;
189201
}
190202

191203
if (operation.EndTime() != TInstant::Zero()) {

ydb/public/sdk/cpp/client/ydb_types/operation/operation.cpp

+16-6
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ class TOperation::TImpl {
1717
: Id_(operation.id(), true /* allowEmpty */)
1818
, Status_(std::move(status))
1919
, Ready_(operation.ready())
20-
, StartTime_(ProtoTimestampToInstant(operation.start_time()))
20+
, CreateTime_(ProtoTimestampToInstant(operation.create_time()))
2121
, EndTime_(ProtoTimestampToInstant(operation.end_time()))
22+
, CreatedBy_(operation.created_by())
2223
, Operation_(std::move(operation))
2324
{
2425
}
@@ -35,14 +36,18 @@ class TOperation::TImpl {
3536
return Status_;
3637
}
3738

38-
TInstant StartTime() const {
39-
return StartTime_;
39+
TInstant CreateTime() const {
40+
return CreateTime_;
4041
}
4142

4243
TInstant EndTime() const {
4344
return EndTime_;
4445
}
4546

47+
const TString& CreatedBy() const {
48+
return CreatedBy_;
49+
}
50+
4651
const Ydb::Operations::Operation& GetProto() const {
4752
return Operation_;
4853
}
@@ -51,8 +56,9 @@ class TOperation::TImpl {
5156
const TOperationId Id_;
5257
const TStatus Status_;
5358
const bool Ready_;
54-
const TInstant StartTime_;
59+
const TInstant CreateTime_;
5560
const TInstant EndTime_;
61+
const TString CreatedBy_;
5662
const Ydb::Operations::Operation Operation_;
5763
};
5864

@@ -76,14 +82,18 @@ const TStatus& TOperation::Status() const {
7682
return Impl_->Status();
7783
}
7884

79-
TInstant TOperation::StartTime() const {
80-
return Impl_->StartTime();
85+
TInstant TOperation::CreateTime() const {
86+
return Impl_->CreateTime();
8187
}
8288

8389
TInstant TOperation::EndTime() const {
8490
return Impl_->EndTime();
8591
}
8692

93+
const TString& TOperation::CreatedBy() const {
94+
return Impl_->CreatedBy();
95+
}
96+
8797
TString TOperation::ToString() const {
8898
TString result;
8999
TStringOutput out(result);

ydb/public/sdk/cpp/client/ydb_types/operation/operation.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ class TOperation {
3232
const TOperationId& Id() const;
3333
bool Ready() const;
3434
const TStatus& Status() const;
35-
TInstant StartTime() const;
35+
TInstant CreateTime() const;
3636
TInstant EndTime() const;
37+
const TString& CreatedBy() const;
3738

3839
TString ToString() const;
3940
TString ToJsonString() const;

0 commit comments

Comments
 (0)