Skip to content

Commit 3de66fa

Browse files
authored
Return storage pool kind in TChannelBind (#15135)
1 parent caf2ade commit 3de66fa

File tree

4 files changed

+37
-47
lines changed

4 files changed

+37
-47
lines changed

ydb/core/grpc_services/rpc_keyvalue.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ class TDescribeVolumeRequest
572572
auto *storageConfig = result.mutable_storage_config();
573573
for (auto &channel : desc.GetBoundChannels()) {
574574
auto *channelBind = storageConfig->add_channel();
575-
channelBind->set_media(channel.GetStoragePoolName());
575+
channelBind->set_media(channel.GetStoragePoolKind());
576576
}
577577
this->ReplyWithResult(Ydb::StatusIds::SUCCESS, result, TActivationContext::AsActorContext());
578578
}
@@ -645,7 +645,6 @@ class TAlterVolumeRequest
645645
}
646646

647647
STFUNC(StateWork) {
648-
Cerr << "TAlterVolumeRequest::StateWork; received event: " << ev->GetTypeName() << Endl;
649648
switch (ev->GetTypeRewrite()) {
650649
hFunc(TEvTxProxySchemeCache::TEvNavigateKeySetResult, Handle);
651650
default:
@@ -664,7 +663,7 @@ class TAlterVolumeRequest
664663
const NKikimrSchemeOp::TSolomonVolumeDescription &desc = request->ResultSet[0].SolomonVolumeInfo->Description;
665664
for (auto &channel : desc.GetBoundChannels()) {
666665
auto *channelBind = StorageConfig.add_channel();
667-
channelBind->set_media(channel.GetStoragePoolName());
666+
channelBind->set_media(channel.GetStoragePoolKind());
668667
}
669668
SendProposeRequest(TActivationContext::AsActorContext());
670669
}

ydb/core/protos/bind_channel_storage_pool.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ message TStoragePool {
99
message TChannelBind {
1010
//optional uint32 Channel = 1; // it should be equal to array index, so it doesn't make any sense to have one
1111
optional string StoragePoolName = 2;
12+
optional string StoragePoolKind = 3;
1213
optional float IOPS = 10;
1314
optional uint64 Throughput = 11;
1415
optional uint64 Size = 12;

ydb/core/tx/schemeshard/schemeshard_impl.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ bool ResolvePoolNames(
6363

6464
result.emplace_back();
6565
result.back().SetStoragePoolName(poolIt->GetName());
66+
result.back().SetStoragePoolKind(poolIt->GetKind());
6667
}
6768

6869
channelsBinding.swap(result);
@@ -533,8 +534,8 @@ bool TSchemeShard::ApplyStorageConfig(
533534
return pools.cend();
534535
};
535536

536-
auto allocateChannel = [&] (const TString& poolName, bool reuseExisting = true) -> ui32 {
537-
auto it = reverseBinding.find(poolName);
537+
auto allocateChannel = [&] (const TStoragePool& pool, bool reuseExisting = true) -> ui32 {
538+
auto it = reverseBinding.find(pool.GetName());
538539
if (it != reverseBinding.end()) {
539540
if (reuseExisting) {
540541
return it->second[0];
@@ -543,8 +544,9 @@ bool TSchemeShard::ApplyStorageConfig(
543544

544545
ui32 channel = channelsBinding.size();
545546
channelsBinding.emplace_back();
546-
channelsBinding.back().SetStoragePoolName(poolName);
547-
reverseBinding[poolName].emplace_back(channel);
547+
channelsBinding.back().SetStoragePoolName(pool.GetName());
548+
channelsBinding.back().SetStoragePoolKind(pool.GetKind());
549+
reverseBinding[pool.GetName()].emplace_back(channel);
548550
return channel;
549551
};
550552

@@ -561,14 +563,15 @@ bool TSchemeShard::ApplyStorageConfig(
561563

562564
channelsBinding.emplace_back();
563565
channelsBinding.back().SetStoragePoolName(sysLogPool->GetName());
566+
channelsBinding.back().SetStoragePoolKind(sysLogPool->GetKind());
564567
}
565568

566569
if (channelsBinding.size() < 2) {
567570
LOCAL_CHECK(storageConfig.HasLog(), "no log storage setting");
568571
auto logPool = resolve(storagePools, storageConfig.GetLog());
569572
LOCAL_CHECK(logPool != storagePools.end(), "unable determine pool for log storage");
570573

571-
ui32 channel = allocateChannel(logPool->GetName());
574+
ui32 channel = allocateChannel(*logPool);
572575
Y_ABORT_UNLESS(channel == 1, "Expected to allocate log channel, not %" PRIu32, channel);
573576
}
574577

@@ -582,7 +585,7 @@ bool TSchemeShard::ApplyStorageConfig(
582585
auto dataPool = resolve(storagePools, storageConfig.GetData());
583586
LOCAL_CHECK(dataPool != storagePools.end(), "definition of data storage present but unable determine pool for it");
584587

585-
ui32 channel = allocateChannel(dataPool->GetName());
588+
ui32 channel = allocateChannel(*dataPool);
586589
room.AssignChannel(NKikimrStorageSettings::TChannelPurpose::Data, channel);
587590
}
588591

@@ -595,7 +598,7 @@ bool TSchemeShard::ApplyStorageConfig(
595598
LOCAL_CHECK(externalChannelsCount < Max<ui8>(), "more than 255 external channels requested");
596599
for (ui32 i = 0; i < externalChannelsCount; ++i) {
597600
// In case if we have 1 external channel, leave old behavior untouched and reuse channel by pool's name
598-
ui32 channel = allocateChannel(externalPool->GetName(), externalChannelsCount == 1 ? true : false);
601+
ui32 channel = allocateChannel(*externalPool, externalChannelsCount == 1 ? true : false);
599602
room.AssignChannel(NKikimrStorageSettings::TChannelPurpose::External, channel);
600603
}
601604
}

ydb/services/keyvalue/grpc_service_ut.cpp

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,10 @@
3030
namespace NKikimr::NGRpcService {
3131
3232
33-
struct TKikimrTestSettings {
34-
static constexpr bool SSL = false;
35-
static constexpr bool AUTH = false;
36-
static constexpr bool PrecreatePools = true;
37-
static constexpr bool EnableSystemViews = true;
38-
};
39-
40-
struct TKikimrTestWithAuth : TKikimrTestSettings {
41-
static constexpr bool AUTH = true;
42-
};
43-
44-
struct TKikimrTestWithAuthAndSsl : TKikimrTestWithAuth {
45-
static constexpr bool SSL = true;
46-
};
4733
48-
struct TKikimrTestNoSystemViews : TKikimrTestSettings {
49-
static constexpr bool EnableSystemViews = false;
50-
};
51-
52-
template <typename TestSettings = TKikimrTestSettings>
53-
class TBasicKikimrWithGrpcAndRootSchema {
34+
class TKikimrWithGrpcAndRootSchema {
5435
public:
55-
TBasicKikimrWithGrpcAndRootSchema(
36+
TKikimrWithGrpcAndRootSchema(
5637
NKikimrConfig::TAppConfig appConfig = {},
5738
TAutoPtr<TLogBackend> logBackend = {})
5839
{
@@ -63,19 +44,13 @@ class TBasicKikimrWithGrpcAndRootSchema {
6344
ServerSettings->SetLogBackend(logBackend);
6445
ServerSettings->SetDomainName("Root");
6546
ServerSettings->SetDynamicNodeCount(1);
66-
if (TestSettings::PrecreatePools) {
67-
ServerSettings->AddStoragePool("ssd");
68-
ServerSettings->AddStoragePool("hdd");
69-
ServerSettings->AddStoragePool("hdd1");
70-
ServerSettings->AddStoragePool("hdd2");
71-
} else {
72-
ServerSettings->AddStoragePoolType("ssd");
73-
ServerSettings->AddStoragePoolType("hdd");
74-
ServerSettings->AddStoragePoolType("hdd1");
75-
ServerSettings->AddStoragePoolType("hdd2");
76-
}
47+
ServerSettings->AddStoragePool("ssd", "ssd-pool");
48+
ServerSettings->AddStoragePool("hdd", "hdd-pool");
49+
ServerSettings->AddStoragePool("hdd1", "hdd1-pool");
50+
ServerSettings->AddStoragePool("hdd2", "hdd2-pool");
7751
ServerSettings->Formats = new TFormatFactory;
7852
ServerSettings->FeatureFlags = appConfig.GetFeatureFlags();
53+
ServerSettings->FeatureFlags.SetAllowUpdateChannelsBindingOfSolomonPartitions(true);
7954
ServerSettings->RegisterGrpcService<NKikimr::NGRpcService::TKeyValueGRpcService>("keyvalue");
8055
8156
Server_.Reset(new Tests::TServer(*ServerSettings));
@@ -101,9 +76,6 @@ class TBasicKikimrWithGrpcAndRootSchema {
10176
//Server_->GetRuntime()->SetLogPriority(NKikimrServices::TX_COLUMNSHARD, NActors::NLog::PRI_DEBUG);
10277
10378
NYdbGrpc::TServerOptions grpcOption;
104-
if (TestSettings::AUTH) {
105-
grpcOption.SetUseAuth(true);
106-
}
10779
grpcOption.SetPort(grpc);
10880
Server_->EnableGRpc(grpcOption);
10981
@@ -145,7 +117,6 @@ class TBasicKikimrWithGrpcAndRootSchema {
145117
ui16 GRpcPort_;
146118
};
147119
148-
using TKikimrWithGrpcAndRootSchema = TBasicKikimrWithGrpcAndRootSchema<TKikimrTestSettings>;
149120
150121
Y_UNIT_TEST_SUITE(KeyValueGRPCService) {
151122
@@ -237,13 +208,20 @@ Y_UNIT_TEST_SUITE(KeyValueGRPCService) {
237208
createVolumeResponse.operation().result().UnpackTo(&createVolumeResult);
238209
}
239210
240-
void AlterVolume(auto &channel, const TString &path, ui32 partition_count = 1) {
211+
void AlterVolume(auto &channel, const TString &path, ui32 partition_count = 1, std::optional<Ydb::KeyValue::StorageConfig> storage_config = {}) {
241212
std::unique_ptr<Ydb::KeyValue::V1::KeyValueService::Stub> stub;
242213
stub = Ydb::KeyValue::V1::KeyValueService::NewStub(channel);
243214
244215
Ydb::KeyValue::AlterVolumeRequest alterVolumeRequest;
245216
alterVolumeRequest.set_path(path);
246217
alterVolumeRequest.set_alter_partition_count(partition_count);
218+
if (storage_config) {
219+
auto *storageConfig = alterVolumeRequest.mutable_storage_config();
220+
for (const auto &channel : storage_config->channel()) {
221+
auto *channelBind = storageConfig->add_channel();
222+
channelBind->set_media(channel.media());
223+
}
224+
}
247225
248226
Ydb::KeyValue::AlterVolumeResponse alterVolumeResponse;
249227
Ydb::KeyValue::AlterVolumeResult alterVolumeResult;
@@ -831,6 +809,15 @@ Y_UNIT_TEST_SUITE(KeyValueGRPCService) {
831809
UNIT_ASSERT_VALUES_EQUAL(channel.media(), "ssd");
832810
}
833811
812+
AlterVolume(channel, tablePath, 3, describeVolumeResult.storage_config());
813+
describeVolumeResult = DescribeVolume(channel, tablePath);
814+
UNIT_ASSERT_VALUES_EQUAL(3, describeVolumeResult.partition_count());
815+
UNIT_ASSERT(describeVolumeResult.has_storage_config());
816+
UNIT_ASSERT_VALUES_EQUAL(describeVolumeResult.storage_config().channel_size(), 3);
817+
for (const auto& channel : describeVolumeResult.storage_config().channel()) {
818+
UNIT_ASSERT_VALUES_EQUAL(channel.media(), "ssd");
819+
}
820+
834821
DropVolume(channel, tablePath);
835822
listDirectoryResult = ListDirectory(channel, path);
836823
UNIT_ASSERT_VALUES_EQUAL(listDirectoryResult.self().name(), "mydb");

0 commit comments

Comments
 (0)