From cf88f4748a496b3986289777de72b9676831a902 Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Thu, 30 Jun 2022 13:48:55 -0400 Subject: [PATCH] workflow manager own get_tasks --- awx/main/analytics/subsystem_metrics.py | 5 +++-- awx/main/scheduler/task_manager.py | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/awx/main/analytics/subsystem_metrics.py b/awx/main/analytics/subsystem_metrics.py index 6c186759d7..f63ca1940d 100644 --- a/awx/main/analytics/subsystem_metrics.py +++ b/awx/main/analytics/subsystem_metrics.py @@ -184,7 +184,7 @@ class Metrics: FloatM('subsystem_metrics_pipe_execute_seconds', 'Time spent saving metrics to redis'), IntM('subsystem_metrics_pipe_execute_calls', 'Number of calls to pipe_execute'), FloatM('subsystem_metrics_send_metrics_seconds', 'Time spent sending metrics to other nodes'), - SetFloatM('task_manager_get_tasks_seconds', 'Time spent in loading all tasks from db'), + SetFloatM('task_manager_get_tasks_seconds', 'Time spent in loading tasks from db'), SetFloatM('task_manager_start_task_seconds', 'Time spent starting task'), SetFloatM('task_manager_process_running_tasks_seconds', 'Time spent processing running tasks'), SetFloatM('task_manager_process_pending_tasks_seconds', 'Time spent processing pending tasks'), @@ -195,7 +195,7 @@ class Metrics: SetIntM('task_manager_running_processed', 'Number of running tasks processed'), SetIntM('task_manager_pending_processed', 'Number of pending tasks processed'), SetIntM('task_manager_tasks_blocked', 'Number of tasks blocked from running'), - SetFloatM('dependency_manager_get_tasks_seconds', 'Time spent in loading all tasks from db'), + SetFloatM('dependency_manager_get_tasks_seconds', 'Time spent in loading tasks from db'), SetFloatM('dependency_manager_generate_dependencies_seconds', 'Time spent generating dependencies for pending tasks'), SetFloatM('dependency_manager__schedule_seconds', 'Time spent in running the entire _schedule'), IntM('dependency_manager_schedule_calls', 'Number of calls to task manager schedule'), @@ -205,6 +205,7 @@ class Metrics: IntM('workflow_manager_schedule_calls', 'Number of calls to task manager schedule'), SetFloatM('workflow_manager_recorded_timestamp', 'Unix timestamp when metrics were last recorded'), SetFloatM('workflow_manager_spawn_workflow_graph_jobs_seconds', 'Time spent spawning workflow jobs'), + SetFloatM('workflow_manager_get_tasks_seconds', 'Time spent in loading tasks from db'), ] # turn metric list into dictionary with the metric name as a key self.METRICS = {} diff --git a/awx/main/scheduler/task_manager.py b/awx/main/scheduler/task_manager.py index 08cacc440e..b85bfb6982 100644 --- a/awx/main/scheduler/task_manager.py +++ b/awx/main/scheduler/task_manager.py @@ -257,9 +257,13 @@ class WorkflowManager(TaskBase): task.job_explanation = timeout_message task.save(update_fields=['status', 'job_explanation', 'timed_out']) + @timeit + def get_tasks(self): + return self.get_running_workflow_jobs() + @timeit def _schedule(self): - running_workflow_tasks = self.get_running_workflow_jobs() + running_workflow_tasks = self.get_tasks() if len(running_workflow_tasks) > 0: self.process_finished_workflow_jobs(running_workflow_tasks)