aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgor Tarasov <jorres.tarasov@gmail.com>2025-05-19 12:34:47 +0200
committerGitHub <noreply@github.com>2025-05-19 12:34:47 +0200
commit053c0fcf46b01e501dd90b97c31f247cb53854ef (patch)
tree6e0b054c106e78d6a0233ef5215287d731252321
parentc610371c6395c6909130e42eba5e513d845ce554 (diff)
downloadydb-053c0fcf46b01e501dd90b97c31f247cb53854ef.tar.gz
Fix 'domains_config' generation of default options (#18084)
-rw-r--r--ydb/tools/cfg/base.py4
-rw-r--r--ydb/tools/cfg/static.py36
2 files changed, 36 insertions, 4 deletions
diff --git a/ydb/tools/cfg/base.py b/ydb/tools/cfg/base.py
index 7f3ce212454..818051df141 100644
--- a/ydb/tools/cfg/base.py
+++ b/ydb/tools/cfg/base.py
@@ -639,6 +639,10 @@ class ClusterDetailsProvider(object):
self.__cluster_description["domains"] = values
@property
+ def domains_config_as_dict(self):
+ return self.__cluster_description["domains_config"]
+
+ @property
def domains_config(self):
domains_config_dict = self.__cluster_description.get("domains_config", {})
if domains_config_dict == {}:
diff --git a/ydb/tools/cfg/static.py b/ydb/tools/cfg/static.py
index e4e3ef8c488..407cff50766 100644
--- a/ydb/tools/cfg/static.py
+++ b/ydb/tools/cfg/static.py
@@ -35,7 +35,7 @@ from ydb.tools.cfg.templates import (
kikimr_cfg_for_static_node_new_style,
)
-logger = logging.getLogger(__name__)
+logger = logging.getLogger()
class StaticConfigGenerator(object):
@@ -1147,7 +1147,7 @@ class StaticConfigGenerator(object):
if domains_config is None:
self.__generate_domains_from_old_domains_key()
else:
- self.__generate_domains_from_proto(domains_config)
+ self.__generate_domains_from_proto(domains_config, self.__cluster_details.domains_config_as_dict)
def __generate_default_pool_with_kind(self, pool_kind):
pool = config_pb2.TDomainsConfig.TStoragePoolType()
@@ -1167,7 +1167,8 @@ class StaticConfigGenerator(object):
'rotencrypted': blobstorage_base3_pb2.EPDiskType.ROT,
}
- property.Type = diskTypeToProto[pool_kind]
+ if pool_kind in diskTypeToProto:
+ property.Type = diskTypeToProto[pool_kind]
pool.PoolConfig.CopyFrom(pool_config)
return pool
@@ -1181,7 +1182,32 @@ class StaticConfigGenerator(object):
[self.__tablet_types.TX_ALLOCATOR.tablet_id_for(i) for i in range(int(allocators))]
)
- def __generate_domains_from_proto(self, domains_config):
+ def __check_pool_configs(self, domain, domains_config_dict):
+ for pool in domain.StoragePoolTypes:
+ # Empirical check: if a pool has 'encrypted' in its name it probably should be encrypted
+ if 'encrypted' in pool.Kind and pool.PoolConfig.EncryptionMode != 1:
+ # Special case for migration purposes: if `encryption_mode: 0` is present in pool config,
+ # we should still allow it even if the naming contains `encrypted`. We have to rely on yaml config
+ # because there is no way in proto message to distinguish between missing and undefined keys
+ encryption_mode_0 = False
+ for storage_pool_type in domains_config_dict['domain'][0]['storage_pool_types']:
+ if storage_pool_type['kind'] == pool.Kind and 'encryption_mode' in storage_pool_type['pool_config']:
+ encryption_mode_0 = True
+ break
+
+ if not encryption_mode_0:
+ raise RuntimeError(f"You named a storage pool '{pool.Kind}', but did not explicitly enable `pool_config.encryption_mode: 1`. Either specify the value (0 or 1) or rename the pool")
+
+ # Check disk type is specified for every pool
+ type_defined = False
+ for filterElement in pool.PoolConfig.PDiskFilter:
+ if filterElement.Property and filterElement.Property[0].Type:
+ type_defined = True
+
+ if not type_defined:
+ logger.warning(f"pdisk_filter.property.type missing for pool {pool.Kind}. This pool name is unknown, no default has been generated, specify type by hand")
+
+ def __generate_domains_from_proto(self, domains_config, domains_config_dict):
domains = domains_config.Domain
if len(domains) > 1:
raise ValueError('Multiple domains specified: len(domains_config.domain) > 1. This is unsupported')
@@ -1202,6 +1228,8 @@ class StaticConfigGenerator(object):
defaultPool.MergeFrom(pool)
pool.CopyFrom(defaultPool)
+ self.__check_pool_configs(domain, domains_config_dict)
+
if not domain.DomainId:
domain.DomainId = 1
if not domain.PlanResolution: