Prevent a race condition when writing the rsyslog.conf

This commit is contained in:
Christian Adams 2020-05-05 15:38:26 -04:00
parent c565130b35
commit e41d33991a
2 changed files with 5 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import socket
from socket import SHUT_RDWR
# Django
from django.db import connection
from django.conf import settings
from django.http import Http404
from django.utils.translation import ugettext_lazy as _
@ -130,7 +131,8 @@ class SettingSingletonDetail(RetrieveUpdateDestroyAPIView):
setting.save(update_fields=['value'])
settings_change_list.append(key)
if settings_change_list:
handle_setting_changes.delay(settings_change_list)
connection.on_commit(lambda: handle_setting_changes.delay(settings_change_list))
def destroy(self, request, *args, **kwargs):
instance = self.get_object()
@ -145,7 +147,7 @@ class SettingSingletonDetail(RetrieveUpdateDestroyAPIView):
setting.delete()
settings_change_list.append(setting.key)
if settings_change_list:
handle_setting_changes.delay(settings_change_list)
connection.on_commit(lambda: handle_setting_changes.delay(settings_change_list))
# When TOWER_URL_BASE is deleted from the API, reset it to the hostname
# used to make the request as a default.

View File

@ -288,7 +288,7 @@ def handle_setting_changes(setting_keys):
setting.startswith('LOG_AGGREGATOR')
for setting in setting_keys
]):
connection.on_commit(reconfigure_rsyslog)
reconfigure_rsyslog()
@task(queue='tower_broadcast_all')