Skip to content

Commit

Permalink
fix: use_walle:True with NopHostInfoProvider is undefined behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorres committed Jan 23, 2025
1 parent 1f8521b commit efe5d75
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
12 changes: 11 additions & 1 deletion ydb/tools/cfg/bin/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 1 addition & 13 deletions ydb/tools/cfg/configurator_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: <label>
k8s_dc_label: <label>""")
host_location_group.add_argument(
parser_cfg.add_argument(
"--hosts-provider-url",
type=str,
help="""URL from which information about hosts can be obtained.
Expand Down

0 comments on commit efe5d75

Please sign in to comment.