mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
switched to using the built in task processing
Signed-off-by: Jessica Mack <jmack@redhat.com>
This commit is contained in:
parent
9f959ca3d4
commit
cb31973d59
@ -1,9 +1,9 @@
|
||||
import logging
|
||||
import json
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.cache import cache
|
||||
from awx.main.dispatch import pg_bus_conn
|
||||
from awx.conf import settings_registry
|
||||
from awx.main.dispatch.worker.task import TaskWorker
|
||||
|
||||
logger = logging.getLogger('awx.main.cache_clear')
|
||||
|
||||
@ -22,16 +22,12 @@ class Command(BaseCommand):
|
||||
conn.listen("tower_settings_change")
|
||||
for e in conn.events(yield_timeouts=True):
|
||||
if e is not None:
|
||||
logger.info("Cache clear request received. Clearing now")
|
||||
# clear the cache of the keys in the payload
|
||||
setting_keys = e.payload
|
||||
orig_len = len(setting_keys)
|
||||
for i in range(orig_len):
|
||||
for dependent_key in settings_registry.get_dependent_settings(setting_keys[i]):
|
||||
setting_keys.append(dependent_key)
|
||||
cache_keys = set(setting_keys)
|
||||
logger.info('cache delete_many(%r)', cache_keys)
|
||||
cache.delete_many(cache_keys)
|
||||
body = json.loads(e.payload)
|
||||
logger.warning(f"Cache clear request received. Clearing now, payload: {e.payload}")
|
||||
TaskWorker.run_callable(body)
|
||||
else:
|
||||
logger.info('run_clear_cache got timeout')
|
||||
|
||||
except Exception:
|
||||
# Log unanticipated exception in addition to writing to stderr to get timestamps and other metadata
|
||||
logger.exception('Encountered unhandled error in cache clear main loop')
|
||||
|
||||
@ -242,8 +242,8 @@ def apply_cluster_membership_policies():
|
||||
|
||||
@task(queue='tower_settings_change')
|
||||
def clear_setting_cache(setting_keys):
|
||||
# notify the service to clear the cache
|
||||
send_pg_notify('tower_settings_change', setting_keys)
|
||||
# log that cache is being cleared
|
||||
logger.info(f"clear_setting_cache of keys {setting_keys}")
|
||||
|
||||
|
||||
@task(queue='tower_broadcast_all')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user