From efe5d7504af469adc9b21e4deebc0c799a38bc20 Mon Sep 17 00:00:00 2001 From: Jorres Tarasov Date: Thu, 23 Jan 2025 19:28:36 +0100 Subject: [PATCH] fix: use_walle:True with NopHostInfoProvider is undefined behavior --- ydb/tools/cfg/bin/__main__.py | 12 +++++++++++- ydb/tools/cfg/configurator_setup.py | 14 +------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/ydb/tools/cfg/bin/__main__.py b/ydb/tools/cfg/bin/__main__.py index 68ab819ccc08..775f9fd45a31 100644 --- a/ydb/tools/cfg/bin/__main__.py +++ b/ydb/tools/cfg/bin/__main__.py @@ -50,11 +50,21 @@ def cfg_generate(args): cluster_template = yaml.safe_load(yaml_template) host_info_provider = NopHostsInformationProvider() + + use_k8s_enabled = cluster_template.get("use_k8s", {}).get("enabled", False) if args.hosts_provider_url: + if not cluster_template.get("use_walle", False): + raise RuntimeError("you specified --hosts-provider-url, but `use_walle` is false in template.\nSpecify `use_walle: True` to continue") host_info_provider = WalleHostsInformationProvider(args.hosts_provider_url) - elif args.hosts_provider_k8s: + elif use_k8s_enabled: host_info_provider = K8sApiHostsInformationProvider(args.kubeconfig) + if cluster_template.get("use_walle", False) and not isinstance(host_info_provider, WalleHostsInformationProvider): + raise RuntimeError("you specified 'use_walle: True', but didn't specify --hosts-provider-url to initialize walle") + + if cluster_template.get("use_walle", False) and cluster_template.get("use_k8s", {}).get("enabled", False): + raise RuntimeError("you specified 'use_walle: True' and 'use_k8s.enabled: True', please select a single host info provider") + generator = cfg_cls(cluster_template, args.binary_path, args.output_dir, host_info_provider=host_info_provider, **kwargs) all_configs = generator.get_all_configs() diff --git a/ydb/tools/cfg/configurator_setup.py b/ydb/tools/cfg/configurator_setup.py index 6257b7a88ce0..3a4364ce3d7d 100644 --- a/ydb/tools/cfg/configurator_setup.py +++ b/ydb/tools/cfg/configurator_setup.py @@ -75,19 +75,7 @@ def get_parser(generate_func, extra_cfg_arguments=[]): help=v['help'], ) - host_location_group = parser_cfg.add_mutually_exclusive_group() - host_location_group.add_argument( - "--hosts-provider-k8s", - action='store_true', - help="""If specified, K8s api will be used to query information - about host location. Mutually exclusive with --host-location-url. - Usage example in template: - - k8s_settings: - use: true - k8s_rack_label: