From 85a266b247ffaf1cf8969868f923ea32af02c78b Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Sat, 16 Jan 2021 21:31:33 -0500 Subject: [PATCH] worker, run: use exact commits for teuthology and qa suite This ensures we use the same version across all jobs in a run. We already have suite_sha1 set by older versions of teuthology, but for folks who haven't updated their suite command, and thus don't set teuthology_sha1 in the job config, look up the sha1 of in the worker. Signed-off-by: Josh Durgin --- teuthology/run.py | 3 ++- teuthology/test/test_run.py | 5 +++-- teuthology/worker.py | 21 ++++++++++++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/teuthology/run.py b/teuthology/run.py index 0bae936d65..2eb0429fc9 100644 --- a/teuthology/run.py +++ b/teuthology/run.py @@ -85,8 +85,9 @@ def fetch_tasks_if_needed(job_config): if suite_repo: teuth_config.ceph_qa_suite_git_url = suite_repo suite_branch = job_config.get('suite_branch', ceph_branch) + suite_sha1 = job_config.get('suite_sha1') suite_path = os.path.normpath(os.path.join( - fetch_qa_suite(suite_branch), + fetch_qa_suite(suite_branch, commit=suite_sha1), job_config.get('suite_relpath', ''), )) sys.path.insert(1, suite_path) diff --git a/teuthology/test/test_run.py b/teuthology/test/test_run.py index 5a7b073ad8..f08082f58c 100644 --- a/teuthology/test/test_run.py +++ b/teuthology/test/test_run.py @@ -110,10 +110,11 @@ class TestRun(object): @patch("teuthology.run.fetch_qa_suite") def test_fetch_tasks_if_needed(self, m_fetch_qa_suite): - config = {"suite_path": "/some/suite/path", "suite_branch": "feature_branch"} + config = {"suite_path": "/some/suite/path", "suite_branch": "feature_branch", + "suite_sha1": "commit"} m_fetch_qa_suite.return_value = "/some/other/suite/path" result = run.fetch_tasks_if_needed(config) - m_fetch_qa_suite.assert_called_with("feature_branch") + m_fetch_qa_suite.assert_called_with("feature_branch", commit="commit") assert result == "/some/other/suite/path" @patch("teuthology.run.get_status") diff --git a/teuthology/worker.py b/teuthology/worker.py index e7c1eb6ef7..317745d7a2 100644 --- a/teuthology/worker.py +++ b/teuthology/worker.py @@ -16,7 +16,7 @@ from teuthology.config import config as teuth_config from teuthology.config import set_config_attr from teuthology.exceptions import BranchNotFoundError, SkipJob, MaxWhileTries from teuthology.kill import kill_job -from teuthology.repo_utils import fetch_qa_suite, fetch_teuthology +from teuthology.repo_utils import fetch_qa_suite, fetch_teuthology, ls_remote, build_git_url log = logging.getLogger(__name__) start_time = datetime.utcnow() @@ -148,22 +148,37 @@ def prep_job(job_config, log_file_path, archive_dir): # store that value. teuthology_branch = job_config.get('teuthology_branch', 'master') job_config['teuthology_branch'] = teuthology_branch + teuthology_sha1 = job_config.get('teuthology_sha1') + if not teuthology_sha1: + repo_url = build_git_url('teuthology', 'ceph') + teuthology_sha1 = ls_remote(repo_url, teuthology_branch) + if not teuthology_sha1: + reason = "Teuthology branch {} not found; marking job as dead".format(teuthology_branch) + log.error(reason) + report.try_push_job_info( + job_config, + dict(status='dead', failure_reason=reason) + ) + raise SkipJob() + log.info('Using teuthology sha1 %s', teuthology_sha1) try: if teuth_config.teuthology_path is not None: teuth_path = teuth_config.teuthology_path else: - teuth_path = fetch_teuthology(branch=teuthology_branch) + teuth_path = fetch_teuthology(branch=teuthology_branch, + commit=teuthology_sha1) # For the teuthology tasks, we look for suite_branch, and if we # don't get that, we look for branch, and fall back to 'master'. # last-in-suite jobs don't have suite_branch or branch set. ceph_branch = job_config.get('branch', 'master') suite_branch = job_config.get('suite_branch', ceph_branch) + suite_sha1 = job_config.get('suite_sha1') suite_repo = job_config.get('suite_repo') if suite_repo: teuth_config.ceph_qa_suite_git_url = suite_repo job_config['suite_path'] = os.path.normpath(os.path.join( - fetch_qa_suite(suite_branch), + fetch_qa_suite(suite_branch, suite_sha1), job_config.get('suite_relpath', ''), )) except BranchNotFoundError as exc: -- 2.39.5