summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2018-07-24 09:51:27 -0500
committerMonty Taylor <mordred@inaugust.com>2018-07-24 13:57:05 -0500
commit67824d8e64250ede0cb4a3ebe344412f5cba2218 (patch)
treecef06c28b8e444dd01b1a0019c8f1e4c02816ad3
parent60bf606db48eb575ead7c10914cb893878bfec94 (diff)
Make statsd key look like the keys from shade3.2.0
openstacksdk produces task names that look like compute.DELETE.servers, which are {service_type}.{METHOD}.{url}.{parts} but shade and nodepool have been reporting to statsd with {Service_type}{Method}{Url}{Parts}. Translate the task.name produced by sdk into the key nodepool expects to report as. Also, emit 'Manager ran task' log lines The super class emits these, but on the openstacksdk logger. We don't really want to turn that on at debug level for normal usage, so rather than calling super(post_run_task) just straight-up override it. Make sure we log using the transformed name in all cases. Change-Id: I7f21aefc204366f7621643fdba76b7e70ce4caf5
Notes
Notes (review): Code-Review+2: David Shrewsbury <shrewsbury.dave@gmail.com> Workflow+1: David Shrewsbury <shrewsbury.dave@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 24 Jul 2018 20:44:33 +0000 Reviewed-on: https://review.openstack.org/585397 Project: openstack-infra/nodepool Branch: refs/heads/master
-rw-r--r--nodepool/task_manager.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/nodepool/task_manager.py b/nodepool/task_manager.py
index 602318a..26ae7fa 100644
--- a/nodepool/task_manager.py
+++ b/nodepool/task_manager.py
@@ -26,6 +26,14 @@ from openstack import task_manager as openstack_task_manager
26from nodepool import stats 26from nodepool import stats
27 27
28 28
29def _transform_task_name(task_name):
30 # openstacksdk sets task.name to something like "compute.DELETE.servers"
31 # We want ComputeDeleteServers
32 return "".join(
33 [part.lower().capitalize() for part in task_name.split('.')]
34 )
35
36
29class ManagerStoppedException(Exception): 37class ManagerStoppedException(Exception):
30 pass 38 pass
31 39
@@ -68,7 +76,9 @@ class TaskManager(openstack_task_manager.TaskManager):
68 break 76 break
69 time.sleep(self.rate - delta) 77 time.sleep(self.rate - delta)
70 self.log.debug("Manager %s running task %s (queue %s)" % 78 self.log.debug("Manager %s running task %s (queue %s)" %
71 (self.name, task.name, self.queue.qsize())) 79 (self.name,
80 _transform_task_name(task.name),
81 self.queue.qsize()))
72 self.run_task(task) 82 self.run_task(task)
73 self.queue.task_done() 83 self.queue.task_done()
74 except Exception: 84 except Exception:
@@ -76,10 +86,14 @@ class TaskManager(openstack_task_manager.TaskManager):
76 raise 86 raise
77 87
78 def post_run_task(self, elapsed_time, task): 88 def post_run_task(self, elapsed_time, task):
79 super(TaskManager, self).post_run_task(elapsed_time, task) 89 task_name = _transform_task_name(task.name)
90 self.log.debug(
91 "Manager %s ran task %s in %ss" %
92 (self.name, task_name, elapsed_time))
93
80 if self.statsd: 94 if self.statsd:
81 # nodepool.task.PROVIDER.TASK_NAME 95 # nodepool.task.PROVIDER.TASK_NAME
82 key = 'nodepool.task.%s.%s' % (self.name, task.name) 96 key = 'nodepool.task.%s.%s' % (self.name, task_name)
83 self.statsd.timing(key, int(elapsed_time * 1000)) 97 self.statsd.timing(key, int(elapsed_time * 1000))
84 self.statsd.incr(key) 98 self.statsd.incr(key)
85 99