mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 07:26:03 -03:30
add a per-request GUID and log as it travels through background services
see: https://github.com/ansible/awx/issues/9329
This commit is contained in:
@@ -9,6 +9,7 @@ from django.conf import settings
|
||||
from django.utils.timezone import now as tz_now
|
||||
from django.db import DatabaseError, OperationalError, connection as django_connection
|
||||
from django.db.utils import InterfaceError, InternalError
|
||||
from django_guid.middleware import GuidMiddleware
|
||||
|
||||
import psutil
|
||||
|
||||
@@ -152,6 +153,8 @@ class CallbackBrokerWorker(BaseWorker):
|
||||
|
||||
if body.get('event') == 'EOF':
|
||||
try:
|
||||
if 'guid' in body:
|
||||
GuidMiddleware.set_guid(body['guid'])
|
||||
final_counter = body.get('final_counter', 0)
|
||||
logger.info('Event processing is finished for Job {}, sending notifications'.format(job_identifier))
|
||||
# EOF events are sent when stdout for the running task is
|
||||
@@ -176,6 +179,8 @@ class CallbackBrokerWorker(BaseWorker):
|
||||
handle_success_and_failure_notifications.apply_async([uj.id])
|
||||
except Exception:
|
||||
logger.exception('Worker failed to emit notifications: Job {}'.format(job_identifier))
|
||||
finally:
|
||||
GuidMiddleware.set_guid('')
|
||||
return
|
||||
|
||||
event = cls.create_from_data(**body)
|
||||
|
||||
Reference in New Issue
Block a user