]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
suite: Do not send emails with --dry-run at schedule_fail
authorVallari Agrawal <val.agl002@gmail.com>
Mon, 11 Jul 2022 12:55:46 +0000 (18:25 +0530)
committerVallari Agrawal <val.agl002@gmail.com>
Tue, 12 Jul 2022 12:24:43 +0000 (17:54 +0530)
Signed-off-by: Vallari Agrawal <val.agl002@gmail.com>
teuthology/suite/__init__.py
teuthology/suite/run.py
teuthology/suite/util.py

index b7f0466649d4e18057f3e8794b9c720d616a7d70..45aa799c160e86e19dbc74a78c3ccdfe1ea778e3 100644 (file)
@@ -109,14 +109,15 @@ def main(args):
     if conf.verbose:
         teuthology.log.setLevel(logging.DEBUG)
 
+    dry_run = conf.dry_run or None
     if not conf.machine_type or conf.machine_type == 'None':
         if not config.default_machine_type or config.default_machine_type == 'None':
-            schedule_fail("Must specify a machine_type")
+            schedule_fail("Must specify a machine_type", dry_run=dry_run)
         else:
            conf.machine_type = config.default_machine_type
     elif 'multi' in conf.machine_type:
         schedule_fail("'multi' is not a valid machine_type. " +
-                      "Maybe you want 'gibba,smithi,mira' or similar")
+                      "Maybe you want 'gibba,smithi,mira' or similar", dry_run=dry_run)
 
     if conf.email:
         config.results_email = conf.email
index 7ae4a37646f8841f6d21c6ddb92aa89d792d2349..aeeabe596364e56f0ed38b36e64a0a193def8656 100644 (file)
@@ -100,7 +100,7 @@ class Run(object):
             self.suite_repo_path = self.args.suite_dir
         else:
             self.suite_repo_path = util.fetch_repos(
-                suite_branch, test_name=self.name)
+                suite_branch, test_name=self.name, dry_run=self.args.dry_run)
         teuthology_branch, teuthology_sha1 = self.choose_teuthology_branch()
 
 
@@ -144,7 +144,8 @@ class Run(object):
             if not kernel_hash:
                 util.schedule_fail(
                     "Kernel branch '{branch}' not found".format(
-                     branch=self.args.kernel_branch)
+                     branch=self.args.kernel_branch),
+                     dry_run=self.args.dry_run,
                 )
         if kernel_hash:
             log.info("kernel sha1: {hash}".format(hash=kernel_hash))
@@ -172,7 +173,7 @@ class Run(object):
                     self.args.ceph_sha1,
                     '%s.git' % repo_name
                 )
-                util.schedule_fail(message=str(exc), name=self.name)
+                util.schedule_fail(message=str(exc), name=self.name, dry_run=self.args.dry_run)
             log.info("ceph sha1 explicitly supplied")
 
         elif self.args.ceph_branch:
@@ -183,7 +184,7 @@ class Run(object):
                     self.args.ceph_branch,
                     '%s.git' % repo_name
                 )
-                util.schedule_fail(message=str(exc), name=self.name)
+                util.schedule_fail(message=str(exc), name=self.name, dry_run=self.args.dry_run)
 
         log.info("ceph sha1: {hash}".format(hash=ceph_hash))
         return ceph_hash
@@ -198,7 +199,7 @@ class Run(object):
                     self.args.distro_version, self.args.machine_type,
                 )
             except Exception as exc:
-                util.schedule_fail(str(exc), self.name)
+                util.schedule_fail(str(exc), self.name, dry_run=self.args.dry_run)
             log.info("ceph version: {ver}".format(ver=ceph_version))
             return ceph_version
         else:
@@ -268,7 +269,7 @@ class Run(object):
             )
         if not teuthology_sha1:
             exc = BranchNotFoundError(teuthology_branch, build_git_url('teuthology'))
-            util.schedule_fail(message=str(exc), name=self.name)
+            util.schedule_fail(message=str(exc), name=self.name, dry_run=self.args.dry_run)
         log.info("teuthology branch: %s %s", teuthology_branch, teuthology_sha1)
         return teuthology_branch, teuthology_sha1
 
@@ -301,7 +302,7 @@ class Run(object):
                 suite_branch
             ):
                 exc = BranchNotFoundError(suite_branch, suite_repo_name)
-                util.schedule_fail(message=str(exc), name=self.name)
+                util.schedule_fail(message=str(exc), name=self.name, dry_run=self.args.dry_run)
         elif not suite_branch:
             # Decide what branch of the suite repo to use
             if util.git_branch_exists(suite_repo_project_or_url, ceph_branch):
@@ -325,7 +326,7 @@ class Run(object):
         )
         if not suite_hash:
             exc = BranchNotFoundError(suite_branch, suite_repo_name)
-            util.schedule_fail(message=str(exc), name=self.name)
+            util.schedule_fail(message=str(exc), name=self.name, dry_run=self.args.dry_run)
         log.info("%s branch: %s %s", suite_repo_name, suite_branch, suite_hash)
         return suite_hash
 
@@ -513,6 +514,7 @@ class Run(object):
                         "At least one job needs packages that don't exist for "
                         "hash {sha1}.".format(sha1=self.base_config.sha1),
                         name,
+                        dry_run=self.args.dry_run,
                     )
             util.teuthology_schedule(
                 args=job['args'],
@@ -538,11 +540,11 @@ Use the following testing priority
 200 to 1000: Large test runs that can be done over the course of a week.
 Note: To force run, use --force-priority'''
         if priority < 50:
-            util.schedule_fail(msg)
+            util.schedule_fail(msg, dry_run=self.args.dry_run)
         elif priority < 75 and jobs_to_schedule > 25:
-            util.schedule_fail(msg)
+            util.schedule_fail(msg, dry_run=self.args.dry_run)
         elif priority < 150 and jobs_to_schedule > 100:
-            util.schedule_fail(msg)
+            util.schedule_fail(msg, dry_run=self.args.dry_run)
 
     def check_num_jobs(self, jobs_to_schedule):
         """
@@ -553,7 +555,7 @@ Note: To force run, use --force-priority'''
 
 Note: If you still want to go ahead, use --job-threshold 0'''
         if threshold and jobs_to_schedule > threshold:
-            util.schedule_fail(msg)
+            util.schedule_fail(msg, dry_run=self.args.dry_run)
 
     def schedule_suite(self):
         """
@@ -659,6 +661,7 @@ Note: If you still want to go ahead, use --job-threshold 0'''
                 util.schedule_fail(
                     'Exceeded %d backtracks; raise --newest value' % limit,
                     name,
+                    dry_run=self.args.dry_run,
                 )
 
         if self.args.dry_run:
index 67ac32410945016174f6e6c364aaedb429458c4e..9b4cade7bfbe782965293d345bd34914153a093a 100644 (file)
@@ -29,7 +29,7 @@ CONTAINER_DISTRO = 'centos/8'       # the one to check for build_complete
 CONTAINER_FLAVOR = 'default'
 
 
-def fetch_repos(branch, test_name):
+def fetch_repos(branch, test_name, dry_run):
     """
     Fetch the suite repo (and also the teuthology repo) so that we can use it
     to build jobs. Repos are stored in ~/src/.
@@ -51,17 +51,18 @@ def fetch_repos(branch, test_name):
                 fetch_teuthology('main')
         suite_repo_path = fetch_qa_suite(branch)
     except BranchNotFoundError as exc:
-        schedule_fail(message=str(exc), name=test_name)
+        schedule_fail(message=str(exc), name=test_name, dry_run=dry_run)
     return suite_repo_path
 
 
-def schedule_fail(message, name=''):
+def schedule_fail(message, name='', dry_run=None):
     """
     If an email address has been specified anywhere, send an alert there. Then
     raise a ScheduleFailError.
+    Don't send the mail if --dry-run has been passed.
     """
     email = config.results_email
-    if email:
+    if email and not dry_run:
         subject = "Failed to schedule {name}".format(name=name)
         msg = MIMEText(message)
         msg['Subject'] = subject