Merge lp:~julian-edwards/maas/task-log-level into lp:~maas-committers/maas/trunk

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 2647
Proposed branch: lp:~julian-edwards/maas/task-log-level
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 261 lines (+38/-35)
2 files modified
src/provisioningserver/dhcp/detect.py (+1/-1)
src/provisioningserver/tasks.py (+37/-34)
To merge this branch: bzr merge lp:~julian-edwards/maas/task-log-level
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Review via email: mp+229251@code.launchpad.net

Commit message

Wind down some INFO logs for periodic tasks to DEBUG as they swamp the log.

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

No approved revision specified.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/dhcp/detect.py'
2--- src/provisioningserver/dhcp/detect.py 2014-07-30 11:08:46 +0000
3+++ src/provisioningserver/dhcp/detect.py 2014-08-01 16:00:35 +0000
4@@ -287,7 +287,7 @@
5 # which we need to ignore; it means the interface has no IP
6 # and there's no need to scan this interface as it's not in
7 # use.
8- maaslog.info(
9+ maaslog.debug(
10 "Ignoring DHCP scan for %s, it has no IP address", interface)
11 elif e.errno == errno.ENODEV:
12 # Errno ENODEV is "no such device". This seems an odd situation
13
14=== modified file 'src/provisioningserver/tasks.py'
15--- src/provisioningserver/tasks.py 2014-07-29 16:35:08 +0000
16+++ src/provisioningserver/tasks.py 2014-08-01 16:00:35 +0000
17@@ -29,6 +29,7 @@
18
19 from base64 import b64decode
20 from functools import wraps
21+import logging
22 from subprocess import CalledProcessError
23
24 from celery.app import app_or_default
25@@ -84,24 +85,26 @@
26 maaslog = get_maas_logger("tasks")
27
28
29-def log_task_events(func):
30+def log_task_events(level=logging.INFO):
31 """Log to the maaslog that something happened with a task.
32
33 :param event: The event that we want to log.
34 :param task_name: The name of the task.
35 :**kwargs: A dict of args passed to the task.
36 """
37- @wraps(func)
38- def wrapper(*args, **kwargs):
39- arg_string = "%s %s" % (args, kwargs)
40- maaslog.info(
41- "Starting task '%s' with args: %s" %
42- (func.__name__, arg_string))
43- func(*args, **kwargs)
44- maaslog.info(
45- "Finished task '%s' with args: %s" %
46- (func.__name__, arg_string))
47- return wrapper
48+ def _decorator(func):
49+ @wraps(func)
50+ def wrapper(*args, **kwargs):
51+ arg_string = "%s %s" % (args, kwargs)
52+ maaslog.log(
53+ level, "Starting task '%s' with args: %s" %
54+ (func.__name__, arg_string))
55+ func(*args, **kwargs)
56+ maaslog.log(
57+ level, "Finished task '%s' with args: %s" %
58+ (func.__name__, arg_string))
59+ return wrapper
60+ return _decorator
61
62
63 # The tasks catch bare exceptions in an attempt to circumvent Celery's
64@@ -123,7 +126,7 @@
65
66
67 @task
68-@log_task_events
69+@log_task_events()
70 @log_exception_text
71 def refresh_secrets(**kwargs):
72 """Update the worker's knowledge of various secrets it needs.
73@@ -172,7 +175,7 @@
74
75
76 @task
77-@log_task_events
78+@log_task_events()
79 @log_exception_text
80 def power_on(power_type, **kwargs):
81 """Turn a node on.
82@@ -186,7 +189,7 @@
83
84
85 @task
86-@log_task_events
87+@log_task_events()
88 @log_exception_text
89 def power_off(power_type, **kwargs):
90 """Turn a node off.
91@@ -211,7 +214,7 @@
92
93
94 @task(max_retries=RNDC_COMMAND_MAX_RETRY, queue=celery_config.WORKER_QUEUE_DNS)
95-@log_task_events
96+@log_task_events()
97 @log_exception_text
98 def rndc_command(arguments, retry=False, callback=None):
99 """Use rndc to execute a command.
100@@ -236,7 +239,7 @@
101
102
103 @task(queue=celery_config.WORKER_QUEUE_DNS)
104-@log_task_events
105+@log_task_events()
106 @log_exception_text
107 def write_full_dns_config(zones=None, callback=None, **kwargs):
108 """Write out the DNS configuration files: the main configuration
109@@ -260,7 +263,7 @@
110
111
112 @task(queue=celery_config.WORKER_QUEUE_DNS)
113-@log_task_events
114+@log_task_events()
115 @log_exception_text
116 def write_dns_config(zones=(), callback=None, **kwargs):
117 """Write out the DNS configuration file.
118@@ -279,7 +282,7 @@
119
120
121 @task(queue=celery_config.WORKER_QUEUE_DNS)
122-@log_task_events
123+@log_task_events()
124 @log_exception_text
125 def write_dns_zone_config(zones, callback=None, **kwargs):
126 """Write out DNS zones.
127@@ -297,7 +300,7 @@
128
129
130 @task(queue=celery_config.WORKER_QUEUE_DNS)
131-@log_task_events
132+@log_task_events()
133 @log_exception_text
134 def setup_rndc_configuration(callback=None):
135 """Write out the two rndc configuration files (rndc.conf and
136@@ -317,7 +320,7 @@
137
138
139 @task
140-@log_task_events
141+@log_task_events(level=logging.DEBUG)
142 @log_exception_text
143 def upload_dhcp_leases():
144 """Upload DHCP leases.
145@@ -329,7 +332,7 @@
146
147
148 @task
149-@log_task_events
150+@log_task_events()
151 @log_exception_text
152 def add_new_dhcp_host_map(mappings, server_address, shared_key):
153 """Add address mappings to the DHCP server.
154@@ -356,7 +359,7 @@
155
156
157 @task
158-@log_task_events
159+@log_task_events()
160 @log_exception_text
161 def remove_dhcp_host_map(ip_address, server_address, omapi_key):
162 """Remove an IP to MAC mapping in the DHCP server.
163@@ -381,7 +384,7 @@
164
165
166 @task
167-@log_task_events
168+@log_task_events()
169 @log_exception_text
170 def write_dhcp_config(callback=None, **kwargs):
171 """Write out the DHCP configuration file and restart the DHCP server.
172@@ -399,7 +402,7 @@
173
174
175 @task
176-@log_task_events
177+@log_task_events()
178 @log_exception_text
179 def restart_dhcp_server():
180 """Restart the DHCP server."""
181@@ -419,7 +422,7 @@
182
183
184 @task
185-@log_task_events
186+@log_task_events()
187 @log_exception_text
188 def stop_dhcp_server():
189 """Write a blank config file and stop a DHCP server."""
190@@ -447,7 +450,7 @@
191
192
193 @task
194-@log_task_events
195+@log_task_events(level=logging.DEBUG)
196 @log_exception_text
197 def periodic_probe_dhcp():
198 """Probe for foreign DHCP servers."""
199@@ -460,7 +463,7 @@
200
201
202 @task
203-@log_task_events
204+@log_task_events(level=logging.DEBUG)
205 @log_exception_text
206 def report_boot_images():
207 """For master worker only: report available netboot images."""
208@@ -480,7 +483,7 @@
209
210
211 @task(max_retries=UPDATE_NODE_TAGS_MAX_RETRY)
212-@log_task_events
213+@log_task_events()
214 @log_exception_text
215 def update_node_tags(tag_name, tag_definition, tag_nsmap, retry=True):
216 """Update the nodes for a new/changed tag definition.
217@@ -504,7 +507,7 @@
218 # =====================================================================
219
220 @task
221-@log_task_events
222+@log_task_events()
223 @log_exception_text
224 def import_boot_images(sources, http_proxy=None, callback=None):
225 for source in sources:
226@@ -529,7 +532,7 @@
227 # =====================================================================
228
229 @task
230-@log_task_events
231+@log_task_events()
232 @log_exception_text
233 def add_seamicro15k(mac, username, password, power_control=None):
234 """ See `maasserver.api.NodeGroup.add_seamicro15k`. """
235@@ -543,7 +546,7 @@
236
237
238 @task
239-@log_task_events
240+@log_task_events()
241 @log_exception_text
242 def add_virsh(poweraddr, password=None):
243 """ See `maasserver.api.NodeGroup.add_virsh`. """
244@@ -551,7 +554,7 @@
245
246
247 @task
248-@log_task_events
249+@log_task_events()
250 @log_exception_text
251 def enlist_nodes_from_ucsm(url, username, password):
252 """ See `maasserver.api.NodeGroupHandler.enlist_nodes_from_ucsm`. """
253@@ -559,7 +562,7 @@
254
255
256 @task
257-@log_task_events
258+@log_task_events()
259 @log_exception_text
260 def enlist_nodes_from_mscm(host, username, password):
261 """ See `maasserver.api.NodeGroupHandler.enlist_nodes_from_mscm`. """