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