mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 02:19:58 -03:30
record the parent WFJ ID for job events that originate from a WFJT
This commit is contained in:
parent
60fc952716
commit
b5225bd80d
@ -324,7 +324,10 @@ class BasePlaybookEvent(CreatedModifiedModel):
|
||||
kwargs.pop('created', None)
|
||||
|
||||
sanitize_event_keys(kwargs, cls.VALID_KEYS)
|
||||
workflow_job_id = kwargs.pop('workflow_job_id', None)
|
||||
job_event = cls.objects.create(**kwargs)
|
||||
if workflow_job_id:
|
||||
setattr(job_event, 'workflow_job_id', workflow_job_id)
|
||||
analytics_logger.info('Event data saved.', extra=dict(python_objects=dict(job_event=job_event)))
|
||||
return job_event
|
||||
|
||||
@ -396,7 +399,7 @@ class JobEvent(BasePlaybookEvent):
|
||||
An event/message logged from the callback when running a job.
|
||||
'''
|
||||
|
||||
VALID_KEYS = BasePlaybookEvent.VALID_KEYS + ['job_id']
|
||||
VALID_KEYS = BasePlaybookEvent.VALID_KEYS + ['job_id', 'workflow_job_id']
|
||||
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
@ -530,7 +533,7 @@ class JobEvent(BasePlaybookEvent):
|
||||
|
||||
class ProjectUpdateEvent(BasePlaybookEvent):
|
||||
|
||||
VALID_KEYS = BasePlaybookEvent.VALID_KEYS + ['project_update_id']
|
||||
VALID_KEYS = BasePlaybookEvent.VALID_KEYS + ['project_update_id', 'workflow_job_id']
|
||||
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
@ -639,7 +642,7 @@ class BaseCommandEvent(CreatedModifiedModel):
|
||||
|
||||
class AdHocCommandEvent(BaseCommandEvent):
|
||||
|
||||
VALID_KEYS = BaseCommandEvent.VALID_KEYS + ['ad_hoc_command_id', 'event']
|
||||
VALID_KEYS = BaseCommandEvent.VALID_KEYS + ['ad_hoc_command_id', 'event', 'workflow_job_id']
|
||||
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
@ -747,7 +750,7 @@ class AdHocCommandEvent(BaseCommandEvent):
|
||||
|
||||
class InventoryUpdateEvent(BaseCommandEvent):
|
||||
|
||||
VALID_KEYS = BaseCommandEvent.VALID_KEYS + ['inventory_update_id']
|
||||
VALID_KEYS = BaseCommandEvent.VALID_KEYS + ['inventory_update_id', 'workflow_job_id']
|
||||
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
|
||||
@ -704,6 +704,7 @@ class BaseTask(object):
|
||||
|
||||
def __init__(self):
|
||||
self.cleanup_paths = []
|
||||
self.parent_workflow_job_id = None
|
||||
|
||||
def update_model(self, pk, _attempt=0, **updates):
|
||||
"""Reload the model instance from the database and update the
|
||||
@ -1069,6 +1070,8 @@ class BaseTask(object):
|
||||
if event_data.get(self.event_data_key, None):
|
||||
if self.event_data_key != 'job_id':
|
||||
event_data.pop('parent_uuid', None)
|
||||
if self.parent_workflow_job_id:
|
||||
event_data['workflow_job_id'] = self.parent_workflow_job_id
|
||||
should_write_event = False
|
||||
event_data.setdefault(self.event_data_key, self.instance.id)
|
||||
self.dispatcher.dispatch(event_data)
|
||||
@ -1158,6 +1161,11 @@ class BaseTask(object):
|
||||
private_data_dir = None
|
||||
isolated_manager_instance = None
|
||||
|
||||
# store a reference to the parent workflow job (if any) so we can include
|
||||
# it in event data JSON
|
||||
if self.instance.spawned_by_workflow:
|
||||
self.parent_workflow_job_id = self.instance.get_workflow_job().id
|
||||
|
||||
try:
|
||||
isolated = self.instance.is_isolated()
|
||||
self.instance.send_notification_templates("running")
|
||||
|
||||
@ -184,6 +184,8 @@ class LogstashFormatter(LogstashFormatterBase):
|
||||
data_for_log[key] = 'Exception `{}` producing field'.format(e)
|
||||
|
||||
data_for_log['event_display'] = job_event.get_event_display2()
|
||||
if hasattr(job_event, 'workflow_job_id'):
|
||||
data_for_log['workflow_job_id'] = job_event.workflow_job_id
|
||||
|
||||
elif kind == 'system_tracking':
|
||||
data.pop('ansible_python_version', None)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user