Skip to content

Commit 603978f

Browse files
authored
Merge 3d62698 into afb7274
2 parents afb7274 + 3d62698 commit 603978f

File tree

4 files changed

+80
-11
lines changed

4 files changed

+80
-11
lines changed

ydb/tools/cfg/base.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3+
import base64
34
import collections
45
import copy
56
import os
@@ -104,7 +105,7 @@ def __hash__(self):
104105
)
105106

106107
KiKiMRHost = collections.namedtuple(
107-
"_KiKiMRHost", ["hostname", "node_id", "drives", "ic_port", "body", "datacenter", "rack", "host_config_id"]
108+
"_KiKiMRHost", ["hostname", "node_id", "drives", "ic_port", "body", "datacenter", "rack", "host_config_id", "port"]
108109
)
109110

110111
DEFAULT_PLAN_RESOLUTION = 10
@@ -425,6 +426,7 @@ def __collect_host_info(self, node_id, host_description):
425426
datacenter=self._get_datacenter(host_description),
426427
rack=self._get_rack(host_description),
427428
host_config_id=host_description.get("host_config_id", None),
429+
port=host_description.get("port", DEFAULT_INTERCONNECT_PORT),
428430
)
429431

430432
@property
@@ -682,6 +684,13 @@ def log_config(self):
682684
log_config = config_pb2.TLogConfig()
683685
if "default_level" not in log_config_dict:
684686
log_config["default_level"] = self.default_log_level
687+
688+
# This little dance is required because 'entry.component' field is `bytes` in
689+
# proto specification, attempting to deserialize it from plain text will fail
690+
for i, entry in enumerate(log_config_dict.get("entry", [])):
691+
entry["component"] = base64.b64encode(entry.get("component").encode('utf-8'))
692+
log_config_dict["entry"][i] = entry
693+
685694
utils.wrap_parse_dict(log_config_dict, log_config)
686695
return log_config
687696

ydb/tools/cfg/static.py

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def __init__(
9191
"sys.txt": self.__generate_sys_txt,
9292
"tracing.txt": self.__generate_tracing_txt,
9393
# files with default implementation
94+
"actor_system_config.txt": None,
9495
"sqs.txt": None,
9596
"vdisks.txt": None,
9697
"ic.txt": None,
@@ -110,6 +111,7 @@ def __init__(
110111
"pdisk_key.txt": None,
111112
"immediate_controls_config.txt": None,
112113
"cms_config.txt": None,
114+
"audit_config.txt": None,
113115
}
114116
self.__optional_config_files = set(
115117
(
@@ -164,6 +166,10 @@ def domains_txt(self):
164166
def feature_flags_txt(self):
165167
return self.__proto_config("feature_flags.txt", feature_flags_pb2.TFeatureFlags, self.__cluster_details.get_service("features"))
166168

169+
@property
170+
def feature_flags_new_txt(self):
171+
return self.__proto_config("feature_flags_new.txt", feature_flags_pb2.TFeatureFlags, self.__cluster_details.get_service("feature_flags"))
172+
167173
@property
168174
def failure_injection_txt(self):
169175
return self.__proto_config(
@@ -248,6 +254,14 @@ def audit_txt(self):
248254
def audit_txt_enabled(self):
249255
return self.__proto_config("audit.txt").ByteSize() > 0
250256

257+
@property
258+
def audit_config_txt(self):
259+
return self.__proto_config("audit_config.txt", config_pb2.TAuditConfig, self.__cluster_details.get_service("audit_config"))
260+
261+
@property
262+
def audit_config_txt_enabled(self):
263+
return self.__proto_config("audit_config.txt").ByteSize() > 0
264+
251265
@property
252266
def fq_txt(self):
253267
return self.__proto_config("fq.txt", TFederatedQueryConfig, self.__cluster_details.get_service("yq"))
@@ -286,6 +300,16 @@ def cms_config_txt(self):
286300
def cms_config_txt_enabled(self):
287301
return self.__proto_config("cms_config.txt").ByteSize() > 0
288302

303+
@property
304+
def actor_system_config_txt(self):
305+
return self.__proto_config("actor_system_config.txt",
306+
config_pb2.TActorSystemConfig,
307+
self.__cluster_details.get_service("actor_system_config"))
308+
309+
@property
310+
def actor_system_config_txt_enabled(self):
311+
return self.__proto_config("actor_system_config.txt").ByteSize() > 0
312+
289313
@property
290314
def mbus_enabled(self):
291315
mbus_config = self.__cluster_details.get_service("message_bus_config")
@@ -533,16 +557,16 @@ def get_normalized_config(self):
533557
if "hive_config" in normalized_config["domains_config"]:
534558
del normalized_config["domains_config"]["hive_config"]
535559

536-
hostname_to_host_config_id = {node.hostname: node.host_config_id for node in self.__cluster_details.hosts}
560+
node_to_host_config_id = {(node.hostname, node.port): node.host_config_id for node in self.__cluster_details.hosts}
537561
normalized_config["hosts"] = []
538562
for node in normalized_config["nameservice_config"]["node"]:
539-
if "port" in node and int(node.get("port")) == 19001:
563+
if "port" in node and int(node.get("port")) == base.DEFAULT_INTERCONNECT_PORT:
540564
del node["port"]
541565

542566
if "interconnect_host" in node and node["interconnect_host"] == node["host"]:
543567
del node["interconnect_host"]
544568

545-
host_config_id = hostname_to_host_config_id[node["host"]]
569+
host_config_id = node_to_host_config_id[(node["host"], node.get("port", base.DEFAULT_INTERCONNECT_PORT))]
546570
if host_config_id is not None:
547571
node["host_config_id"] = host_config_id
548572
normalized_config["hosts"].append(node)
@@ -577,6 +601,9 @@ def get_normalized_config(self):
577601
if self._yaml_config_enabled:
578602
normalized_config['yaml_config_enabled'] = True
579603

604+
if self.__cluster_details.storage_config_generation is not None:
605+
normalized_config["storage_config_generation"] = int(self.__cluster_details.storage_config_generation)
606+
580607
return normalized_config
581608

582609
def get_yaml_format_config(self, normalized_config):
@@ -628,21 +655,24 @@ def get_app_config(self):
628655
app_config.BlobStorageConfig.CopyFrom(self.bs_txt)
629656
app_config.ChannelProfileConfig.CopyFrom(self.channels_txt)
630657
app_config.DomainsConfig.CopyFrom(self.domains_txt)
658+
659+
# Old template style:
631660
if self.feature_flags_txt.ByteSize() > 0:
632661
app_config.FeatureFlags.CopyFrom(self.feature_flags_txt)
662+
# New config.yaml style:
663+
if self.feature_flags_new_txt.ByteSize() > 0:
664+
app_config.FeatureFlags.CopyFrom(self.feature_flags_new_txt)
665+
633666
app_config.LogConfig.CopyFrom(self.log_txt)
634667
if self.auth_txt.ByteSize() > 0:
635668
app_config.AuthConfig.CopyFrom(self.auth_txt)
636669
app_config.KQPConfig.CopyFrom(self.kqp_txt)
637670
app_config.NameserviceConfig.CopyFrom(self.names_txt)
638-
app_config.ActorSystemConfig.CopyFrom(self.sys_txt)
639671
app_config.GRpcConfig.CopyFrom(self.grpc_txt)
640672
app_config.InterconnectConfig.CopyFrom(self.ic_txt)
641673
app_config.VDiskConfig.CopyFrom(self.vdisks_txt)
642674
app_config.PQConfig.CopyFrom(self.pq_txt)
643675

644-
if self.cms_txt.ByteSize() > 0:
645-
app_config.CmsConfig.CopyFrom(self.cms_txt)
646676
if self.dyn_ns_txt.ByteSize() > 0:
647677
app_config.DynamicNameserviceConfig.CopyFrom(self.dyn_ns_txt)
648678
if self.pqcd_txt.ByteSize() > 0:
@@ -653,8 +683,6 @@ def get_app_config(self):
653683
app_config.ResourceBrokerConfig.CopyFrom(self.rb_txt)
654684
if self.metering_txt_enabled:
655685
app_config.MeteringConfig.CopyFrom(self.metering_txt)
656-
if self.audit_txt_enabled:
657-
app_config.AuditConfig.CopyFrom(self.audit_txt)
658686
if self.fq_txt_enabled:
659687
app_config.FederatedQueryConfig.CopyFrom(self.fq_txt)
660688
if self.failure_injection_txt_enabled:
@@ -668,8 +696,26 @@ def get_app_config(self):
668696
app_config.PDiskKeyConfig.CopyFrom(self.pdisk_key_txt)
669697
if self.immediate_controls_config_txt_enabled:
670698
app_config.ImmediateControlsConfig.CopyFrom(self.immediate_controls_config_txt)
699+
700+
# Old template style:
701+
app_config.ActorSystemConfig.CopyFrom(self.sys_txt)
702+
# New config.yaml style:
703+
if self.actor_system_config_txt_enabled:
704+
app_config.ActorSystemConfig.CopyFrom(self.actor_system_config_txt)
705+
706+
# Old template style:
707+
if self.cms_txt.ByteSize() > 0:
708+
app_config.CmsConfig.CopyFrom(self.cms_txt)
709+
# New config.yaml style:
671710
if self.cms_config_txt_enabled:
672711
app_config.CmsConfig.CopyFrom(self.cms_config_txt)
712+
713+
# Old template style:
714+
if self.audit_txt_enabled:
715+
app_config.AuditConfig.CopyFrom(self.audit_txt)
716+
# New config.yaml style:
717+
if self.audit_config_txt_enabled:
718+
app_config.AuditConfig.CopyFrom(self.audit_config_txt)
673719
return app_config
674720

675721
def __proto_config(self, config_file, config_class=None, cluster_details_for_field=None):
@@ -804,6 +850,11 @@ def __generate_bs_txt(self):
804850
if drive.expected_slot_count is not None:
805851
drive_pb.PDiskConfig.ExpectedSlotCount = drive.expected_slot_count
806852

853+
# Full support of `pdisk_config`, not just copying selected fields manually
854+
# from other non-typed locations
855+
if drive.pdisk_config is not None:
856+
utils.wrap_parse_dict(drive.pdisk_config, drive_pb.PDiskConfig)
857+
807858
assert drive_pb.Guid not in all_guids, "All Guids must be unique!"
808859
all_guids.add(drive_pb.Guid)
809860

@@ -1263,9 +1314,12 @@ def __generate_names_txt(self):
12631314
utils.wrap_parse_dict(self.__cluster_details.nameservice_config, self.names_txt)
12641315

12651316
for host in self.__cluster_details.hosts:
1317+
port = host.port
1318+
if port is base.DEFAULT_INTERCONNECT_PORT:
1319+
port = host.ic_port
12661320
node = self.names_txt.Node.add(
12671321
NodeId=host.node_id,
1268-
Port=host.ic_port,
1322+
Port=port,
12691323
Host=host.hostname,
12701324
InterconnectHost=host.hostname,
12711325
)

ydb/tools/cfg/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def get_camel_case_string(snake_str):
164164
'Vdisk': 'VDisk',
165165
'NtoSelect': 'NToSelect',
166166
'Ssid': 'SSId',
167+
'Sids': 'SIDs',
167168
}
168169
for k, v in abbreviations.items():
169170
camelCased = camelCased.replace(k, v)

ydb/tools/cfg/validation.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,12 @@
957957

958958

959959
def _host_and_ic_port(host):
960-
return "%s:%s" % (host.get("name", host.get("host")), str(host.get("ic_port", 19001)))
960+
port = 19001
961+
if "ic_port" in host:
962+
port = host["ic_port"]
963+
if "port" in host:
964+
port = host["port"]
965+
return "%s:%s" % (host.get("name", host.get("host")), str(port))
961966

962967

963968
def checkNameServiceDuplicates(validator, allow_duplicates, instance, schema):

0 commit comments

Comments
 (0)