Skip to content

Commit

Permalink
Remove dispatch_run_light and dispatch_run_raw_cfg from ydb_slice (yd…
Browse files Browse the repository at this point in the history
  • Loading branch information
maximyurchuk authored Apr 12, 2024
1 parent 9eed797 commit e85d4d6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 43 deletions.
34 changes: 5 additions & 29 deletions ydb/tools/ydbd_slice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,19 +542,6 @@ def _run(args):
mode.set_defaults(handler=_run)


def dispatch_run_light(func, args, walle_provider):
logger.debug("run func '%s' with cmd args is '%s'", func.__name__, args)

cluster_details = safe_load_cluster_details(args.cluster, walle_provider)
components = deduce_components_from_args(args, cluster_details)

logger.debug("components is '%s'", components)

nodes = deduce_nodes_from_args(args, walle_provider)

func(components, nodes, cluster_details, walle_provider)


def dispatch_run(func, args, walle_provider):
logger.debug("run func '%s' with cmd args is '%s'", func.__name__, args)

Expand Down Expand Up @@ -584,17 +571,6 @@ def dispatch_run(func, args, walle_provider):
shutil.rmtree(temp_dir)


def dispatch_run_raw_cfg(func, args, walle_provider):
logger.debug("run func '%s' with cmd args is '%s'", func.__name__, args)

cluster_details = safe_load_cluster_details(args.cluster, walle_provider)
components = deduce_components_from_args(args, cluster_details)

nodes = deduce_nodes_from_args(args, walle_provider)

func(components, nodes, cluster_details, args.raw_cfg)


def add_install_mode(modes, walle_provider):
def _run(args):
dispatch_run(handlers.slice_install, args, walle_provider)
Expand Down Expand Up @@ -626,7 +602,7 @@ def _run(args):

def add_update_raw_configs(modes, walle_provider):
def _run(args):
dispatch_run_raw_cfg(handlers.slice_update_raw_configs, args, walle_provider)
dispatch_run(handlers.slice_update_raw_configs, args, walle_provider)

mode = modes.add_parser(
"update-raw-cfg",
Expand All @@ -645,7 +621,7 @@ def _run(args):

def add_stop_mode(modes, walle_provider):
def _run(args):
dispatch_run_light(handlers.slice_stop, args, walle_provider)
dispatch_run(handlers.slice_stop, args, walle_provider)

mode = modes.add_parser(
"stop",
Expand All @@ -659,7 +635,7 @@ def _run(args):

def add_start_mode(modes, walle_provider):
def _run(args):
dispatch_run_light(handlers.slice_start, args, walle_provider)
dispatch_run(handlers.slice_start, args, walle_provider)

mode = modes.add_parser(
"start",
Expand All @@ -674,7 +650,7 @@ def _run(args):

def add_clear_mode(modes, walle_provider):
def _run(args):
dispatch_run_light(handlers.slice_clear, args, walle_provider)
dispatch_run(handlers.slice_clear, args, walle_provider)

mode = modes.add_parser(
"clear",
Expand All @@ -688,7 +664,7 @@ def _run(args):

def add_format_mode(modes, walle_provider):
def _run(args):
dispatch_run_light(handlers.slice_format, args, walle_provider)
dispatch_run(handlers.slice_format, args, walle_provider)

mode = modes.add_parser(
"format",
Expand Down
28 changes: 14 additions & 14 deletions ydb/tools/ydbd_slice/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ def _clear_logs(nodes):
nodes.execute_async(cmd)


def slice_format(components, nodes, cluster_details, walle_provider):
slice_stop(components, nodes, cluster_details), walle_provider
def slice_format(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider):
slice_stop(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider)
format_drivers(nodes)
slice_start(components, nodes, cluster_details, walle_provider)
slice_start(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider)


def slice_clear(components, nodes, cluster_details, walle_provider):
slice_stop(components, nodes, cluster_details, walle_provider)
def slice_clear(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider):
slice_stop(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider)

if 'dynamic_slots' in components:
for slot in cluster_details.dynamic_slots.values():
Expand Down Expand Up @@ -102,7 +102,7 @@ def _dynamic_configure(configurations):

def slice_install(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider):
_ensure_berkanavt_exists(nodes)
slice_stop(components, nodes, cluster_details, walle_provider)
slice_stop(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider)

if 'dynamic_slots' in components or 'kikimr' in components:
_stop_all_slots(nodes)
Expand Down Expand Up @@ -306,7 +306,7 @@ def get_numa_nodes(nodes):
logger.warning('{count} unused slots'.format(count=all_available_slots_count - len(slots_taken)))


def slice_start(components, nodes, cluster_details, walle_provider):
def slice_start(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider):
if 'kikimr' in components:
_start_static(nodes)

Expand Down Expand Up @@ -351,7 +351,7 @@ def _stop_dynamic(components, nodes, cluster_details):
nodes._check_async_execution(tasks, False)


def slice_stop(components, nodes, cluster_details, walle_provider):
def slice_stop(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider):
_stop_dynamic(components, nodes, cluster_details)

if 'kikimr' in components:
Expand Down Expand Up @@ -414,22 +414,22 @@ def slice_update(components, nodes, cluster_details, configurator, do_clear_logs
if 'bin' in components.get('kikimr', []):
_update_kikimr(nodes, configurator.kikimr_bin, configurator.kikimr_compressed_bin)

slice_stop(components, nodes, cluster_details, walle_provider)
slice_stop(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider)
if 'kikimr' in components:
if 'cfg' in components.get('kikimr', []):
static = configurator.create_static_cfg()
_update_cfg(nodes, static)
_deploy_secrets(nodes, args.yav_version)

_deploy_slot_configs(components, nodes, cluster_details, walle_provider)
slice_start(components, nodes, cluster_details, walle_provider)
slice_start(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider)


def slice_update_raw_configs(components, nodes, cluster_details, config_path, walle_provider):
slice_stop(components, nodes, cluster_details, walle_provider)
def slice_update_raw_configs(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider):
slice_stop(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider)
if 'kikimr' in components:
if 'cfg' in components.get('kikimr', []):
kikimr_cfg = os.path.join(config_path, 'kikimr-static')
kikimr_cfg = os.path.join(args.raw_cfg.config_path, 'kikimr-static')
_update_cfg(nodes, kikimr_cfg)

slice_start(components, nodes, cluster_details, walle_provider)
slice_start(components, nodes, cluster_details, configurator, do_clear_logs, args, walle_provider)

0 comments on commit e85d4d6

Please sign in to comment.