Skip to content

Commit 3041d8f

Browse files
authored
Fix BSC config proto (#21276)
(cherry picked from commit 95b354d)
1 parent 7a91dce commit 3041d8f

File tree

13 files changed

+159
-73
lines changed

13 files changed

+159
-73
lines changed

ydb/apps/dstool/lib/dstool_cmd_cluster_set.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ def create_request(args):
4040

4141
cmd = request.Command.add().UpdateSettings
4242
if args.default_max_slots is not None:
43-
cmd.DefaultMaxSlots = args.default_max_slots
43+
cmd.DefaultMaxSlots.append(args.default_max_slots)
4444
if args.self_heal is not None:
45-
cmd.EnableSelfHeal = args.self_heal
45+
cmd.EnableSelfHeal.append(args.self_heal)
4646
if args.donor_mode is not None:
47-
cmd.EnableDonorMode = args.donor_mode
47+
cmd.EnableDonorMode.append(args.donor_mode)
4848
if args.scrub_periodicity is not None:
4949
if args.scrub_periodicity == 'disable':
5050
d = timedelta()
@@ -53,21 +53,21 @@ def create_request(args):
5353
if m is None:
5454
raise Exception('Incorrect scrub periodicity format %s' % args.scrub_periodicity)
5555
d = timedelta(**dict(zip(['days', 'hours', 'minutes', 'seconds'], map(lambda x: int(x or 0), m.group(2, 4, 6, 8)))))
56-
cmd.ScrubPeriodicitySeconds = int(d.total_seconds())
56+
cmd.ScrubPeriodicitySeconds.append(int(d.total_seconds()))
5757
if args.pdisk_space_margin_promille is not None:
5858
if args.pdisk_space_margin_promille < 0 or args.pdisk_space_margin_promille > 1000:
5959
raise Exception('Incorrect PDisk space margin setting %f' % args.pdisk_space_margin_promille)
60-
cmd.PDiskSpaceMarginPromille = args.pdisk_space_margin_promille
60+
cmd.PDiskSpaceMarginPromille.append(args.pdisk_space_margin_promille)
6161
if args.group_reserve_min is not None:
62-
cmd.GroupReserveMin = args.group_reserve_min
62+
cmd.GroupReserveMin.append(args.group_reserve_min)
6363
if args.group_reserve_part_ppm is not None:
64-
cmd.GroupReservePartPPM = args.group_reserve_part_ppm
64+
cmd.GroupReservePartPPM.append(args.group_reserve_part_ppm)
6565
if args.max_scrubbed_disks_at_once is not None:
66-
cmd.MaxScrubbedDisksAtOnce = args.max_scrubbed_disks_at_once
66+
cmd.MaxScrubbedDisksAtOnce.append(args.max_scrubbed_disks_at_once)
6767
if args.pdisk_space_color_border is not None:
68-
cmd.PDiskSpaceColorBorder = disk_color.TPDiskSpaceColor.E.Value(args.pdisk_space_color_border)
68+
cmd.PDiskSpaceColorBorder.append(disk_color.TPDiskSpaceColor.E.Value(args.pdisk_space_color_border))
6969
if args.self_heal_local_policy is not None:
70-
cmd.UseSelfHealLocalPolicy = args.self_heal_local_policy
70+
cmd.UseSelfHealLocalPolicy.append(args.self_heal_local_policy)
7171

7272
return request
7373

ydb/core/blobstorage/nodewarden/distconf_generate.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ namespace NKikimr::NStorage {
123123

124124
if (baseConfig->HasSettings()) {
125125
const auto& settings = baseConfig->GetSettings();
126-
if (settings.HasDefaultMaxSlots()) {
127-
defaultMaxSlots = settings.GetDefaultMaxSlots();
126+
if (settings.DefaultMaxSlotsSize()) {
127+
defaultMaxSlots = settings.GetDefaultMaxSlots(0);
128128
}
129-
if (settings.HasPDiskSpaceColorBorder()) {
130-
pdiskSpaceColorBorder.emplace(settings.GetPDiskSpaceColorBorder());
129+
if (settings.PDiskSpaceColorBorderSize()) {
130+
pdiskSpaceColorBorder.emplace(settings.GetPDiskSpaceColorBorder(0));
131131
}
132-
if (settings.HasPDiskSpaceMarginPromille()) {
133-
pdiskSpaceMarginPromille = settings.GetPDiskSpaceMarginPromille();
132+
if (settings.PDiskSpaceMarginPromilleSize()) {
133+
pdiskSpaceMarginPromille = settings.GetPDiskSpaceMarginPromille(0);
134134
}
135135
}
136136

ydb/core/blobstorage/ut_blobstorage/lib/env.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,9 +792,9 @@ struct TEnvironmentSetup {
792792
NKikimrBlobStorage::TConfigRequest request;
793793
auto *cmd = request.AddCommand();
794794
auto *us = cmd->MutableUpdateSettings();
795-
us->SetEnableSelfHeal(selfHeal);
796-
us->SetEnableDonorMode(donorMode);
797-
us->SetEnableGroupLayoutSanitizer(groupLayoutSanitizer);
795+
us->AddEnableSelfHeal(selfHeal);
796+
us->AddEnableDonorMode(donorMode);
797+
us->AddEnableGroupLayoutSanitizer(groupLayoutSanitizer);
798798
auto response = Invoke(request);
799799
UNIT_ASSERT_C(response.GetSuccess(), response.GetErrorDescription());
800800
}

ydb/core/blobstorage/ut_blobstorage/sanitize_groups.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ Y_UNIT_TEST_SUITE(GroupLayoutSanitizer) {
196196
NKikimrBlobStorage::TConfigRequest request;
197197
auto *cmd = request.AddCommand();
198198
auto *us = cmd->MutableUpdateSettings();
199-
us->SetEnableSelfHeal(true);
200-
us->SetEnableGroupLayoutSanitizer(true);
199+
us->AddEnableSelfHeal(true);
200+
us->AddEnableGroupLayoutSanitizer(true);
201201
// us->AddAllowMultipleRealmsOccupation(allowMultipleRealmsOccupation);
202202
auto response = env->Invoke(request);
203203
UNIT_ASSERT_C(response.GetSuccess(), response.GetErrorDescription());

ydb/core/mind/bscontroller/bsc.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "config.h"
33
#include "self_heal.h"
44
#include "sys_view.h"
5+
#include "util.h"
56

67
namespace NKikimr {
78

@@ -185,9 +186,7 @@ void TBlobStorageController::ApplyBscSettings(const NKikimrConfig::TBlobStorageC
185186
auto *request = r.MutableRequest();
186187
auto* command = request->AddCommand();
187188

188-
auto updateSettings = command->MutableUpdateSettings();
189-
190-
updateSettings->CopyFrom(bsConfig.GetBscSettings());
189+
command->MutableUpdateSettings()->CopyFrom(FromBscConfig(bsConfig.GetBscSettings()));
191190

192191
STLOG(PRI_DEBUG, BS_CONTROLLER, BSC17, "ApplyBSCSettings", (Request, r));
193192
Send(SelfId(), ev.release());

ydb/core/mind/bscontroller/config.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,20 +1179,20 @@ namespace NKikimr::NBsController {
11791179
}
11801180

11811181
void TBlobStorageController::SerializeSettings(NKikimrBlobStorage::TUpdateSettings *settings) {
1182-
settings->SetDefaultMaxSlots(DefaultMaxSlots);
1183-
settings->SetEnableSelfHeal(SelfHealEnable);
1184-
settings->SetEnableDonorMode(DonorMode);
1185-
settings->SetScrubPeriodicitySeconds(ScrubPeriodicity.Seconds());
1186-
settings->SetPDiskSpaceMarginPromille(PDiskSpaceMarginPromille);
1187-
settings->SetGroupReserveMin(GroupReserveMin);
1188-
settings->SetGroupReservePartPPM(GroupReservePart);
1189-
settings->SetMaxScrubbedDisksAtOnce(MaxScrubbedDisksAtOnce);
1190-
settings->SetPDiskSpaceColorBorder(PDiskSpaceColorBorder);
1191-
settings->SetEnableGroupLayoutSanitizer(GroupLayoutSanitizerEnabled);
1192-
// TODO: settings->SetSerialManagementStage(SerialManagementStage);
1193-
settings->SetAllowMultipleRealmsOccupation(AllowMultipleRealmsOccupation);
1194-
settings->SetUseSelfHealLocalPolicy(UseSelfHealLocalPolicy);
1195-
settings->SetTryToRelocateBrokenDisksLocallyFirst(TryToRelocateBrokenDisksLocallyFirst);
1182+
settings->AddDefaultMaxSlots(DefaultMaxSlots);
1183+
settings->AddEnableSelfHeal(SelfHealEnable);
1184+
settings->AddEnableDonorMode(DonorMode);
1185+
settings->AddScrubPeriodicitySeconds(ScrubPeriodicity.Seconds());
1186+
settings->AddPDiskSpaceMarginPromille(PDiskSpaceMarginPromille);
1187+
settings->AddGroupReserveMin(GroupReserveMin);
1188+
settings->AddGroupReservePartPPM(GroupReservePart);
1189+
settings->AddMaxScrubbedDisksAtOnce(MaxScrubbedDisksAtOnce);
1190+
settings->AddPDiskSpaceColorBorder(PDiskSpaceColorBorder);
1191+
settings->AddEnableGroupLayoutSanitizer(GroupLayoutSanitizerEnabled);
1192+
// TODO: settings->AddSerialManagementStage(SerialManagementStage);
1193+
settings->AddAllowMultipleRealmsOccupation(AllowMultipleRealmsOccupation);
1194+
settings->AddUseSelfHealLocalPolicy(UseSelfHealLocalPolicy);
1195+
settings->AddTryToRelocateBrokenDisksLocallyFirst(TryToRelocateBrokenDisksLocallyFirst);
11961196
}
11971197

11981198
} // NKikimr::NBsController

ydb/core/mind/bscontroller/config_cmd.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -88,69 +88,69 @@ namespace NKikimr::NBsController {
8888
case NKikimrBlobStorage::TConfigRequest::TCommand::kUpdateSettings: {
8989
const auto& settings = cmd.GetUpdateSettings();
9090
using T = Schema::State;
91-
if (settings.HasDefaultMaxSlots()) {
92-
Self->DefaultMaxSlots = settings.GetDefaultMaxSlots();
91+
for (ui32 value : settings.GetDefaultMaxSlots()) {
92+
Self->DefaultMaxSlots = value;
9393
db.Table<T>().Key(true).Update<T::DefaultMaxSlots>(Self->DefaultMaxSlots);
9494
}
95-
if (settings.HasEnableSelfHeal()) {
96-
Self->SelfHealEnable = settings.GetEnableSelfHeal();
95+
for (bool value : settings.GetEnableSelfHeal()) {
96+
Self->SelfHealEnable = value;
9797
db.Table<T>().Key(true).Update<T::SelfHealEnable>(Self->SelfHealEnable);
9898
}
99-
if (settings.HasEnableDonorMode()) {
100-
Self->DonorMode = settings.GetEnableDonorMode();
99+
for (bool value : settings.GetEnableDonorMode()) {
100+
Self->DonorMode = value;
101101
db.Table<T>().Key(true).Update<T::DonorModeEnable>(Self->DonorMode);
102102
auto ev = std::make_unique<TEvControllerUpdateSelfHealInfo>();
103103
ev->DonorMode = Self->DonorMode;
104104
Self->Send(Self->SelfHealId, ev.release());
105105
}
106-
if (settings.HasScrubPeriodicitySeconds()) {
107-
Self->ScrubPeriodicity = TDuration::Seconds(settings.GetScrubPeriodicitySeconds());
106+
for (ui64 value : settings.GetScrubPeriodicitySeconds()) {
107+
Self->ScrubPeriodicity = TDuration::Seconds(value);
108108
db.Table<T>().Key(true).Update<T::ScrubPeriodicity>(Self->ScrubPeriodicity.Seconds());
109109
Self->ScrubState.OnScrubPeriodicityChange();
110110
}
111-
if (settings.HasPDiskSpaceMarginPromille()) {
112-
Self->PDiskSpaceMarginPromille = settings.GetPDiskSpaceMarginPromille();
111+
for (ui32 value : settings.GetPDiskSpaceMarginPromille()) {
112+
Self->PDiskSpaceMarginPromille = value;
113113
db.Table<T>().Key(true).Update<T::PDiskSpaceMarginPromille>(Self->PDiskSpaceMarginPromille);
114114
}
115-
if (settings.HasGroupReserveMin()) {
116-
Self->GroupReserveMin = settings.GetGroupReserveMin();
115+
for (ui32 value : settings.GetGroupReserveMin()) {
116+
Self->GroupReserveMin = value;
117117
db.Table<T>().Key(true).Update<T::GroupReserveMin>(Self->GroupReserveMin);
118118
Self->SysViewChangedSettings = true;
119119
}
120-
if (settings.HasGroupReservePartPPM()) {
121-
Self->GroupReservePart = settings.GetGroupReservePartPPM();
120+
for (ui32 value : settings.GetGroupReservePartPPM()) {
121+
Self->GroupReservePart = value;
122122
db.Table<T>().Key(true).Update<T::GroupReservePart>(Self->GroupReservePart);
123123
Self->SysViewChangedSettings = true;
124124
}
125-
if (settings.HasMaxScrubbedDisksAtOnce()) {
126-
Self->MaxScrubbedDisksAtOnce = settings.GetMaxScrubbedDisksAtOnce();
125+
for (ui32 value : settings.GetMaxScrubbedDisksAtOnce()) {
126+
Self->MaxScrubbedDisksAtOnce = value;
127127
db.Table<T>().Key(true).Update<T::MaxScrubbedDisksAtOnce>(Self->MaxScrubbedDisksAtOnce);
128128
Self->ScrubState.OnMaxScrubbedDisksAtOnceChange();
129129
}
130-
if (settings.HasPDiskSpaceColorBorder()) {
131-
Self->PDiskSpaceColorBorder = static_cast<T::PDiskSpaceColorBorder::Type>(settings.GetPDiskSpaceColorBorder());
130+
for (auto value : settings.GetPDiskSpaceColorBorder()) {
131+
Self->PDiskSpaceColorBorder = static_cast<T::PDiskSpaceColorBorder::Type>(value);
132132
db.Table<T>().Key(true).Update<T::PDiskSpaceColorBorder>(Self->PDiskSpaceColorBorder);
133133
}
134-
if (settings.HasEnableGroupLayoutSanitizer()) {
135-
Self->GroupLayoutSanitizerEnabled = settings.GetEnableGroupLayoutSanitizer();
134+
for (bool value : settings.GetEnableGroupLayoutSanitizer()) {
135+
Self->GroupLayoutSanitizerEnabled = value;
136136
db.Table<T>().Key(true).Update<T::GroupLayoutSanitizer>(Self->GroupLayoutSanitizerEnabled);
137137
auto ev = std::make_unique<TEvControllerUpdateSelfHealInfo>();
138138
ev->GroupLayoutSanitizerEnabled = Self->GroupLayoutSanitizerEnabled;
139139
Self->Send(Self->SelfHealId, ev.release());
140140
}
141-
if (settings.HasAllowMultipleRealmsOccupation()) {
142-
Self->AllowMultipleRealmsOccupation = settings.GetAllowMultipleRealmsOccupation();
141+
for (bool value : settings.GetAllowMultipleRealmsOccupation()) {
142+
Self->AllowMultipleRealmsOccupation = value;
143143
db.Table<T>().Key(true).Update<T::AllowMultipleRealmsOccupation>(Self->AllowMultipleRealmsOccupation);
144144
auto ev = std::make_unique<TEvControllerUpdateSelfHealInfo>();
145145
ev->AllowMultipleRealmsOccupation = Self->AllowMultipleRealmsOccupation;
146146
Self->Send(Self->SelfHealId, ev.release());
147147
}
148-
if (settings.HasUseSelfHealLocalPolicy()) {
149-
Self->UseSelfHealLocalPolicy = settings.GetUseSelfHealLocalPolicy();
148+
for (bool value : settings.GetUseSelfHealLocalPolicy()) {
149+
Self->UseSelfHealLocalPolicy = value;
150150
db.Table<T>().Key(true).Update<T::UseSelfHealLocalPolicy>(Self->UseSelfHealLocalPolicy);
151151
}
152-
if (settings.HasTryToRelocateBrokenDisksLocallyFirst()) {
153-
Self->TryToRelocateBrokenDisksLocallyFirst = settings.GetTryToRelocateBrokenDisksLocallyFirst();
152+
for (bool value : settings.GetTryToRelocateBrokenDisksLocallyFirst()) {
153+
Self->TryToRelocateBrokenDisksLocallyFirst = value;
154154
db.Table<T>().Key(true).Update<T::TryToRelocateBrokenDisksLocallyFirst>(Self->TryToRelocateBrokenDisksLocallyFirst);
155155
}
156156
return true;

ydb/core/mind/bscontroller/ut_selfheal/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ Y_UNIT_TEST_SUITE(BsControllerTest) {
5757
NKikimrBlobStorage::TConfigRequest request;
5858
auto *cmd = request.AddCommand()->MutableUpdateSettings();
5959
if (useSelfHealLocalPolicy.has_value()) {
60-
cmd->SetUseSelfHealLocalPolicy(*useSelfHealLocalPolicy);
60+
cmd->AddUseSelfHealLocalPolicy(*useSelfHealLocalPolicy);
6161
}
6262
if (tryToRelocateBrokenDisksLocallyFirst.has_value()) {
63-
cmd->SetTryToRelocateBrokenDisksLocallyFirst(*tryToRelocateBrokenDisksLocallyFirst);
63+
cmd->AddTryToRelocateBrokenDisksLocallyFirst(*tryToRelocateBrokenDisksLocallyFirst);
6464
}
65-
cmd->SetGroupReserveMin(additionalSlots);
66-
cmd->SetEnableDonorMode(true);
65+
cmd->AddGroupReserveMin(additionalSlots);
66+
cmd->AddEnableDonorMode(true);
6767
auto response = Env.Invoke(request);
6868
UNIT_ASSERT_C(response.GetSuccess(), response.GetErrorDescription());
6969
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include "util.h"
2+
3+
namespace NKikimr::NBsController {
4+
5+
NKikimrBlobStorage::TUpdateSettings FromBscConfig(const NKikimrBlobStorage::TBscConfig &config) {
6+
NKikimrBlobStorage::TUpdateSettings result;
7+
8+
if (config.HasDefaultMaxSlots()) {
9+
result.AddDefaultMaxSlots(config.GetDefaultMaxSlots());
10+
}
11+
if (config.HasEnableSelfHeal()) {
12+
result.AddEnableSelfHeal(config.GetEnableSelfHeal());
13+
}
14+
if (config.HasEnableDonorMode()) {
15+
result.AddEnableDonorMode(config.GetEnableDonorMode());
16+
}
17+
if (config.HasScrubPeriodicitySeconds()) {
18+
result.AddScrubPeriodicitySeconds(config.GetScrubPeriodicitySeconds());
19+
}
20+
if (config.HasPDiskSpaceMarginPromille()) {
21+
result.AddPDiskSpaceMarginPromille(config.GetPDiskSpaceMarginPromille());
22+
}
23+
if (config.HasGroupReserveMin()) {
24+
result.AddGroupReserveMin(config.GetGroupReserveMin());
25+
}
26+
if (config.HasGroupReservePartPPM()) {
27+
result.AddGroupReservePartPPM(config.GetGroupReservePartPPM());
28+
}
29+
if (config.HasMaxScrubbedDisksAtOnce()) {
30+
result.AddMaxScrubbedDisksAtOnce(config.GetMaxScrubbedDisksAtOnce());
31+
}
32+
if (config.HasPDiskSpaceColorBorder()) {
33+
result.AddPDiskSpaceColorBorder(config.GetPDiskSpaceColorBorder());
34+
}
35+
if (config.HasEnableGroupLayoutSanitizer()) {
36+
result.AddEnableGroupLayoutSanitizer(config.GetEnableGroupLayoutSanitizer());
37+
}
38+
if (config.HasAllowMultipleRealmsOccupation()) {
39+
result.AddAllowMultipleRealmsOccupation(config.GetAllowMultipleRealmsOccupation());
40+
}
41+
if (config.HasUseSelfHealLocalPolicy()) {
42+
result.AddUseSelfHealLocalPolicy(config.GetUseSelfHealLocalPolicy());
43+
}
44+
if (config.HasTryToRelocateBrokenDisksLocallyFirst()) {
45+
result.AddTryToRelocateBrokenDisksLocallyFirst(config.GetTryToRelocateBrokenDisksLocallyFirst());
46+
}
47+
48+
return result;
49+
}
50+
51+
52+
} // NKikimr::NBsController

ydb/core/mind/bscontroller/util.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include <ydb/core/protos/blobstorage_config.pb.h>
4+
5+
namespace NKikimr::NBsController {
6+
7+
NKikimrBlobStorage::TUpdateSettings FromBscConfig(const NKikimrBlobStorage::TBscConfig &config);
8+
9+
} // NKikimr::NBsController

0 commit comments

Comments
 (0)