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
This commit is contained in:
Hao Liu 2023-03-27 14:41:48 -04:00
parent 8c5e2237f4
commit 25303ee625

View File

@ -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