Skip to content

Commit b6bea7d

Browse files
AleYakovlevAlexander Yakovlev
andauthored
Add env param to kikimr_configure --enable_modules, default false (#27724)
Co-authored-by: Alexander Yakovlev <[email protected]>
1 parent 744e230 commit b6bea7d

File tree

5 files changed

+37
-5
lines changed

5 files changed

+37
-5
lines changed

ydb/tools/cfg/base.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __hash__(self):
105105
)
106106

107107
KiKiMRHost = collections.namedtuple(
108-
"_KiKiMRHost", ["hostname", "node_id", "drives", "ic_port", "body", "datacenter", "rack", "host_config_id", "port"]
108+
"_KiKiMRHost", ["hostname", "node_id", "drives", "ic_port", "body", "datacenter", "module", "rack", "host_config_id", "port"]
109109
)
110110

111111
DEFAULT_PLAN_RESOLUTION = 10
@@ -417,6 +417,16 @@ def _get_body(self, host_description):
417417

418418
return str(self._host_info_provider.get_body(host_description.get("name", host_description.get("host"))))
419419

420+
def _get_module(self, host_description):
421+
if host_description.get("module") is not None:
422+
return str(host_description.get("module"))
423+
module = host_description.get("location", {}).get("module", None)
424+
if module is not None:
425+
return str(module)
426+
427+
module_from_provider = self._host_info_provider.get_module(host_description.get("name", host_description.get("host")))
428+
return str(module_from_provider) if module_from_provider else ""
429+
420430
def _collect_drives_info(self, host_description):
421431
host_config_id = host_description.get("host_config_id", None)
422432
drives = host_description.get("drives", [])
@@ -439,6 +449,7 @@ def __collect_host_info(self, node_id, host_description):
439449
ic_port=host_description.get("ic_port", DEFAULT_INTERCONNECT_PORT),
440450
body=self._get_body(host_description),
441451
datacenter=self._get_datacenter(host_description),
452+
module=self._get_module(host_description),
442453
rack=self._get_rack(host_description),
443454
host_config_id=host_description.get("host_config_id", None),
444455
port=host_description.get("port", DEFAULT_INTERCONNECT_PORT),

ydb/tools/cfg/configurator_setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def parse_optional_arguments(args):
2222
kwargs['walle_url'] = args.walle_url
2323

2424
kwargs['enable_cores'] = args.enable_cores
25+
kwargs['enable_modules'] = getattr(args, 'enable_modules', False)
2526

2627
for cmd_arg in ('ic_port', 'grpc_port', 'mbus_port', 'mon_port', 'cfg_home', 'sqs_port', 'binaries_home'):
2728
if hasattr(args, cmd_arg) and getattr(args, cmd_arg) is not None:
@@ -59,6 +60,9 @@ def get_parser(generate_func, extra_cfg_arguments=[]):
5960
'--tenant', type=str, help='Tenant to serve (possible options: name of domain or no for pure storage nodes)'
6061
)
6162
parser_cfg.add_argument('--enable-cores', action='store_true', help='Enables coredumps')
63+
parser_cfg.add_argument(
64+
'--enable-modules', action='store_true', help='Enable module field in node location configuration (default: false)'
65+
)
6266
parser_cfg.add_argument(
6367
'--dynamic-node', action='store_true', help='Indicates that configuration should be generated for dynamic node'
6468
)

ydb/tools/cfg/dynamic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(
3232
self._grpc_endpoint = grpc_endpoint
3333
self.__configure_request = None
3434
self.__static_config = static.StaticConfigGenerator(
35-
template, binary_path, output_dir, host_info_provider=host_info_provider, local_binary_path=local_binary_path
35+
template, binary_path, output_dir, host_info_provider=host_info_provider, local_binary_path=local_binary_path, **kwargs
3636
)
3737

3838
@property

ydb/tools/cfg/static.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def __init__(
5353
cfg_home="/Berkanavt/kikimr",
5454
sqs_port=8771,
5555
enable_cores=False,
56+
enable_modules=False,
5657
local_binary_path=None,
5758
skip_location=False,
5859
schema_validator=None,
@@ -70,6 +71,7 @@ def __init__(
7071
self._host_info_provider._init_k8s_labels(self.__cluster_details.k8s_rack_label, self.__cluster_details.k8s_dc_label)
7172

7273
self._enable_cores = template.get("enable_cores", enable_cores)
74+
self._enable_modules = template.get("enable_modules", enable_modules)
7375
self._yaml_config_enabled = template.get("yaml_config_enabled", False)
7476
self.__is_dynamic_node = True if database is not None else False
7577
self._database = database
@@ -1509,6 +1511,8 @@ def __generate_names_txt(self):
15091511
if not self._skip_location:
15101512
if self.__cluster_details.use_walle:
15111513
node.WalleLocation.DataCenter = host.datacenter
1514+
if self._enable_modules:
1515+
node.WalleLocation.Module = host.module
15121516
node.WalleLocation.Rack = host.rack
15131517
node.WalleLocation.Body = int(host.body)
15141518
elif self.__cluster_details.use_k8s_api:
@@ -1517,6 +1521,8 @@ def __generate_names_txt(self):
15171521
node.Location.Body = int(host.body)
15181522
else:
15191523
node.Location.DataCenter = host.datacenter
1524+
if self._enable_modules:
1525+
node.Location.Module = host.module
15201526
node.Location.Rack = host.rack
15211527
node.Location.Body = int(host.body)
15221528

ydb/tools/cfg/walle/walle.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ class HostsInformationProvider:
1717
__metaclass__ = ABCMeta
1818

1919
@abstractmethod
20-
def get_rack(hostname):
20+
def get_rack(self, hostname):
2121
pass
2222

2323
@abstractmethod
24-
def get_datacenter(hostname):
24+
def get_datacenter(self, hostname):
2525
pass
2626

2727
@abstractmethod
28-
def get_body(hostname):
28+
def get_body(self, hostname):
29+
pass
30+
31+
@abstractmethod
32+
def get_module(self, hostname):
2933
pass
3034

3135

@@ -44,6 +48,9 @@ def get_datacenter(self, hostname):
4448
def get_body(self, hostname):
4549
return zlib.crc32(hostname.encode())
4650

51+
def get_module(self, hostname):
52+
return "FAKE"
53+
4754

4855
class WalleHostsInformationProvider(HostsInformationProvider):
4956
def __init__(self, provider_url=None, cloud_mode=False):
@@ -103,5 +110,9 @@ def get_datacenter(self, hostname):
103110
short_dc_name = self._ask_location(hostname)["location"]["short_datacenter_name"]
104111
return short_dc_name if self._cloud_mode else short_dc_name.upper()
105112

113+
def get_module(self, hostname):
114+
queue = self._ask_location(hostname)["location"].get("queue", "")
115+
return queue if self._cloud_mode else queue.upper()
116+
106117
def get_body(self, hostname):
107118
return self._ask_location(hostname)["inv"]

0 commit comments

Comments
 (0)