Set redis logs entries to expire rather than to immediately delete them to make the logs archiver idempotent.

This commit is contained in:
Jake Moshenko 2014-09-12 13:13:14 -04:00
parent 353da13b16
commit c01de4a916
3 changed files with 11 additions and 6 deletions

View file

@ -2,6 +2,11 @@ import redis
import json
from util.dynamic import import_class
from datetime import timedelta
ONE_DAY = timedelta(days=1)
class BuildStatusRetrievalError(Exception):
pass
@ -54,11 +59,11 @@ class RedisBuildLogs(object):
except redis.ConnectionError:
raise BuildStatusRetrievalError('Cannot retrieve build logs')
def delete_log_entries(self, build_id):
def expire_log_entries(self, build_id):
"""
Deletes the logs and status keys completely.
Sets the log entry to expire in 1 day.
"""
self._redis.delete(self._logs_key(build_id))
self._redis.expire(self._logs_key(build_id), ONE_DAY)
@staticmethod