mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02:30
Update task management to only do things with ready instances
This commit is contained in:
@@ -37,7 +37,11 @@ class TaskManagerInstances:
|
|||||||
def __init__(self, active_tasks, instances=None, instance_fields=('node_type', 'capacity', 'hostname', 'enabled')):
|
def __init__(self, active_tasks, instances=None, instance_fields=('node_type', 'capacity', 'hostname', 'enabled')):
|
||||||
self.instances_by_hostname = dict()
|
self.instances_by_hostname = dict()
|
||||||
if instances is None:
|
if instances is None:
|
||||||
instances = Instance.objects.filter(hostname__isnull=False, enabled=True).exclude(node_type='hop').only(*instance_fields)
|
instances = (
|
||||||
|
Instance.objects.filter(hostname__isnull=False, node_state=Instance.States.READY, enabled=True)
|
||||||
|
.exclude(node_type='hop')
|
||||||
|
.only('node_type', 'node_state', 'capacity', 'hostname', 'enabled')
|
||||||
|
)
|
||||||
for instance in instances:
|
for instance in instances:
|
||||||
self.instances_by_hostname[instance.hostname] = TaskManagerInstance(instance)
|
self.instances_by_hostname[instance.hostname] = TaskManagerInstance(instance)
|
||||||
|
|
||||||
|
|||||||
@@ -349,9 +349,13 @@ def _cleanup_images_and_files(**kwargs):
|
|||||||
logger.info(f'Performed local cleanup with kwargs {kwargs}, output:\n{stdout}')
|
logger.info(f'Performed local cleanup with kwargs {kwargs}, output:\n{stdout}')
|
||||||
|
|
||||||
# if we are the first instance alphabetically, then run cleanup on execution nodes
|
# if we are the first instance alphabetically, then run cleanup on execution nodes
|
||||||
checker_instance = Instance.objects.filter(node_type__in=['hybrid', 'control'], enabled=True, capacity__gt=0).order_by('-hostname').first()
|
checker_instance = (
|
||||||
|
Instance.objects.filter(node_type__in=['hybrid', 'control'], node_state=Instance.States.READY, enabled=True, capacity__gt=0)
|
||||||
|
.order_by('-hostname')
|
||||||
|
.first()
|
||||||
|
)
|
||||||
if checker_instance and this_inst.hostname == checker_instance.hostname:
|
if checker_instance and this_inst.hostname == checker_instance.hostname:
|
||||||
for inst in Instance.objects.filter(node_type='execution', enabled=True, capacity__gt=0):
|
for inst in Instance.objects.filter(node_type='execution', node_state=Instance.States.READY, enabled=True, capacity__gt=0):
|
||||||
runner_cleanup_kwargs = inst.get_cleanup_task_kwargs(**kwargs)
|
runner_cleanup_kwargs = inst.get_cleanup_task_kwargs(**kwargs)
|
||||||
if not runner_cleanup_kwargs:
|
if not runner_cleanup_kwargs:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user