Permalink
Browse files

Bug 976752: Handle case where master doesn't exist in production-mast…

…ers.json r=dustin
  • Loading branch information...
catlee committed Feb 25, 2014
1 parent 1ebc6b7 commit 02392811f0e5dea17132d99fa1ab5679829f3b7a
Showing with 13 additions and 5 deletions.
  1. +7 −3 buildapi/lib/helpers.py
  2. +6 −2 buildapi/templates/running.mako
View
@@ -99,8 +99,8 @@ def __init__(self):
time_format = '%a, %d %b %Y %H:%M:%S %z (%Z)'
def pacific_time(timestamp, format=time_format):
- """Convert a time expressed in seconds since the epoch to a string
- representing Pacific time. If secs is not provided or None, the current
+ """Convert a time expressed in seconds since the epoch to a string
+ representing Pacific time. If secs is not provided or None, the current
time as returned by time() is used.
"""
if not timestamp:
@@ -110,7 +110,7 @@ def pacific_time(timestamp, format=time_format):
return dt.strftime(format)
-# Matches a master from production-masters.json, to the corresponding
+# Matches a master from production-masters.json, to the corresponding
# build pool, by looking at the 'role' field
ROLE_MASTERS_POOLS = {
'build': BUILDPOOL,
@@ -204,6 +204,8 @@ def addr_for_master(claimed_by_name):
"""Returns the fully qualified domain name and port for the master
indicated by claimed_by_name"""
get_masters()
+ if claimed_by_name not in _masters_by_dbname:
+ return None, None
fqdn = _masters_by_dbname[claimed_by_name]['hostname']
port = _masters_by_dbname[claimed_by_name]['http_port']
@@ -221,6 +223,8 @@ def convert_master(m):
* master_url, eg 'http://buildbot-master1.build.mozilla.org:8011'
"""
fqdn, port = addr_for_master(m)
+ if fqdn is None:
+ return None
pretty_name = '%s:%i' % (fqdn.split(".")[0], port)
master_url = 'http://%(fqdn)s:%(port)i' % locals()
@@ -47,8 +47,12 @@ $(document).ready(function() {
build['start_time_human'] = datetime.fromtimestamp(build['start_time']).strftime('%Y-%m-%d %H:%M:%S')
build['running_for'] = now - datetime.fromtimestamp(build['start_time'])
m = h.convert_master(build['claimed_by_name'])
- build['master'] = m['pretty_name']
- build['url'] = h.url_for_build(m['master_addr'], build['buildername'], build['number'])
+ if m:
+ build['master'] = m['pretty_name']
+ build['url'] = h.url_for_build(m['master_addr'], build['buildername'], build['number'])
+ else:
+ build['master'] = ''
+ build['url'] = '#'
%>
<tr>
<td>${branch}</td><td>${revision}</td>

0 comments on commit 0239281

Please sign in to comment.