diff --git a/awx/main/dispatch/__init__.py b/awx/main/dispatch/__init__.py index d368b7cc96..587a8219aa 100644 --- a/awx/main/dispatch/__init__.py +++ b/awx/main/dispatch/__init__.py @@ -1,7 +1,5 @@ import psycopg2 import select -import sys -import logging from contextlib import contextmanager @@ -9,10 +7,6 @@ from django.conf import settings NOT_READY = ([], [], []) -if 'run_callback_receiver' in sys.argv: - logger = logging.getLogger('awx.main.commands.run_callback_receiver') -else: - logger = logging.getLogger('awx.main.dispatch') def get_local_queuename(): @@ -36,25 +30,6 @@ class PubSub(object): with self.conn.cursor() as cur: cur.execute('SELECT pg_notify(%s, %s);', (channel, payload)) - def get_event(self, select_timeout=0): - # poll the connection, then return one event, if we have one. Else - # return None. - select.select([self.conn], [], [], select_timeout) - self.conn.poll() - if self.conn.notifies: - return self.conn.notifies.pop(0) - - def get_events(self, select_timeout=0): - # Poll the connection and return all events, if there are any. Else - # return None. - select.select([self.conn], [], [], select_timeout) # redundant? - self.conn.poll() - events = [] - while self.conn.notifies: - events.append(self.conn.notifies.pop(0)) - if events: - return events - def events(self, select_timeout=5, yield_timeouts=False): while True: if select.select([self.conn], [], [], select_timeout) == NOT_READY: diff --git a/awx/main/dispatch/control.py b/awx/main/dispatch/control.py index 4565df17f5..186acee5cf 100644 --- a/awx/main/dispatch/control.py +++ b/awx/main/dispatch/control.py @@ -1,6 +1,5 @@ import logging -import string -import random +import uuid import json from awx.main.dispatch import get_local_queuename @@ -21,10 +20,6 @@ class Control(object): self.service = service self.queuename = host or get_local_queuename() - def publish(self, msg, conn, **kwargs): - # TODO: delete this method?? - raise RuntimeError("Publish called?!") - def status(self, *args, **kwargs): return self.control_with_reply('status', *args, **kwargs) @@ -33,8 +28,7 @@ class Control(object): @classmethod def generate_reply_queue_name(cls): - letters = string.ascii_lowercase - return 'reply_to_{}'.format(''.join(random.choice(letters) for i in range(8))) + return f"reply_to_{str(uuid.uuid4()).replace('-','_')}" def control_with_reply(self, command, timeout=5): logger.warn('checking {} {} for {}'.format(self.service, command, self.queuename)) diff --git a/awx/main/dispatch/publish.py b/awx/main/dispatch/publish.py index 020e7407cd..f7fd7cf4fb 100644 --- a/awx/main/dispatch/publish.py +++ b/awx/main/dispatch/publish.py @@ -74,7 +74,7 @@ class task: getattr(cls.queue, 'im_func', cls.queue) ) if not queue: - msg = f'{cls.name}: Queue value required and may not me None' + msg = f'{cls.name}: Queue value required and may not be None' logger.error(msg) raise ValueError(msg) obj = { diff --git a/awx/main/managers.py b/awx/main/managers.py index ea65b36234..9f1537fd6f 100644 --- a/awx/main/managers.py +++ b/awx/main/managers.py @@ -126,7 +126,7 @@ class InstanceManager(models.Manager): instance = instance.get() if instance.ip_address != ip_address: instance.ip_address = ip_address - instance.save() + instance.save(update_fields=['ip_address']) return (True, instance) else: return (False, instance) diff --git a/awx/main/tests/functional/test_dispatch.py b/awx/main/tests/functional/test_dispatch.py index c13a031af3..aa3c42ce26 100644 --- a/awx/main/tests/functional/test_dispatch.py +++ b/awx/main/tests/functional/test_dispatch.py @@ -349,7 +349,7 @@ class TestTaskPublisher: def test_apply_async_queue_required(self): with pytest.raises(ValueError) as e: message, queue = add.apply_async([2, 2]) - assert "awx.main.tests.functional.test_dispatch.add: Queue value required and may not me None" == e.value.args[0] + assert "awx.main.tests.functional.test_dispatch.add: Queue value required and may not be None" == e.value.args[0] def test_queue_defined_in_task_decorator(self): message, queue = multiply.apply_async([2, 2])