Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:buildbot/buildbot
Browse files Browse the repository at this point in the history
  • Loading branch information
bhearsum committed Aug 26, 2010
2 parents 9b5af09 + 5a12f7d commit ae15bfd
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 13 deletions.
2 changes: 2 additions & 0 deletions master/buildbot/buildslave.py
Expand Up @@ -210,6 +210,8 @@ def attached(self, bot):
@return: a Deferred that fires when the attachment is complete
"""

self.slave_status.recordConnectTime()

if self.slave:
# uh-oh, we've got a duplicate slave. The most likely
# explanation is that the slave is behind a slow link, thinks we
Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/clients/sendchange.py
Expand Up @@ -11,13 +11,13 @@ def __init__(self, master, user=None):
self.num_changes = 0

def send(self, branch, revision, comments, files, user=None, category=None,
when=None, properties={}, repository = '', project = ''):
when=None, properties={}, repository='', project='', revlink=''):
if user is None:
user = self.user
change = {'project': project, 'repository': repository, 'who': user,
'files': files, 'comments': comments, 'branch': branch,
'revision': revision, 'category': category, 'when': when,
'properties': properties}
'properties': properties, 'revlink': revlink}
self.num_changes += 1

f = pb.PBClientFactory()
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/ec2buildslave.py
Expand Up @@ -231,9 +231,9 @@ def _start_instance(self):
self.output.output))
if self.elastic_ip is not None:
self.instance.use_ip(self.elastic_ip)
return [self.instance.id,
image.id,
'%02d:%02d:%02d' % (minutes//60, minutes%60, seconds)]
return [self.instance.id,
image.id,
'%02d:%02d:%02d' % (minutes//60, minutes%60, seconds)]
else:
log.msg('%s %s failed to start instance %s (%s)' %
(self.__class__.__name__, self.slavename,
Expand Down
5 changes: 4 additions & 1 deletion master/buildbot/scripts/runner.py
Expand Up @@ -784,6 +784,7 @@ def __init__(self):
("logfile", "F", None,
"Read the log messages from this file (- for stdin)"),
("when", "w", None, "timestamp to use as the change time"),
("revlink", "l", None, "Revision link (revlink)"),
]

buildbotOptions = [
Expand Down Expand Up @@ -815,6 +816,7 @@ def sendchange(config, runReactor=False):
properties = config.get('properties', {})
repository = config.get('repository', '')
project = config.get('project', '')
revlink = config.get('revlink', '')
if config.get('when'):
when = float(config.get('when'))
else:
Expand All @@ -839,7 +841,8 @@ def sendchange(config, runReactor=False):

s = Sender(master, user)
d = s.send(branch, revision, comments, files, category=category, when=when,
properties=properties, repository=repository, project=project)
properties=properties, repository=repository, project=project,
revlink=revlink)
if runReactor:
status = [True]
def failed(res):
Expand Down
11 changes: 10 additions & 1 deletion master/buildbot/status/builder.py
Expand Up @@ -12,6 +12,7 @@
import weakref
import os, shutil, re, urllib, itertools
import gc
import time
from cPickle import load, dump
from cStringIO import StringIO
from bz2 import BZ2File
Expand Down Expand Up @@ -2148,6 +2149,7 @@ def __init__(self, name):
self._lastMessageReceived = 0
self.runningBuilds = []
self.graceful_callbacks = []
self.connect_times = []

def getName(self):
return self.name
Expand All @@ -2165,6 +2167,9 @@ def lastMessageReceived(self):
return self._lastMessageReceived
def getRunningBuilds(self):
return self.runningBuilds
def getConnectCount(self):
then = time.time() - 3600
return len([ t for t in self.connect_times if t > then ])

def setAdmin(self, admin):
self.admin = admin
Expand All @@ -2179,6 +2184,11 @@ def setConnected(self, isConnected):
def setLastMessageReceived(self, when):
self._lastMessageReceived = when

def recordConnectTime(self):
# record this connnect, and keep data for the last hour
now = time.time()
self.connect_times = [ t for t in self.connect_times if t > now - 3600 ] + [ now ]

def buildStarted(self, build):
self.runningBuilds.append(build)
def buildFinished(self, build):
Expand Down Expand Up @@ -2217,7 +2227,6 @@ def asDict(self):
result['runningBuilds'] = [b.asDict() for b in self.getRunningBuilds()]
return result


class Status:
"""
I represent the status of the buildmaster.
Expand Down
11 changes: 9 additions & 2 deletions master/buildbot/status/web/slaves.py
Expand Up @@ -59,7 +59,12 @@ def content(self, request, ctx):
recent_builds.append(self.get_line_values(request, rb))
if n > max_builds:
break
ctx.update(dict(slave = s.getSlave(self.slavename),

# connects over the last hour
slave = s.getSlave(self.slavename)
connect_count = slave.getConnectCount()

ctx.update(dict(slave=slave,
slavename = self.slavename,
current = current_builds,
recent = recent_builds,
Expand All @@ -69,7 +74,8 @@ def content(self, request, ctx):
access_uri = slave.getAccessURI()),
admin = unicode(slave.getAdmin() or '', 'utf-8'),
host = unicode(slave.getHost() or '', 'utf-8'),
show_builder_column = True)
show_builder_column = True,
connect_count = connect_count)
template = request.site.buildbot_service.templates.get_template("buildslave.html")
data = template.render(**ctx)
return data
Expand Down Expand Up @@ -112,6 +118,7 @@ def content(self, request, ctx):

info['version'] = slave.getVersion()
info['connected'] = slave.isConnected()
info['connectCount'] = slave.getConnectCount()

if slave.isConnected():
info['admin'] = unicode(slave.getAdmin() or '', 'utf-8')
Expand Down
9 changes: 7 additions & 2 deletions master/buildbot/status/web/templates/buildslave.html
Expand Up @@ -42,9 +42,14 @@ <h2>Slave information</h2>
<pre>{{ host|e }}</pre>
{% endif %}

<h2>Connection Status</h2>
<p>
{{ connect_count }} connection(s) in the last hour
{% if not slave.isConnected() %}
<p>(not connected)</p>
{% elif authz.advertiseAction('gracefulShutdown') %}
(not currently connected)
{% endif %}
</p>
{% if authz.advertiseAction('gracefulShutdown') %}
<h2>Graceful Shutdown</h2>
{% if slave.getGraceful() %}
<p>Slave will shut down gracefully when it is idle.</p>
Expand Down
13 changes: 11 additions & 2 deletions master/buildbot/status/web/templates/buildslaves.html
Expand Up @@ -16,6 +16,7 @@ <h1>Buildslaves</h1>
<th>BuildBot</th>
<th>Admin</th>
<th>Last heard from</th>
<th>Connects/Hour</th>
<th>Status</th>
</tr>

Expand Down Expand Up @@ -51,15 +52,23 @@ <h1>Buildslaves</h1>
{%- endif -%}
</td>

{% else %}
<td>-</td>
<td>-</td>
{% endif %}

<td>
{{ s.connectCount }}
</td>

{% if s.connected %}
{% if s.running_builds %}
<td class="building">Running {{ s.running_builds }} build(s)</td>
{% else %}
<td class="idle">Idle</td>
{% endif %}

{% else %}
<td>-</td>
<td>-</td>
<td class="offline">Not connected</td>
{% endif %}

Expand Down

0 comments on commit ae15bfd

Please sign in to comment.