Skip to content

Commit

Permalink
teuthology: add email headers for suite/user
Browse files Browse the repository at this point in the history
For advanced filtering/organization.

Fixes: https://tracker.ceph.com/issues/64839
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
  • Loading branch information
batrick committed Mar 11, 2024
1 parent e691533 commit 92dc90d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
19 changes: 12 additions & 7 deletions teuthology/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,27 @@ def results(archive_dir, name, email, timeout, dry_run):
print("Subject: %s" % subject)
print(body)
elif email:
email_results(
subject=subject,
from_=(config.results_sending_email or 'teuthology'),
to=email,
body=body,
)
sender = config.results_sending_email or 'teuthology')
email_results(config, subject, sender, to, body)


def email_results(subject, from_, to, body):
def email_results(config, subject, from_, to, body):
log.info('Sending results to {to}: {body}'.format(to=to, body=body))
import smtplib
from email.mime.text import MIMEText
msg = MIMEText(body)
msg['Subject'] = subject
msg['From'] = from_
msg['To'] = to
suite = config.get('suite')
if suite is not None:
msg['QA-suite'] = suite
suite = config.get('suite')
if suite is not None:
msg['QA-suite'] = suite
user = config.get('user')
if user is not None:
msg['QA-user'] = user
log.debug('sending email %s', msg.as_string())
smtp = smtplib.SMTP('localhost')
smtp.sendmail(msg['From'], [msg['To']], msg.as_string())
Expand Down
5 changes: 2 additions & 3 deletions teuthology/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,8 @@ def report_outcome(config, archive, summary, fake_ctx):
and not passed):
config_dump = yaml.safe_dump(config)
subject = "Teuthology error -- %s" % summary['failure_reason']
email_results(subject, "Teuthology", config['email-on-error'],
"\n".join([summary_dump, config_dump]))

body = "\n".join([summary_dump, config_dump])
email_results(config, subject, "Teuthology", body)

report.try_push_job_info(config, summary)

Expand Down

0 comments on commit 92dc90d

Please sign in to comment.