mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Raise ValueError when no ready and enabled task instance
This commit is contained in:
parent
6267469709
commit
c8c8ed1775
@ -1,3 +1,4 @@
|
||||
import os
|
||||
import psycopg2
|
||||
import select
|
||||
|
||||
@ -5,8 +6,6 @@ from contextlib import contextmanager
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import connection as pg_connection
|
||||
import os
|
||||
|
||||
|
||||
NOT_READY = ([], [], [])
|
||||
|
||||
@ -16,24 +15,27 @@ def get_local_queuename():
|
||||
|
||||
|
||||
def get_task_queuename():
|
||||
if os.getenv('AWX_COMPONENT') == 'web':
|
||||
from awx.main.models.ha import Instance
|
||||
|
||||
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:
|
||||
if os.getenv('AWX_COMPONENT') != 'web':
|
||||
return settings.CLUSTER_HOST_ID
|
||||
|
||||
from awx.main.models.ha import Instance
|
||||
|
||||
random_task_instance = (
|
||||
Instance.objects.filter(
|
||||
node_type__in=(Instance.Types.CONTROL, Instance.Types.HYBRID),
|
||||
node_state=Instance.States.READY,
|
||||
enabled=True,
|
||||
)
|
||||
.only('hostname')
|
||||
.order_by('?')
|
||||
.first()
|
||||
)
|
||||
|
||||
if random_task_instance is None:
|
||||
raise ValueError('No task instances are READY and Enabled.')
|
||||
|
||||
return random_task_instance.hostname
|
||||
|
||||
|
||||
class PubSub(object):
|
||||
def __init__(self, conn):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user