Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Commit

Permalink
Bug 976752: Handle case where master doesn't exist in production-mast…
Browse files Browse the repository at this point in the history
…ers.json r=dustin
  • Loading branch information
Chris AtLee committed Feb 25, 2014
1 parent 1ebc6b7 commit 0239281
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions buildapi/lib/helpers.py
Expand Up @@ -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:
Expand All @@ -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,
Expand Down Expand Up @@ -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']

Expand All @@ -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()

Expand Down
8 changes: 6 additions & 2 deletions buildapi/templates/running.mako
Expand Up @@ -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>
Expand Down

0 comments on commit 0239281

Please sign in to comment.