Skip to content

Commit

Permalink
issue-757: pass path as empty TMaybe<TString> instead of empty TStrin…
Browse files Browse the repository at this point in the history
…g when registering node in Node Broker; spoil BS Controller config before restarting Kikimr after formatting static pdisks in local-emergency test (otherwise BS Controller would erase all the data from other non-static groups) (#2049)
  • Loading branch information
SvartMetal authored and Mikhail Montsev committed Sep 17, 2024
1 parent 33ae451 commit 3ec2986
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
13 changes: 9 additions & 4 deletions cloud/blockstore/libs/daemon/ydb/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,11 @@ void TBootstrapYdb::InitKikimrService()
};

bool loadCmsConfigs = Configs->Options->LoadCmsConfigs;
if (loadCmsConfigs &&
(Configs->StorageConfig->GetHiveProxyFallbackMode() ||
Configs->StorageConfig->GetSSProxyFallbackMode()))
{
bool emergencyMode =
Configs->StorageConfig->GetHiveProxyFallbackMode() ||
Configs->StorageConfig->GetSSProxyFallbackMode();

if (loadCmsConfigs && emergencyMode) {
STORAGE_INFO("Disable loading configs from CMS in emergency mode");
loadCmsConfigs = false;
}
Expand All @@ -251,6 +252,10 @@ void TBootstrapYdb::InitKikimrService()
.Settings = std::move(settings)
};

if (emergencyMode) {
registerOpts.SchemeShardDir = "";
}

if (Configs->Options->LocationFile) {
NProto::TLocation location;
ParseProtoTextFromFile(Configs->Options->LocationFile, location);
Expand Down
14 changes: 4 additions & 10 deletions cloud/blockstore/tests/loadtest/local-emergency/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# import os
import pytest

import yatest.common as common
Expand Down Expand Up @@ -82,15 +81,10 @@ def __run_test(test_case):
client.execute_action(action="BackupPathDescriptions", input_bytes=str.encode(""))
client.execute_action(action="BackupTabletBootInfos", input_bytes=str.encode(""))

static_pdisk_paths = []
for info in env.pdisks_info:
if info["pdisk_user_kind"] == 0:
static_pdisk_paths += [info["pdisk_path"]]
assert len(static_pdisk_paths) == 1

# Destroy static group in order to emulate emergency.
# TODO: survive outage of kikimr static tablets.
# os.remove(static_pdisk_paths[0])
env.kikimr_cluster.format_static_pdisks()
# spoil config to prevent BS Controller from starting otherwise it will
# erase dynamic groups data
env.kikimr_cluster.spoil_bs_controller_config()
env.kikimr_cluster.restart_nodes()

env.nbs.storage_config_patches = [storage_config_with_emergency_mode(backups_folder)]
Expand Down
9 changes: 7 additions & 2 deletions cloud/storage/core/libs/kikimr/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ struct TLegacyNodeRegistrant
{
NClient::TKikimr kikimr(CreateKikimrConfig(Options, nodeBrokerAddress));

TMaybe<TString> path;
if (Options.SchemeShardDir) {
path = Options.SchemeShardDir;
}

auto registrant = kikimr.GetNodeRegistrant();
auto result = registrant.SyncRegisterNode(
Options.Domain,
Expand All @@ -232,8 +237,8 @@ struct TLegacyNodeRegistrant
HostAddress,
HostName,
Location,
false, //request fixed node id
Options.SchemeShardDir);
false, // fixedNodeId
path);

if (!result.IsSuccess()) {
return MakeError(
Expand Down
24 changes: 24 additions & 0 deletions ydb/tests/library/harness/kikimr_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,30 @@ def __instantiate_udfs_dir(self):
os.symlink(udf_path, link_name)
return self.__common_udfs_dir

# TODO(svartmetal): remove this when YDB learns not to erase dynamic groups
# data after formatting of static pdisks
def spoil_bs_controller_config(self):
flat_bs_controller = [{
"info": {
"channels": [{
"channel": 0,
"channel_erasure_name": str(self.__configurator.static_erasure),
"history": [{
"from_generation": 0,
"group_id": 100500
}]
}]
}
}]
self.__configurator.yaml_config["system_tablets"]["flat_bs_controller"] = flat_bs_controller
self.__write_configs()

def format_static_pdisks(self):
for node_id in self.__configurator.all_node_ids():
for pdisk in self.__configurator.pdisks_info:
if pdisk["pdisk_user_kind"] == 0:
self.nodes[node_id].format_pdisk(**pdisk)

def __format_disks(self, node_id):
for pdisk in self.__configurator.pdisks_info:
if pdisk['node_id'] != node_id:
Expand Down

0 comments on commit 3ec2986

Please sign in to comment.