From d25d7b54a919e439c968b332c4357e3f8124ea0d Mon Sep 17 00:00:00 2001 From: rakeshgm Date: Wed, 13 May 2020 20:21:40 +0530 Subject: [PATCH] fixes for redhat internal tasks Signed-off-by: rakeshgm --- teuthology/run.py | 11 +++++++++++ teuthology/task/internal/__init__.py | 2 ++ teuthology/task/internal/git_ignore_ssl.py | 22 ++++++++++++++++++++++ teuthology/task/internal/redhat.py | 6 +++--- 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 teuthology/task/internal/git_ignore_ssl.py diff --git a/teuthology/run.py b/teuthology/run.py index 8c59396b0e..3476b8069d 100644 --- a/teuthology/run.py +++ b/teuthology/run.py @@ -220,11 +220,21 @@ def get_initial_tasks(lock, config, machine_type): ]) init_tasks.append({'internal.timer': None}) + # install_latest_rh_kernel is used for redhat config + if 'redhat' not in config: + if 'kernel' in config: + init_tasks.append({'kernel': config['kernel']}) + if 'roles' in config: init_tasks.extend([ {'pcp': None}, {'selinux': None}, ]) + + if 'redhat' in config: + init_tasks.extend([ + {'internal.setup_stage_cdn': None}]) + if config.get('ceph_cm_ansible', True): init_tasks.append({'ansible.cephlab': None}) @@ -234,6 +244,7 @@ def get_initial_tasks(lock, config, machine_type): if 'redhat' in config: init_tasks.extend([ + {'internal.git_ignore_ssl': None}, {'internal.setup_cdn_repo': None}, {'internal.setup_base_repo': None}, {'internal.setup_additional_repo': None}, diff --git a/teuthology/task/internal/__init__.py b/teuthology/task/internal/__init__.py index 2c758bf08e..3b552127d2 100644 --- a/teuthology/task/internal/__init__.py +++ b/teuthology/task/internal/__init__.py @@ -19,6 +19,8 @@ from teuthology.config import config as teuth_config from teuthology.exceptions import VersionNotFoundError from teuthology.job_status import get_status, set_status from teuthology.orchestra import cluster, remote, run +# the below import with noqa is to workaround run.py which does not support multilevel submodule import +from teuthology.task.internal.redhat import setup_cdn_repo, setup_base_repo, setup_additional_repo, setup_stage_cdn # noqa log = logging.getLogger(__name__) diff --git a/teuthology/task/internal/git_ignore_ssl.py b/teuthology/task/internal/git_ignore_ssl.py new file mode 100644 index 0000000000..b7bfa3ade2 --- /dev/null +++ b/teuthology/task/internal/git_ignore_ssl.py @@ -0,0 +1,22 @@ +import contextlib +import logging + +from teuthology.orchestra import run + +log = logging.getLogger(__name__) + + +@contextlib.contextmanager +def git_ignore_ssl(ctx, config): + """ + Ignore ssl error's while cloning from untrusted http + """ + + log.info("ignoring ssl errors while cloning http repo") + ctx.cluster.run( + args=[ + 'sudo', 'git', 'config', run.Raw('--system'), + 'http.sslverify', 'false' + ], + ) + yield diff --git a/teuthology/task/internal/redhat.py b/teuthology/task/internal/redhat.py index 99929110d9..6310074d53 100644 --- a/teuthology/task/internal/redhat.py +++ b/teuthology/task/internal/redhat.py @@ -24,7 +24,7 @@ def setup_stage_cdn(ctx, config): raise ConfigError("Provide rhbuild attribute") teuthconfig.rhbuild = str(rhbuild) with parallel() as p: - for remote in ctx.cluster.remotes.iterkeys(): + for remote in ctx.cluster.remotes.keys(): if remote.os.name == 'rhel': log.info("subscribing stage cdn on : %s", remote.shortname) p.spawn(_subscribe_stage_cdn, remote) @@ -32,7 +32,7 @@ def setup_stage_cdn(ctx, config): yield finally: with parallel() as p: - for remote in ctx.cluster.remotes.iterkeys(): + for remote in ctx.cluster.remotes.keys(): p.spawn(_unsubscribe_stage_cdn, remote) @@ -187,7 +187,7 @@ def _setup_latest_repo(ctx, config): # create base repo if base_url.startswith('http'): repo_to_use = _get_repos_to_use(base_url, repos) - base_repo_file = NamedTemporaryFile(delete=False) + base_repo_file = NamedTemporaryFile(mode='w', delete=False) _create_temp_repo_file(repo_to_use, base_repo_file) remote.put_file(base_repo_file.name, base_repo_file.name) remote.run(args=['sudo', 'cp', base_repo_file.name, -- 2.39.5