Skip to content

Commit

Permalink
Consistent behavior with dispatcher and callback
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding committed Sep 23, 2024
1 parent 1234ef2 commit d9b6e0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 5 additions & 4 deletions awx/main/management/commands/run_callback_receiver.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Copyright (c) 2015 Ansible, Inc.
# All Rights Reserved.

import redis

Check warning on line 4 in awx/main/management/commands/run_callback_receiver.py

View check run for this annotation

Codecov / codecov/patch

awx/main/management/commands/run_callback_receiver.py#L4

Added line #L4 was not covered by tests

from django.conf import settings
from django.core.management.base import BaseCommand, CommandError

from redis.exceptions import ConnectionError
import redis.exceptions

Check warning on line 8 in awx/main/management/commands/run_callback_receiver.py

View check run for this annotation

Codecov / codecov/patch

awx/main/management/commands/run_callback_receiver.py#L7-L8

Added lines #L7 - L8 were not covered by tests

from awx.main.analytics.subsystem_metrics import CallbackReceiverMetricsServer

Check warning on line 10 in awx/main/management/commands/run_callback_receiver.py

View check run for this annotation

Codecov / codecov/patch

awx/main/management/commands/run_callback_receiver.py#L10

Added line #L10 was not covered by tests
from awx.main.dispatch.control import Control
Expand All @@ -31,8 +32,8 @@ def handle(self, *arg, **options):

try:
CallbackReceiverMetricsServer().start()
except ConnectionError as exc:
raise CommandError(f'Could not connect to redis, error:\n{exc}\n')
except redis.exceptions.ConnectionError as exc:
raise CommandError(f'Callback receiver could not connect to redis, error: {exc}')

Check warning on line 36 in awx/main/management/commands/run_callback_receiver.py

View check run for this annotation

Codecov / codecov/patch

awx/main/management/commands/run_callback_receiver.py#L33-L36

Added lines #L33 - L36 were not covered by tests

try:
consumer = AWXConsumerRedis(
Expand Down
9 changes: 7 additions & 2 deletions awx/main/management/commands/run_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import logging
import yaml

import redis

Check warning on line 6 in awx/main/management/commands/run_dispatcher.py

View check run for this annotation

Codecov / codecov/patch

awx/main/management/commands/run_dispatcher.py#L6

Added line #L6 was not covered by tests

from django.conf import settings
from django.core.management.base import BaseCommand
from django.core.management.base import BaseCommand, CommandError

Check warning on line 9 in awx/main/management/commands/run_dispatcher.py

View check run for this annotation

Codecov / codecov/patch

awx/main/management/commands/run_dispatcher.py#L9

Added line #L9 was not covered by tests

from awx.main.dispatch import get_task_queuename
from awx.main.dispatch.control import Control
Expand Down Expand Up @@ -63,7 +65,10 @@ def handle(self, *arg, **options):

consumer = None

DispatcherMetricsServer().start()
try:
DispatcherMetricsServer().start()
except redis.exceptions.ConnectionError as exc:
raise CommandError(f'Dispatcher could not connect to redis, error: {exc}')

Check warning on line 71 in awx/main/management/commands/run_dispatcher.py

View check run for this annotation

Codecov / codecov/patch

awx/main/management/commands/run_dispatcher.py#L68-L71

Added lines #L68 - L71 were not covered by tests

try:
queues = ['tower_broadcast_all', 'tower_settings_change', get_task_queuename()]
Expand Down

0 comments on commit d9b6e0f

Please sign in to comment.