log builder failures (bug 664877)

This commit is contained in:
Jeff Balogh 2011-07-01 15:10:48 -07:00
Родитель 4b6a161350
Коммит 2a72e0257e
2 изменённых файлов: 26 добавлений и 2 удалений

Просмотреть файл

@ -64,6 +64,22 @@ class FakeUpload(object):
self.validation = validation
class RedisLogHandler(logging.Handler):
"""Logging handler that sends jetpack messages to redis."""
def __init__(self, logger, upgrader, file_data, level=logging.WARNING):
self.logger = logger
self.upgrader = upgrader
self.file_data = file_data
super(RedisLogHandler, self).__init__(level)
def emit(self, record):
self.file_data['status'] = 'failed'
self.file_data['msg'] = record.msg
self.upgrader.file(self.file_data)
self.logger.removeHandler(self)
@task
def repackage_jetpack(builder_data, **kw):
repack_data = dict(urlparse.parse_qsl(builder_data['request']))
@ -74,8 +90,10 @@ def repackage_jetpack(builder_data, **kw):
all_keys.update(repack_data)
msg = lambda s: ('[{file_id}]: ' + s).format(**all_keys)
upgrader = JetpackUpgrader()
file_data = upgrader.file(repack_data['file_id'])
redis_logger = RedisLogHandler(jp_log, upgrader, file_data)
jp_log.addHandler(redis_logger)
if file_data.get('uuid') != repack_data['uuid']:
return jp_log.warning(msg('Aborting repack. AMO<=>Builder tracking '
'number does not match.'))
@ -133,6 +151,7 @@ def repackage_jetpack(builder_data, **kw):
# Sync out the new version.
addon.update_version()
upgrader.finish(repack_data['file_id'])
jp_log.removeHandler(redis_logger)
try:
send_upgrade_email(addon, new_version, file_data['version'])

Просмотреть файл

@ -6,6 +6,7 @@
<style>
.upgrade { color: green; }
#jetpacks tbody { font-family: monospace; }
.fail { color: red }
</style>
{% endblock %}
@ -88,7 +89,11 @@
{% if upgrading %}
{% if file.id|string in repack_status %}
{% with repack = repack_status[file.id|string] %}
<td>{{ repack['status'] }} {{ repack['time']|timesince }}</td>
{% if repack.status == 'failed' %}
<td class="fail"><pre>{{ repack.msg }}</pre></td>
{% else %}
<td>{{ repack.status }} {{ repack.time|timesince }}</td>
{% endif %}
{% endwith %}
{% else %}
<td></td>