Merge lp:~joetalbott/adt-result-checker/add_log_rotation into lp:adt-result-checker

Proposed by Joe Talbott
Status: Merged
Approved by: Joe Talbott
Approved revision: 15
Merged at revision: 13
Proposed branch: lp:~joetalbott/adt-result-checker/add_log_rotation
Merge into: lp:adt-result-checker
Diff against target: 147 lines (+24/-16)
5 files modified
adt_result_checker/__init__.py (+17/-10)
adt_result_checker/_cloud_support.py (+0/-4)
called-by-tarmac.py (+5/-0)
setup.py (+1/-2)
test_requirements.txt (+1/-0)
To merge this branch: bzr merge lp:~joetalbott/adt-result-checker/add_log_rotation
Reviewer Review Type Date Requested Status
Celso Providelo (community) Approve
Review via email: mp+256247@code.launchpad.net

Commit message

Add log rotation and flake8 checking (fix flake8 issues).

Description of the change

Add log rotation and flake8 checking (fix flake8 issues).

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

Very minor comment that I'm surprised it didn't catch with flake8. I don't personally care to be *that* nitpicky on it, but since you're going through this and correcting all these already, might as well. :)

Revision history for this message
Celso Providelo (cprov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'adt_result_checker/__init__.py'
2--- adt_result_checker/__init__.py 2015-04-14 21:02:30 +0000
3+++ adt_result_checker/__init__.py 2015-04-14 22:44:33 +0000
4@@ -105,8 +105,8 @@
5 # constantly requeueing messages. Does this matter?
6 # 2) If the cloud-worker never uploaded the tarball at all,
7 # this message will never leave the queue.
8- # 3) If our swift credentials are busted, this will similarly
9- # requeue forever.
10+ # 3) If our swift credentials are busted, this will
11+ # similarly requeue forever.
12 logger.warning(
13 "Requeueing message for request id '%s' since it's "
14 "result tarball is not in swift yet.",
15@@ -116,7 +116,8 @@
16 message.requeue()
17
18 def insert_into_dead_letter_queue(self, message, reason):
19- """Insert 'message_payload' into the dead-letter queue, with 'reason'."""
20+ """Insert 'message_payload' into the dead-letter queue,
21+ with 'reason'."""
22 logger.error(
23 "Inserting payload into dead letter queue. Reason: %s",
24 reason,
25@@ -135,7 +136,8 @@
26 # why we ack this message, even though we're really failing it.
27 message.payload['deadletter_reason'] = reason
28
29- queue = self.connection.SimpleQueue('adt.deadletters.{}'.format(API_VERSION))
30+ queue = self.connection.SimpleQueue(
31+ 'adt.deadletters.{}'.format(API_VERSION))
32 queue.put(message.payload)
33 queue.close()
34
35@@ -164,15 +166,16 @@
36 'adt.requests.{}'.format(routing_key),
37 self.adt_exchange, routing_key=routing_key)
38
39- # Always declare exchange and destination queue, even if there are no
40- # available works the request is preserved.
41+ # Always declare exchange and destination queue, even if
42+ # there are no available works the request is preserved.
43 declare = [self.adt_exchange, queue]
44
45 with producers[self.connection].acquire(block=True) as producer:
46
47 def errback(exc, interval):
48- # TODO: Figure out when we've stopped retrying, and add this
49- # message to the dead letter queue with a helpful error message
50+ # TODO: Figure out when we've stopped retrying, and
51+ # add this message to the dead letter queue with a
52+ # helpful error message
53 logger.error('Error: %r', exc, exc_info=1)
54 logger.info('Retry in %s seconds.', interval)
55
56@@ -188,7 +191,7 @@
57 dead_reason = "Maximum retry count exceeded"
58 if reason:
59 dead_reason += ' ({})'.format(reason)
60- self.insert_into_dead_letter_queue( message, dead_reason)
61+ self.insert_into_dead_letter_queue(message, dead_reason)
62
63 def post_results(self, request_id):
64 """Post the results of a successful test run.
65@@ -242,7 +245,11 @@
66 log_dir = os.path.dirname(log_path)
67 handler = None
68 if os.path.exists(log_dir):
69- handler = logging.FileHandler(log_path)
70+ handler = logging.handlers.TimedRotatingFileHandler(
71+ log_path,
72+ when='D',
73+ interval=1
74+ )
75 else:
76 print("'logs' directory '{}' does not exist, using stderr for "
77 "app log.".format(log_dir))
78
79=== modified file 'adt_result_checker/_cloud_support.py'
80--- adt_result_checker/_cloud_support.py 2015-03-18 21:42:30 +0000
81+++ adt_result_checker/_cloud_support.py 2015-04-14 22:44:33 +0000
82@@ -18,10 +18,8 @@
83 """Functions that talk to the cloud."""
84
85 import logging
86-from functools import lru_cache
87
88 from swiftclient.service import (
89- SwiftPostObject,
90 SwiftService,
91 )
92
93@@ -31,11 +29,9 @@
94 __all__ = [
95 'result_tarball_exists_in_swift',
96 'set_config_dict',
97- 'upload_tarball_to_swift_container',
98 ]
99
100
101-
102 def set_config_dict(config_dict):
103 global get_config_dict
104 get_config_dict = lambda: config_dict
105
106=== modified file 'called-by-tarmac.py'
107--- called-by-tarmac.py 2015-03-19 03:53:41 +0000
108+++ called-by-tarmac.py 2015-04-14 22:44:33 +0000
109@@ -89,6 +89,11 @@
110 'setup.py',
111 'test',
112 ],
113+ [
114+ os.path.join(ve_dir, 'bin', 'python3'),
115+ 'setup.py',
116+ 'flake8',
117+ ],
118 )
119 for cmd in all_cmds:
120 ret = _run_command(cmd)
121
122=== modified file 'setup.py'
123--- setup.py 2015-03-16 20:44:01 +0000
124+++ setup.py 2015-04-14 22:44:33 +0000
125@@ -21,13 +21,12 @@
126 import sys
127 assert sys.version_info >= (3,), 'Python 3 is required'
128
129-from setuptools import find_packages, setup, Extension
130+from setuptools import find_packages, setup
131
132
133 VERSION = '1.0.0'
134
135
136-
137 setup(
138 name='adt-result-checker',
139 version=VERSION,
140
141=== modified file 'test_requirements.txt'
142--- test_requirements.txt 2015-03-16 02:06:27 +0000
143+++ test_requirements.txt 2015-04-14 22:44:33 +0000
144@@ -1,3 +1,4 @@
145 testtools
146 fixtures
147+flake8==2.4.0
148

Subscribers

People subscribed via source and target branches