]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
suite: Look for teuthology branch mismatches
authorZack Cerza <zack@redhat.com>
Thu, 21 Apr 2022 16:48:19 +0000 (10:48 -0600)
committerZack Cerza <zack@cerza.org>
Wed, 27 Apr 2022 20:51:10 +0000 (14:51 -0600)
If config.teuthology_path is set, we don't fetch teuthology at runtime.
This can lead to confusing situations if --teuthology-branch is passed
to teuthology-suite, as the job config will claim a branch is used when
it is not. We can avoid this problem by refusing to schedule if there
is a mismatch.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/suite/run.py

index f8d789e19d5fd62872841a9391368d8e064cfd5f..e680c531402fab2137cbaace452b1f0c826af142 100644 (file)
@@ -10,10 +10,12 @@ from humanfriendly import format_timespan
 
 from datetime import datetime
 from tempfile import NamedTemporaryFile
+from teuthology import repo_utils
 
 from teuthology.config import config, JobConfig
 from teuthology.exceptions import (
-    BranchNotFoundError, CommitNotFoundError, VersionNotFoundError
+    BranchMismatchError, BranchNotFoundError, CommitNotFoundError,
+    VersionNotFoundError
 )
 from teuthology.misc import deep_merge, get_results_url
 from teuthology.orchestra.opsys import OS
@@ -246,10 +248,23 @@ class Run(object):
         if not teuthology_branch:
             teuthology_branch = config.get('teuthology_branch', 'master')
 
-        teuthology_sha1 = util.git_ls_remote(
-            'teuthology',
-            teuthology_branch
-        )
+        if config.teuthology_path is None:
+            teuthology_sha1 = util.git_ls_remote(
+                'teuthology',
+                teuthology_branch
+            )
+        else:
+            actual_branch = repo_utils.current_branch(config.teuthology_path)
+            if actual_branch != teuthology_branch:
+                raise BranchMismatchError(
+                    teuthology_branch,
+                    config.teuthology_path,
+                    "config.teuthology_path is set",
+                )
+            teuthology_sha1 = util.git_ls_remote(
+                f"file://{config.teuthology_path}",
+                teuthology_branch
+            )
         if not teuthology_sha1:
             exc = BranchNotFoundError(teuthology_branch, build_git_url('teuthology'))
             util.schedule_fail(message=str(exc), name=self.name)