llvmbot monitor: Handle missing complete_at field
For some reason just now we were getting a successful build
without a completed time. That's fixed itself now but I might as
well add the code I wrote to handle it anyway.
Probably a glitch on Buildbot's side.
Change-Id: I049da16cf126865ce7d054eca8677da10a3377dc
diff --git a/monitor/bot-status.py b/monitor/bot-status.py
index a030d3e..6e37def 100755
--- a/monitor/bot-status.py
+++ b/monitor/bot-status.py
@@ -110,10 +110,12 @@
status["first_fail_url"] = "{}/builds/{}".format(
agent_url, first_fail["number"]
)
- fail_since = int(datetime.now().timestamp()) - int(
- first_fail["complete_at"]
- )
- status["fail_since"] = timedelta(seconds=fail_since)
+ # Occasionaly we find a finished build without complete_at,
+ # it may be an intermitent issue on Buildbot's side.
+ complete_at = first_fail.get("complete_at")
+ if complete_at is not None:
+ fail_since = int(datetime.now().timestamp()) - int(complete_at)
+ status["fail_since"] = timedelta(seconds=fail_since)
break
first_fail = build
else: