mirror of
https://github.com/ansible/awx.git
synced 2026-02-15 18:20:00 -03:30
Adopt the node_type field in receptor logic (#10802)
* Adopt the node_type field in receptor logic * Refactor Instance.objects.register so we do not reset capacity to 0
This commit is contained in:
@@ -85,7 +85,7 @@ from awx.main.models import (
|
||||
SystemJobEvent,
|
||||
build_safe_env,
|
||||
)
|
||||
from awx.main.constants import ACTIVE_STATES
|
||||
from awx.main.constants import ACTIVE_STATES, RECEPTOR_PENDING
|
||||
from awx.main.exceptions import AwxTaskError, PostRunError
|
||||
from awx.main.queue import CallbackQueueDispatcher
|
||||
from awx.main.dispatch.publish import task
|
||||
@@ -121,7 +121,6 @@ from awx.main.analytics.subsystem_metrics import Metrics
|
||||
from rest_framework.exceptions import PermissionDenied
|
||||
|
||||
RECEPTOR_SOCK = '/var/run/receptor/receptor.sock'
|
||||
RECEPTOR_PENDING = 'ansible-runner-???'
|
||||
|
||||
|
||||
__all__ = [
|
||||
@@ -422,17 +421,14 @@ def discover_receptor_nodes():
|
||||
commands = ad['WorkCommands'] or []
|
||||
if 'ansible-runner' not in commands:
|
||||
continue
|
||||
(changed, instance) = Instance.objects.register(hostname=hostname)
|
||||
(changed, instance) = Instance.objects.register(hostname=hostname, node_type='execution')
|
||||
was_lost = instance.is_lost(ref_time=nowtime)
|
||||
if changed:
|
||||
logger.info("Registered tower execution node '{}'".format(hostname))
|
||||
instance.capacity = 0
|
||||
instance.version = RECEPTOR_PENDING
|
||||
instance.save(update_fields=['capacity', 'version', 'modified'])
|
||||
logger.info("Registered execution node '{}'".format(hostname))
|
||||
check_heartbeat.apply_async([hostname])
|
||||
else:
|
||||
last_seen = parse_date(ad['Time'])
|
||||
logger.debug("Updated tower control node '{}' last seen {}".format(hostname, last_seen))
|
||||
logger.debug("Updated execution node '{}' modified from {} to {}".format(hostname, instance.modified, last_seen))
|
||||
instance.modified = last_seen
|
||||
if instance.is_lost(ref_time=nowtime):
|
||||
# if the instance hasn't advertised in awhile,
|
||||
@@ -466,7 +462,8 @@ def cluster_node_heartbeat():
|
||||
if inst.hostname == settings.CLUSTER_HOST_ID:
|
||||
this_inst = inst
|
||||
instance_list.remove(inst)
|
||||
elif inst.version.startswith('ansible-runner'): # TODO: use proper field when introduced
|
||||
elif inst.node_type == 'execution':
|
||||
# Only considering control plane for this logic
|
||||
continue
|
||||
elif inst.is_lost(ref_time=nowtime):
|
||||
lost_instances.append(inst)
|
||||
|
||||
Reference in New Issue
Block a user