From d1326df6eefec76eac3af056e908a23db2e0b6ff Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 8 Nov 2018 11:35:56 +1100 Subject: [PATCH] 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 --- nodepool/task_manager.py | 11 ----------- .../openstacksdk-stats-fix-f0f8da97cfd52328.yaml | 4 ++++ 2 files changed, 4 insertions(+), 11 deletions(-) create mode 100644 releasenotes/notes/openstacksdk-stats-fix-f0f8da97cfd52328.yaml diff --git a/nodepool/task_manager.py b/nodepool/task_manager.py index 0e52c35b5..7d4c142ee 100644 --- a/nodepool/task_manager.py +++ b/nodepool/task_manager.py @@ -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() diff --git a/releasenotes/notes/openstacksdk-stats-fix-f0f8da97cfd52328.yaml b/releasenotes/notes/openstacksdk-stats-fix-f0f8da97cfd52328.yaml new file mode 100644 index 000000000..058d00f88 --- /dev/null +++ b/releasenotes/notes/openstacksdk-stats-fix-f0f8da97cfd52328.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - Fixes a regression of missing task statistics with OpenstackSDK + versions greater than 0.19.0.