Skip to content

Commit ffb950b

Browse files
adrpoclaude
andauthored
Keep reports off asap-remote, survive mail errors (#416) (#417)
The report stages ran on asap-remote, which has been moved. Its publish-reports.py could not reach smtp.office365.com, and the OSError failed the stage before the overviews were built. Run the report stages on linux && !asap-remote. Catch OSError and SMTPException around the SMTP session: print the emails left unsent (the reports are recorded, so a rerun would not send them), exit with 2 and let the Jenkinsfile mark the build unstable, so the overviews are still built. Give the connection a 60 s timeout. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1c9738a commit ffb950b

2 files changed

Lines changed: 44 additions & 14 deletions

File tree

‎.CI/Jenkinsfile‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ pipeline {
498498
stage('report') {
499499
agent {
500500
dockerfile {
501-
label 'linux'
501+
label 'linux && !asap-remote'
502502
dir '.CI/build-dep'
503503
customWorkspace 'ws/OpenModelicaLibraryTestingReport'
504504
args '-e IDA_EMAIL_USR=$IDA_EMAIL_USR -e IDA_EMAIL_PSW=$IDA_EMAIL_PSW'
@@ -546,7 +546,17 @@ pipeline {
546546
// knows about is never generated again, so one that a later failure in
547547
// this stage stops from being uploaded would be lost for good.
548548
sshPublisher(publishers: [sshPublisherDesc(configName: 'LibraryTestingReports', transfers: [sshTransfer(sourceFiles: 'history/**')])])
549-
sh './publish-reports.py'
549+
// Exit code 2: the reports are recorded but the mail server could not be
550+
// reached. The log lists the emails left unsent; the overviews below are
551+
// still built, so the build is only marked unstable.
552+
script {
553+
def status = sh(script: './publish-reports.py', returnStatus: true)
554+
if (status == 2) {
555+
unstable('publish-reports.py could not send the regression emails, see the log for the ones left unsent')
556+
} else if (status != 0) {
557+
error("publish-reports.py failed with exit code ${status}")
558+
}
559+
}
550560

551561
sh "./report.py --branches='${env.GITBRANCHES} ${env.GITBRANCHES_WASM_JIT}' configs/conf.json configs/conf-old.json configs/conf-nonstandard.json"
552562
sh 'mv overview.html overview-combined.html'
@@ -628,7 +638,7 @@ pipeline {
628638
stage('drop stale pull request tables') {
629639
agent {
630640
dockerfile {
631-
label 'linux'
641+
label 'linux && !asap-remote'
632642
dir '.CI/build-dep'
633643
customWorkspace 'ws/OpenModelicaLibraryTestingReport'
634644
}
@@ -652,7 +662,7 @@ pipeline {
652662
stage('pull request report') {
653663
agent {
654664
dockerfile {
655-
label 'linux'
665+
label 'linux && !asap-remote'
656666
dir '.CI/build-dep'
657667
customWorkspace 'ws/OpenModelicaLibraryTestingReport'
658668
}

‎publish-reports.py‎

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
pending = json.load(fin)
3131

3232
entries = pending.get("entries", {})
33+
unsent = []
3334
emails = pending.get("emails", {})
3435

3536
db = resultsdb.connect(args.db)
@@ -51,7 +52,8 @@
5152
missing_html = ("%s %s %s" % ("<p style=\"color:red;\">", missing_plain, "</p"))
5253

5354
sent = 0
54-
for email in sorted(emails.keys()):
55+
recipients = sorted(emails.keys())
56+
for i, email in enumerate(recipients):
5557
msg = EmailMessage()
5658
msg['Subject'] = 'OpenModelica Library Testing Regressions'
5759
msg['From'] = Address("OM Hudson", "openmodelicabuilds", "ida.liu.se")
@@ -70,17 +72,35 @@
7072
</body>
7173
</html>
7274
""" % (missing_html, "\n".join(reversed(emails[email]["html"]))), subtype='html')
73-
with smtplib.SMTP('smtp.office365.com') as s:
74-
s.starttls()
75-
s.ehlo()
76-
s.login(os.environ["IDA_EMAIL_USR"],os.environ["IDA_EMAIL_PSW"])
77-
try:
78-
s.send_message(msg)
79-
except smtplib.SMTPRecipientsRefused as e:
80-
print("Skipping refused address %s: %s" % (email, e.recipients))
81-
continue
75+
try:
76+
with smtplib.SMTP('smtp.office365.com', timeout=60) as s:
77+
s.starttls()
78+
s.ehlo()
79+
s.login(os.environ["IDA_EMAIL_USR"],os.environ["IDA_EMAIL_PSW"])
80+
try:
81+
s.send_message(msg)
82+
except smtplib.SMTPRecipientsRefused as e:
83+
print("Skipping refused address %s: %s" % (email, e.recipients))
84+
continue
85+
except (OSError, smtplib.SMTPException) as e:
86+
# The rows are in the [history] table already, so a rerun would not mail
87+
# these regressions again: the log is the only place they are left in.
88+
# The mail server is not reachable for the rest of them either, and the
89+
# overviews this stage builds next must not be lost over it.
90+
unsent = recipients[i:]
91+
print("Could not send the emails, %s: %s" % (type(e).__name__, e))
92+
print("Not sent, %d of %d emails:" % (len(unsent), len(emails)))
93+
for address in unsent:
94+
print(" %s:" % address)
95+
for line in reversed(emails[address]["plain"]):
96+
print(" %s" % line)
97+
break
8298
sent += 1
8399
print("Sent %d of %d emails" % (sent, len(emails)))
84100

85101
if not args.keep:
86102
os.remove(args.pending)
103+
104+
if unsent:
105+
# Tells the Jenkinsfile to mark the build unstable and go on.
106+
sys.exit(2)

0 commit comments

Comments
 (0)