From 25303ee6258860d2be75ccad329b4e97b5973193 Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Mon, 27 Mar 2023 14:41:48 -0400 Subject: [PATCH] Only select task instance that are ready and enabled When select a queue for task instance to run task only select task instance that are ready and enabled --- awx/main/dispatch/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/awx/main/dispatch/__init__.py b/awx/main/dispatch/__init__.py index 642405c2dd..009438307a 100644 --- a/awx/main/dispatch/__init__.py +++ b/awx/main/dispatch/__init__.py @@ -19,7 +19,18 @@ def get_task_queuename(): if os.getenv('AWX_COMPONENT') == 'web': from awx.main.models.ha import Instance - return Instance.objects.filter(node_type__in=['control', 'hybrid']).order_by('?').first().hostname + return ( + Instance.objects.filter( + node_type__in=[Instance.Types.CONTROL, Instance.Types.HYBRID], + node_state=Instance.States.READY, + enabled=True, + ) + .only('hostname') + .order_by('?') + .first() + .hostname + ) + else: return settings.CLUSTER_HOST_ID