[#159] preset: Add optional max number of retries to create a container instead of hard-coded number 20
Some checks failed
Tests and linters / Lint (pull_request) Failing after 26s
DCO action / DCO (pull_request) Failing after 41s
Tests and linters / Tests (1.22) (pull_request) Successful in 1m14s
Tests and linters / Tests (1.21) (pull_request) Successful in 1m20s
Tests and linters / Tests with -race (pull_request) Successful in 2m9s
Some checks failed
Tests and linters / Lint (pull_request) Failing after 26s
DCO action / DCO (pull_request) Failing after 41s
Tests and linters / Tests (1.22) (pull_request) Successful in 1m14s
Tests and linters / Tests (1.21) (pull_request) Successful in 1m20s
Tests and linters / Tests with -race (pull_request) Successful in 2m9s
This commit is contained in:
parent
9b9db46a07
commit
2aac95a230
2 changed files with 6 additions and 4 deletions
|
@ -1,8 +1,8 @@
|
||||||
import re
|
import re
|
||||||
from helpers.cmd import execute_cmd, log
|
from helpers.cmd import execute_cmd, log
|
||||||
|
|
||||||
def create_container(endpoint, policy, wallet_path, config, acl, local=False, depth=0):
|
def create_container(endpoint, policy, container_creation_retry, wallet_path, config, acl, local=False, retry=0):
|
||||||
if depth > 20:
|
if retry > int(container_creation_retry):
|
||||||
raise ValueError(f"unable to create container: too many unsuccessful attempts")
|
raise ValueError(f"unable to create container: too many unsuccessful attempts")
|
||||||
|
|
||||||
if wallet_path:
|
if wallet_path:
|
||||||
|
@ -88,7 +88,7 @@ def create_container(endpoint, policy, wallet_path, config, acl, local=False, de
|
||||||
return cid
|
return cid
|
||||||
|
|
||||||
log(f"Created container {cid} is not stored on {endpoint}, creating another one...", endpoint)
|
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):
|
def upload_object(container, payload_filepath, endpoint, wallet_file, wallet_config):
|
||||||
|
|
|
@ -20,6 +20,7 @@ DEFAULT_POLICY = "REP 2 IN X CBF 2 SELECT 2 FROM * AS X"
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--size', help='Upload objects size in kb')
|
parser.add_argument('--size', help='Upload objects size in kb')
|
||||||
parser.add_argument('--containers', help='Number of containers to create')
|
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('--out', help='JSON file with output')
|
||||||
parser.add_argument('--preload_obj', help='Number of pre-loaded objects')
|
parser.add_argument('--preload_obj', help='Number of pre-loaded objects')
|
||||||
parser.add_argument('--wallet', help='Wallet file path')
|
parser.add_argument('--wallet', help='Wallet file path')
|
||||||
|
@ -50,6 +51,7 @@ def main():
|
||||||
if not args.policy:
|
if not args.policy:
|
||||||
args.policy = [DEFAULT_POLICY]
|
args.policy = [DEFAULT_POLICY]
|
||||||
|
|
||||||
|
container_creation_retry = args.retry
|
||||||
wallet = args.wallet
|
wallet = args.wallet
|
||||||
wallet_config = args.config
|
wallet_config = args.config
|
||||||
workers = int(args.workers)
|
workers = int(args.workers)
|
||||||
|
@ -66,7 +68,7 @@ def main():
|
||||||
containers_count = int(args.containers)
|
containers_count = int(args.containers)
|
||||||
print(f"Create containers: {containers_count}")
|
print(f"Create containers: {containers_count}")
|
||||||
with ProcessPoolExecutor(max_workers=min(MAX_WORKERS, workers)) as executor:
|
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
|
for _, endpoint, policy in
|
||||||
zip(range(containers_count), cycle(endpoints), cycle(args.policy))]
|
zip(range(containers_count), cycle(endpoints), cycle(args.policy))]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue