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

[RFC] teuthology: add email headers for suite/user #1925

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 9 additions & 7 deletions teuthology/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,24 @@ 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
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