From f6e7986f8e1aaaf1259ac7e3a8cba52265064c92 Mon Sep 17 00:00:00 2001 From: "s.makhov" Date: Wed, 31 Jul 2024 19:11:33 +0300 Subject: [PATCH] [#159] Load presets: Add optional max number of retries to create a container instead of hard-coded number 20 --- scenarios/preset/helpers/frostfs_cli.py | 6 +++--- scenarios/preset/preset_grpc.py | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scenarios/preset/helpers/frostfs_cli.py b/scenarios/preset/helpers/frostfs_cli.py index 60c88bf..73f48fa 100644 --- a/scenarios/preset/helpers/frostfs_cli.py +++ b/scenarios/preset/helpers/frostfs_cli.py @@ -1,8 +1,8 @@ import re from helpers.cmd import execute_cmd, log -def create_container(endpoint, policy, wallet_path, config, acl, local=False, depth=0): - if depth > 20: +def create_container(endpoint, policy, container_creation_retry, wallet_path, config, acl, local=False, retry=0): + if retry > int(container_creation_retry): raise ValueError(f"unable to create container: too many unsuccessful attempts") if wallet_path: @@ -88,7 +88,7 @@ def create_container(endpoint, policy, wallet_path, config, acl, local=False, de return cid log(f"Created container {cid} is not stored on {endpoint}, creating another one...", endpoint) - return create_container(endpoint, policy, wallet_path, config, acl, local, depth + 1) + return create_container(endpoint, policy, wallet_path, config, acl, local, retry + 1) def upload_object(container, payload_filepath, endpoint, wallet_file, wallet_config): diff --git a/scenarios/preset/preset_grpc.py b/scenarios/preset/preset_grpc.py index ac27abe..565e63a 100755 --- a/scenarios/preset/preset_grpc.py +++ b/scenarios/preset/preset_grpc.py @@ -20,6 +20,7 @@ DEFAULT_POLICY = "REP 2 IN X CBF 2 SELECT 2 FROM * AS X" parser = argparse.ArgumentParser() parser.add_argument('--size', help='Upload objects size in kb') parser.add_argument('--containers', help='Number of containers to create') +parser.add_argument('--retry', default=20, help='Maximum number of retries to create a container') parser.add_argument('--out', help='JSON file with output') parser.add_argument('--preload_obj', help='Number of pre-loaded objects') parser.add_argument('--wallet', help='Wallet file path') @@ -50,6 +51,7 @@ def main(): if not args.policy: args.policy = [DEFAULT_POLICY] + container_creation_retry = args.retry wallet = args.wallet wallet_config = args.config workers = int(args.workers) @@ -66,7 +68,7 @@ def main(): containers_count = int(args.containers) print(f"Create containers: {containers_count}") with ProcessPoolExecutor(max_workers=min(MAX_WORKERS, workers)) as executor: - containers_runs = [executor.submit(create_container, endpoint, policy, wallet, wallet_config, args.acl, args.local) + containers_runs = [executor.submit(create_container, endpoint, policy, container_creation_retry, wallet, wallet_config, args.acl, args.local) for _, endpoint, policy in zip(range(containers_count), cycle(endpoints), cycle(args.policy))]