Use openstacksdk submit_task

Task manager stats sending was broken with openstacksdk updates and
fixed in I8617ab2895d1544a6902ae5a3d6a97b87bfd2ec9.

What used to happen is that openstacksdk run_task() would call
post_run_task(); however with changes to use a threadpool this became
an async call so was not reflecting the post-run state but just the
post-insert-into-threadpool-queue state.

The referenced change moved the post_run_task() call into
submit_task(), where it is called after the task has been wait()ed
for (and actually run).

Unfortunatley, since this file overrides submit_task, it means that
post_run_task is not being called any more and we are not producing
timing stats.

I believe we can use the openstacksdk task manager's submit_task
directly.  There are two differences; the "raw" argument was removed
from upstream with I7b46e263a76d84573bdfbbece57b1048764ed939 and is no
longer necessary.  The ManagerStoppedException is private to this file
and doesn't appear to have an external dependencies; thus the
openstacksdk's TaskManagerStopped exception will work just the same.

Change-Id: I427e6ae9e4beae6d551427fc12a3cde2c1d03aba
This commit is contained in:
Ian Wienand 2018-11-08 11:35:56 +11:00
parent 17d053cf94
commit d1326df6ee
2 changed files with 4 additions and 11 deletions

View File

@ -39,10 +39,6 @@ def _transform_task_name(task_name):
)
class ManagerStoppedException(Exception):
pass
class TaskManager(openstack_task_manager.TaskManager):
log = logging.getLogger("nodepool.TaskManager")
@ -101,10 +97,3 @@ class TaskManager(openstack_task_manager.TaskManager):
key = 'nodepool.task.%s.%s' % (self.name, task_name)
self.statsd.timing(key, int(elapsed_time * 1000))
self.statsd.incr(key)
def submit_task(self, task, raw=False):
if not self._running:
raise ManagerStoppedException(
"Manager %s is no longer running" % self.name)
self.queue.put(task)
return task.wait()

View File

@ -0,0 +1,4 @@
---
fixes:
- Fixes a regression of missing task statistics with OpenstackSDK
versions greater than 0.19.0.