Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suite: Do not send emails with --dry-run at schedule_fail #1778

Merged
merged 2 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions teuthology/suite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 15 additions & 12 deletions teuthology/suite/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def create_initial_config(self):
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()


Expand Down Expand Up @@ -144,7 +144,8 @@ def choose_kernel(self):
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))
Expand Down Expand Up @@ -172,7 +173,7 @@ def choose_ceph_hash(self):
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:
Expand All @@ -183,7 +184,7 @@ def choose_ceph_hash(self):
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
Expand All @@ -198,7 +199,7 @@ def choose_ceph_version(self, ceph_hash):
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:
Expand Down Expand Up @@ -268,7 +269,7 @@ def choose_teuthology_branch(self):
)
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

Expand Down Expand Up @@ -301,7 +302,7 @@ def choose_suite_branch(self):
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):
Expand All @@ -325,7 +326,7 @@ def choose_suite_hash(self, suite_branch):
)
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

Expand Down Expand Up @@ -513,6 +514,7 @@ def schedule_jobs(self, jobs_missing_packages, jobs_to_schedule, name):
"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'],
Expand All @@ -538,11 +540,11 @@ def check_priority(self, jobs_to_schedule):
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):
"""
Expand All @@ -553,7 +555,7 @@ def check_num_jobs(self, jobs_to_schedule):

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):
"""
Expand Down Expand Up @@ -659,6 +661,7 @@ def schedule_suite(self):
util.schedule_fail(
'Exceeded %d backtracks; raise --newest value' % limit,
name,
dry_run=self.args.dry_run,
)

if self.args.dry_run:
Expand Down
9 changes: 5 additions & 4 deletions teuthology/suite/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
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/.
Expand All @@ -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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add a unit test in teuthology/suite/test/test_util.py, for testing different scenarios of schedule failures.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, working on it! 👍

"""
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
Expand Down