add debug views for task manager(s)

implement https://github.com/ansible/awx/issues/12446
in development environment, enable set of views that run
the task manager(s).

Also introduce a setting that disables any calls to schedule()
that do not originate from the debug views when in the development
environment. With guards around both if we are in the development
environment and the setting, I think we're pretty safe this won't get
triggered unintentionally.

use MODE to determine if we are in devel env

Also, move test for skipping task managers to the tasks file
This commit is contained in:
Elijah DeLee
2022-06-30 23:37:28 -04:00
committed by Seth Foster
parent 431b9370df
commit ad08eafb9a
5 changed files with 119 additions and 1 deletions

View File

@@ -1,7 +1,11 @@
# Python
import logging
# Django
from django.conf import settings
# AWX
from awx import MODE
from awx.main.scheduler import TaskManager, DependencyManager, WorkflowManager
from awx.main.dispatch.publish import task
from awx.main.dispatch import get_local_queuename
@@ -11,20 +15,36 @@ logger = logging.getLogger('awx.main.scheduler')
@task(queue=get_local_queuename)
def task_manager():
prefix = 'task'
if MODE == 'development' and settings.AWX_DISABLE_TASK_MANAGERS:
logger.debug(f"Not running {prefix} manager, AWX_DISABLE_TASK_MANAGERS is True. Trigger with GET to /api/debug/{prefix}_manager/")
return
TaskManager().schedule()
@task(queue=get_local_queuename)
def dependency_manager():
prefix = 'dependency'
if MODE == 'development' and settings.AWX_DISABLE_TASK_MANAGERS:
logger.debug(f"Not running {prefix} manager, AWX_DISABLE_TASK_MANAGERS is True. Trigger with GET to /api/debug/{prefix}_manager/")
return
DependencyManager().schedule()
@task(queue=get_local_queuename)
def workflow_manager():
prefix = 'workflow'
if MODE == 'development' and settings.AWX_DISABLE_TASK_MANAGERS:
logger.debug(f"Not running {prefix} manager, AWX_DISABLE_TASK_MANAGERS is True. Trigger with GET to /api/debug/{prefix}_manager/")
return
WorkflowManager().schedule()
def run_task_manager():
if MODE == 'development' and settings.AWX_DISABLE_TASK_MANAGERS:
logger.debug(f"Not running task managers, AWX_DISABLE_TASK_MANAGERS is True. Trigger with GET to /api/debug/{prefix}_manager/")
return
task_manager()
dependency_manager()
workflow_manager()