Skip to content

Commit 1d0ddf7

Browse files
authored
merge to 25.1: Return storage pool kind in TChannelBind (#15209)
1 parent b1889da commit 1d0ddf7

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
@@ -62,6 +62,7 @@ bool ResolvePoolNames(
6262

6363
result.emplace_back();
6464
result.back().SetStoragePoolName(poolIt->GetName());
65+
result.back().SetStoragePoolKind(poolIt->GetKind());
6566
}
6667

6768
channelsBinding.swap(result);
@@ -532,8 +533,8 @@ bool TSchemeShard::ApplyStorageConfig(
532533
return pools.cend();
533534
};
534535

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

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

@@ -560,14 +562,15 @@ bool TSchemeShard::ApplyStorageConfig(
560562

561563
channelsBinding.emplace_back();
562564
channelsBinding.back().SetStoragePoolName(sysLogPool->GetName());
565+
channelsBinding.back().SetStoragePoolKind(sysLogPool->GetKind());
563566
}
564567

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

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

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

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

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

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)