From 472fa5150296f7608f8f8b9c27eef233f0155b62 Mon Sep 17 00:00:00 2001 From: Shraddha Agrawal Date: Wed, 26 Aug 2020 01:44:05 +0530 Subject: [PATCH] minor fix Signed-off-by: Shraddha Agrawal --- scripts/dispatcher.py | 2 +- teuthology/dispatcher/supervisor.py | 8 ++++---- teuthology/lock/ops.py | 26 ++++++++++---------------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/scripts/dispatcher.py b/scripts/dispatcher.py index 5c65d8a401..7c75f38b7c 100644 --- a/scripts/dispatcher.py +++ b/scripts/dispatcher.py @@ -17,7 +17,7 @@ standard arguments: -v, --verbose be more verbose -t, --tube TUBE which beanstalk tube to read jobs from -l, --log-dir LOG_DIR path in which to store logs - -a DIR, --archive-dir DIR path to archive results in + -a DIR, --archive-dir DIR path to archive results in --supervisor run dispatcher in job supervisor mode --bin-path BIN_PATH teuthology bin path --job-config CONFIG file descriptor of job's config file diff --git a/teuthology/dispatcher/supervisor.py b/teuthology/dispatcher/supervisor.py index bc58e2788d..28d03686d0 100644 --- a/teuthology/dispatcher/supervisor.py +++ b/teuthology/dispatcher/supervisor.py @@ -12,7 +12,7 @@ from teuthology import safepath from teuthology.config import config as teuth_config from teuthology.exceptions import SkipJob from teuthology import setup_log_file, install_except_hook -from teuthology.lock.ops import reimage_many +from teuthology.lock.ops import reimage_machines from teuthology.misc import get_user, archive_logs, compress_logs from teuthology.config import FakeNamespace from teuthology.job_status import get_status @@ -47,7 +47,7 @@ def main(args): # reimage target machines before running the job if 'targets' in job_config: - reimage_machines(job_config) + reimage(job_config) with open(config_file_path, 'w') as f: yaml.safe_dump(job_config, f, default_flow_style=False) @@ -152,7 +152,7 @@ def run_job(job_config, teuth_bin_path, archive_dir, verbose): unlock_targets(job_config) -def reimage_machines(job_config): +def reimage(job_config): # Reimage the targets specified in job config # and update their keys in config after reimaging ctx = create_fake_context(job_config) @@ -160,7 +160,7 @@ def reimage_machines(job_config): report.try_push_job_info(ctx.config, dict(status='waiting')) targets = job_config['targets'] try: - reimaged = reimage_many(ctx, targets, job_config['machine_type']) + reimaged = reimage_machines(ctx, targets, job_config['machine_type']) except Exception: log.info('Reimaging error. Nuking machines...') # Reimage failures should map to the 'dead' status instead of 'fail' diff --git a/teuthology/lock/ops.py b/teuthology/lock/ops.py index 8f625af824..2becfbff2a 100644 --- a/teuthology/lock/ops.py +++ b/teuthology/lock/ops.py @@ -133,7 +133,7 @@ def lock_many(ctx, num, machine_type, user=None, description=None, update_nodes(ok_machs) return ok_machs elif reimage and machine_type in reimage_types: - return reimage_many(ctx, machines, machine_type) + return reimage_machines(ctx, machines, machine_type) return machines elif response.status_code == 503: log.error('Insufficient nodes available to lock %d %s nodes.', @@ -287,20 +287,7 @@ def push_new_keys(keys_dict, reference): return ret -def reimage(ctx, machines, machine_type): - reimaged = dict() - with teuthology.parallel.parallel() as p: - for machine in machines: - log.info("Start node '%s' reimaging", machine) - update_nodes([machine], True) - p.spawn(teuthology.provision.reimage, ctx, - machine, machine_type) - reimaged[machine] = machines[machine] - log.info("Node '%s' reimaging is complete", machine) - return reimaged - - -def reimage_many(ctx, machines, machine_type): +def reimage_machines(ctx, machines, machine_type): # Setup log file, reimage machines and update their keys reimaged = dict() console_log_conf = dict( @@ -309,7 +296,14 @@ def reimage_many(ctx, machines, machine_type): for machine in machines], ) with console_log.task(ctx, console_log_conf): - reimaged = reimage(ctx, machines, machine_type) + with teuthology.parallel.parallel() as p: + for machine in machines: + log.info("Start node '%s' reimaging", machine) + update_nodes([machine], True) + p.spawn(teuthology.provision.reimage, ctx, + machine, machine_type) + reimaged[machine] = machines[machine] + log.info("Node '%s' reimaging is complete", machine) reimaged = do_update_keys(list(reimaged.keys()))[1] update_nodes(reimaged) return reimaged -- 2.39.5