From 381c7fdc5d3039f6b3620a6ffc68714fc3d82bd3 Mon Sep 17 00:00:00 2001 From: thedoubl3j Date: Tue, 20 Jan 2026 15:21:23 -0500 Subject: [PATCH] Adjust heartbeat arg and more formatting * fixed the call to cluster_node_heartbeat missing binder * formatting/linter fixes --- awx/main/dispatch/worker/base.py | 7 +------ awx/main/management/commands/run_dispatcher.py | 17 +++++++++++++++++ awx/main/tests/functional/test_jobs.py | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/awx/main/dispatch/worker/base.py b/awx/main/dispatch/worker/base.py index ca7691ca22..788b45a2b7 100644 --- a/awx/main/dispatch/worker/base.py +++ b/awx/main/dispatch/worker/base.py @@ -6,19 +6,14 @@ import logging import signal import sys import time -from queue import Empty as QueueEmpty from django import db from awx.main.utils.redis import get_redis_client from awx.main.dispatch.pool import WorkerPool -from awx.main.utils.db import set_connection_name -if 'run_callback_receiver' in sys.argv: - logger = logging.getLogger('awx.main.commands.run_callback_receiver') -else: - logger = logging.getLogger('awx.main.dispatch') +logger = logging.getLogger('awx.main.commands.run_callback_receiver') def signame(sig): diff --git a/awx/main/management/commands/run_dispatcher.py b/awx/main/management/commands/run_dispatcher.py index e5cdd703f4..b90b89418e 100644 --- a/awx/main/management/commands/run_dispatcher.py +++ b/awx/main/management/commands/run_dispatcher.py @@ -5,6 +5,8 @@ import logging.config import yaml from django.core.management.base import BaseCommand, CommandError +from django.core.cache import cache as django_cache +from django.db import connection from dispatcherd.factories import get_control_from_settings from dispatcherd import run_service @@ -71,3 +73,18 @@ class Command(BaseCommand): dispatcher_setup(get_dispatcherd_config(for_service=True)) run_service() + + def configure_dispatcher_logging(self): + # Apply special log rule for the parent process + special_logging = copy.deepcopy(settings.LOGGING) + for handler_name, handler_config in special_logging.get('handlers', {}).items(): + filters = handler_config.get('filters', []) + if 'dynamic_level_filter' in filters: + handler_config['filters'] = [flt for flt in filters if flt != 'dynamic_level_filter'] + logger.info(f'Dispatcherd main process replaced log level filter for {handler_name} handler') + + # Apply the custom logging level here, before the asyncio code starts + special_logging.setdefault('loggers', {}).setdefault('dispatcherd', {}) + special_logging['loggers']['dispatcherd']['level'] = settings.LOG_AGGREGATOR_LEVEL + + logging.config.dictConfig(special_logging) diff --git a/awx/main/tests/functional/test_jobs.py b/awx/main/tests/functional/test_jobs.py index e71420f737..7d4a0ed5b7 100644 --- a/awx/main/tests/functional/test_jobs.py +++ b/awx/main/tests/functional/test_jobs.py @@ -50,7 +50,7 @@ def test_job_capacity_and_with_inactive_node(): i.save() with override_settings(CLUSTER_HOST_ID=i.hostname): with mock.patch.object(redis.client.Redis, 'ping', lambda self: True): - cluster_node_heartbeat() + cluster_node_heartbeat(None) i = Instance.objects.get(id=i.id) assert i.capacity == 0