mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 23:07:42 -02:30
celery 4.x -> 3.x change route config name
This commit is contained in:
@@ -213,7 +213,7 @@ def handle_ha_toplogy_changes(self):
|
|||||||
.format(instance.hostname, removed_queues, added_queues))
|
.format(instance.hostname, removed_queues, added_queues))
|
||||||
updated_routes = update_celery_worker_routes(instance, settings)
|
updated_routes = update_celery_worker_routes(instance, settings)
|
||||||
logger.info("Worker on tower node '{}' updated celery routes {} all routes are now {}"
|
logger.info("Worker on tower node '{}' updated celery routes {} all routes are now {}"
|
||||||
.format(instance.hostname, updated_routes, self.app.conf.CELERY_TASK_ROUTES))
|
.format(instance.hostname, updated_routes, self.app.conf.CELERY_ROUTES))
|
||||||
|
|
||||||
|
|
||||||
@worker_ready.connect
|
@worker_ready.connect
|
||||||
@@ -232,7 +232,7 @@ def handle_update_celery_routes(sender=None, conf=None, **kwargs):
|
|||||||
instance = Instance.objects.me()
|
instance = Instance.objects.me()
|
||||||
added_routes = update_celery_worker_routes(instance, conf)
|
added_routes = update_celery_worker_routes(instance, conf)
|
||||||
logger.info("Workers on tower node '{}' added routes {} all routes are now {}"
|
logger.info("Workers on tower node '{}' added routes {} all routes are now {}"
|
||||||
.format(instance.hostname, added_routes, conf.CELERY_TASK_ROUTES))
|
.format(instance.hostname, added_routes, conf.CELERY_ROUTES))
|
||||||
|
|
||||||
|
|
||||||
@celeryd_after_setup.connect
|
@celeryd_after_setup.connect
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ def celery_memory_broker():
|
|||||||
|
|
||||||
Allows django signal code to execute without the need for redis
|
Allows django signal code to execute without the need for redis
|
||||||
'''
|
'''
|
||||||
settings.CELERY_BROKER_URL='memory://localhost/'
|
settings.BROKER_URL='memory://localhost/'
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ from datetime import timedelta
|
|||||||
('admin_checks', 'awx.main.tasks.run_administrative_checks'),
|
('admin_checks', 'awx.main.tasks.run_administrative_checks'),
|
||||||
('tower_scheduler', 'awx.main.tasks.awx_periodic_scheduler'),
|
('tower_scheduler', 'awx.main.tasks.awx_periodic_scheduler'),
|
||||||
])
|
])
|
||||||
def test_CELERY_BEAT_SCHEDULE(mocker, job_name, function_path):
|
def test_CELERYBEAT_SCHEDULE(mocker, job_name, function_path):
|
||||||
assert job_name in settings.CELERY_BEAT_SCHEDULE
|
assert job_name in settings.CELERYBEAT_SCHEDULE
|
||||||
assert 'schedule' in settings.CELERY_BEAT_SCHEDULE[job_name]
|
assert 'schedule' in settings.CELERYBEAT_SCHEDULE[job_name]
|
||||||
assert type(settings.CELERY_BEAT_SCHEDULE[job_name]['schedule']) is timedelta
|
assert type(settings.CELERYBEAT_SCHEDULE[job_name]['schedule']) is timedelta
|
||||||
assert settings.CELERY_BEAT_SCHEDULE[job_name]['task'] == function_path
|
assert settings.CELERYBEAT_SCHEDULE[job_name]['task'] == function_path
|
||||||
|
|
||||||
# Ensures that the function exists
|
# Ensures that the function exists
|
||||||
mocker.patch(function_path)
|
mocker.patch(function_path)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from awx.main.utils.ha import (
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def conf():
|
def conf():
|
||||||
class Conf():
|
class Conf():
|
||||||
CELERY_TASK_ROUTES = dict()
|
CELERY_ROUTES = dict()
|
||||||
CELERYBEAT_SCHEDULE = dict()
|
CELERYBEAT_SCHEDULE = dict()
|
||||||
return Conf()
|
return Conf()
|
||||||
|
|
||||||
@@ -88,14 +88,14 @@ class TestUpdateCeleryWorkerRoutes():
|
|||||||
instance.is_controller = mocker.MagicMock(return_value=is_controller)
|
instance.is_controller = mocker.MagicMock(return_value=is_controller)
|
||||||
|
|
||||||
assert update_celery_worker_routes(instance, conf) == expected_routes
|
assert update_celery_worker_routes(instance, conf) == expected_routes
|
||||||
assert conf.CELERY_TASK_ROUTES == expected_routes
|
assert conf.CELERY_ROUTES == expected_routes
|
||||||
|
|
||||||
def test_update_celery_worker_routes_deleted(self, mocker, conf):
|
def test_update_celery_worker_routes_deleted(self, mocker, conf):
|
||||||
instance = mocker.MagicMock()
|
instance = mocker.MagicMock()
|
||||||
instance.hostname = 'east-1'
|
instance.hostname = 'east-1'
|
||||||
instance.is_controller = mocker.MagicMock(return_value=False)
|
instance.is_controller = mocker.MagicMock(return_value=False)
|
||||||
conf.CELERY_TASK_ROUTES = {'awx.main.tasks.awx_isolated_heartbeat': 'foobar'}
|
conf.CELERY_ROUTES = {'awx.main.tasks.awx_isolated_heartbeat': 'foobar'}
|
||||||
|
|
||||||
update_celery_worker_routes(instance, conf)
|
update_celery_worker_routes(instance, conf)
|
||||||
assert 'awx.main.tasks.awx_isolated_heartbeat' not in conf.CELERY_TASK_ROUTES
|
assert 'awx.main.tasks.awx_isolated_heartbeat' not in conf.CELERY_ROUTES
|
||||||
|
|
||||||
|
|||||||
@@ -48,12 +48,12 @@ def update_celery_worker_routes(instance, conf):
|
|||||||
if instance.is_controller():
|
if instance.is_controller():
|
||||||
tasks.append('awx.main.tasks.awx_isolated_heartbeat')
|
tasks.append('awx.main.tasks.awx_isolated_heartbeat')
|
||||||
else:
|
else:
|
||||||
if 'awx.main.tasks.awx_isolated_heartbeat' in conf.CELERY_TASK_ROUTES:
|
if 'awx.main.tasks.awx_isolated_heartbeat' in conf.CELERY_ROUTES:
|
||||||
del conf.CELERY_TASK_ROUTES['awx.main.tasks.awx_isolated_heartbeat']
|
del conf.CELERY_ROUTES['awx.main.tasks.awx_isolated_heartbeat']
|
||||||
|
|
||||||
for t in tasks:
|
for t in tasks:
|
||||||
conf.CELERY_TASK_ROUTES[t] = {'queue': instance.hostname, 'routing_key': instance.hostname}
|
conf.CELERY_ROUTES[t] = {'queue': instance.hostname, 'routing_key': instance.hostname}
|
||||||
routes_updated[t] = conf.CELERY_TASK_ROUTES[t]
|
routes_updated[t] = conf.CELERY_ROUTES[t]
|
||||||
|
|
||||||
return routes_updated
|
return routes_updated
|
||||||
|
|
||||||
|
|||||||
@@ -453,7 +453,7 @@ CELERY_QUEUES = (
|
|||||||
Queue('tower', Exchange('tower'), routing_key='tower'),
|
Queue('tower', Exchange('tower'), routing_key='tower'),
|
||||||
Broadcast('tower_broadcast_all')
|
Broadcast('tower_broadcast_all')
|
||||||
)
|
)
|
||||||
CELERY_TASK_ROUTES = {}
|
CELERY_ROUTES = {}
|
||||||
|
|
||||||
CELERYBEAT_SCHEDULER = 'celery.beat.PersistentScheduler'
|
CELERYBEAT_SCHEDULER = 'celery.beat.PersistentScheduler'
|
||||||
CELERYBEAT_MAX_LOOP_INTERVAL = 60
|
CELERYBEAT_MAX_LOOP_INTERVAL = 60
|
||||||
|
|||||||
Reference in New Issue
Block a user