]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
worker, run: use exact commits for teuthology and qa suite 1599/head
authorJosh Durgin <jdurgin@redhat.com>
Sun, 17 Jan 2021 02:31:33 +0000 (21:31 -0500)
committerJosh Durgin <jdurgin@redhat.com>
Tue, 19 Jan 2021 06:47:37 +0000 (01:47 -0500)
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 <jdurgin@redhat.com>
teuthology/run.py
teuthology/test/test_run.py
teuthology/worker.py

index 0bae936d653e37e9d445a9df86273b0b708d4310..2eb0429fc9955b81343dc0fc68cb8a5bf9636522 100644 (file)
@@ -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)
index 5a7b073ad84624ec21646012bbe8252061420b22..f08082f58c67ec6f21fb7f9980f6013b11ab0a12 100644 (file)
@@ -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")
index e7c1eb6ef7a8114c32fded41324f0fec8627de79..317745d7a2c710396910bcc32c82fba0562f57c4 100644 (file)
@@ -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: