mirror of
https://github.com/ZwareBear/awx.git
synced 2026-03-20 07:43:35 -05:00
Merge pull request #13548 from jessicamack/update_rsyslog
[web-task-split] Update rsyslog_configurer to use the built in Task functionality
This commit is contained in:
@@ -30,7 +30,7 @@ from awx.main.tasks.system import clear_setting_cache
|
|||||||
from awx.conf.models import Setting
|
from awx.conf.models import Setting
|
||||||
from awx.conf.serializers import SettingCategorySerializer, SettingSingletonSerializer
|
from awx.conf.serializers import SettingCategorySerializer, SettingSingletonSerializer
|
||||||
from awx.conf import settings_registry
|
from awx.conf import settings_registry
|
||||||
from awx.main.utils.external_logging import send_pg_notify
|
from awx.main.utils.external_logging import reconfigure_rsyslog
|
||||||
|
|
||||||
|
|
||||||
SettingCategory = collections.namedtuple('SettingCategory', ('url', 'slug', 'name'))
|
SettingCategory = collections.namedtuple('SettingCategory', ('url', 'slug', 'name'))
|
||||||
@@ -122,7 +122,7 @@ class SettingSingletonDetail(RetrieveUpdateDestroyAPIView):
|
|||||||
connection.on_commit(lambda: clear_setting_cache.delay(settings_change_list))
|
connection.on_commit(lambda: clear_setting_cache.delay(settings_change_list))
|
||||||
if any([setting.startswith('LOG_AGGREGATOR') for setting in settings_change_list]):
|
if any([setting.startswith('LOG_AGGREGATOR') for setting in settings_change_list]):
|
||||||
# call notify to rsyslog. no data is need so payload is empty
|
# call notify to rsyslog. no data is need so payload is empty
|
||||||
send_pg_notify('rsyslog_configurer', "")
|
reconfigure_rsyslog.delay()
|
||||||
|
|
||||||
def destroy(self, request, *args, **kwargs):
|
def destroy(self, request, *args, **kwargs):
|
||||||
instance = self.get_object()
|
instance = self.get_object()
|
||||||
@@ -140,7 +140,7 @@ class SettingSingletonDetail(RetrieveUpdateDestroyAPIView):
|
|||||||
connection.on_commit(lambda: clear_setting_cache.delay(settings_change_list))
|
connection.on_commit(lambda: clear_setting_cache.delay(settings_change_list))
|
||||||
if any([setting.startswith('LOG_AGGREGATOR') for setting in settings_change_list]):
|
if any([setting.startswith('LOG_AGGREGATOR') for setting in settings_change_list]):
|
||||||
# call notify to rsyslog. no data is need so payload is empty
|
# call notify to rsyslog. no data is need so payload is empty
|
||||||
send_pg_notify('rsyslog_configurer', "")
|
reconfigure_rsyslog.delay()
|
||||||
|
|
||||||
# When TOWER_URL_BASE is deleted from the API, reset it to the hostname
|
# When TOWER_URL_BASE is deleted from the API, reset it to the hostname
|
||||||
# used to make the request as a default.
|
# used to make the request as a default.
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class Command(BaseCommand):
|
|||||||
consumer = None
|
consumer = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
queues = ['tower_broadcast_all', get_local_queuename()]
|
queues = ['tower_broadcast_all', 'rsyslog_configurer', get_local_queuename()]
|
||||||
consumer = AWXConsumerPG('dispatcher', TaskWorker(), queues, AutoscalePool(min_workers=4))
|
consumer = AWXConsumerPG('dispatcher', TaskWorker(), queues, AutoscalePool(min_workers=4))
|
||||||
consumer.run()
|
consumer.run()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import json
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from awx.main.dispatch import pg_bus_conn
|
from awx.main.dispatch import pg_bus_conn
|
||||||
|
from awx.main.dispatch.worker.task import TaskWorker
|
||||||
from awx.main.utils.external_logging import reconfigure_rsyslog
|
from awx.main.utils.external_logging import reconfigure_rsyslog
|
||||||
|
|
||||||
logger = logging.getLogger('awx.main.rsyslog_configurer')
|
logger = logging.getLogger('awx.main.rsyslog_configurer')
|
||||||
@@ -31,7 +33,8 @@ class Command(BaseCommand):
|
|||||||
setting_keys = [k for k in dir(settings) if k.startswith('LOG_AGGREGATOR')]
|
setting_keys = [k for k in dir(settings) if k.startswith('LOG_AGGREGATOR')]
|
||||||
cache.delete_many(setting_keys)
|
cache.delete_many(setting_keys)
|
||||||
settings._awx_conf_memoizedcache.clear()
|
settings._awx_conf_memoizedcache.clear()
|
||||||
reconfigure_rsyslog()
|
body = json.loads(e.payload)
|
||||||
|
TaskWorker.run_callable(body)
|
||||||
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 rsyslog_configurer main loop')
|
logger.exception('Encountered unhandled error in rsyslog_configurer main loop')
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import urllib.parse as urlparse
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from awx.main.utils.reload import supervisor_service_command
|
from awx.main.utils.reload import supervisor_service_command
|
||||||
|
from awx.main.dispatch.publish import task
|
||||||
from awx.main.dispatch import pg_bus_conn
|
from awx.main.dispatch import pg_bus_conn
|
||||||
|
|
||||||
|
|
||||||
@@ -115,6 +116,7 @@ def construct_rsyslog_conf_template(settings=settings):
|
|||||||
return tmpl
|
return tmpl
|
||||||
|
|
||||||
|
|
||||||
|
@task(queue='rsyslog_configurer')
|
||||||
def reconfigure_rsyslog():
|
def reconfigure_rsyslog():
|
||||||
tmpl = construct_rsyslog_conf_template()
|
tmpl = construct_rsyslog_conf_template()
|
||||||
# Write config to a temp file then move it to preserve atomicity
|
# Write config to a temp file then move it to preserve atomicity
|
||||||
|
|||||||
Reference in New Issue
Block a user