From f0da4c81cff40edc62f295a8b9017d12f12d51f1 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Mon, 11 Mar 2024 12:37:23 -0400 Subject: [PATCH] teuthology: add email headers for suite/user For advanced filtering/organization. Fixes: https://tracker.ceph.com/issues/64839 Signed-off-by: Patrick Donnelly --- teuthology/results.py | 16 +++++++++------- teuthology/run.py | 5 ++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/teuthology/results.py b/teuthology/results.py index aae991eaf1..b72695e51d 100644 --- a/teuthology/results.py +++ b/teuthology/results.py @@ -75,15 +75,11 @@ 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 @@ -91,6 +87,12 @@ def email_results(subject, from_, to, 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()) diff --git a/teuthology/run.py b/teuthology/run.py index e065495cff..2e97956df7 100644 --- a/teuthology/run.py +++ b/teuthology/run.py @@ -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)