When saving JobEvents, include job_created

* this is the partition key
* .. used to determine which partition job event rows are sent to
This commit is contained in:
Jim Ladd
2021-02-10 20:23:44 -08:00
parent 2f737f644f
commit c0d38e91f5
2 changed files with 19 additions and 5 deletions

View File

@@ -781,6 +781,7 @@ class BaseTask(object):
self.parent_workflow_job_id = None
self.host_map = {}
self.guid = GuidMiddleware.get_guid()
self.job_created = None
def update_model(self, pk, _attempt=0, **updates):
"""Reload the model instance from the database and update the
@@ -1158,6 +1159,10 @@ class BaseTask(object):
event_data.pop('parent_uuid', None)
if self.parent_workflow_job_id:
event_data['workflow_job_id'] = self.parent_workflow_job_id
# Do we have to check if the field exists? if it doesn't
# how will be eventually store the event in the db?
if self.job_created:
event_data['job_created'] = self.job_created
if self.host_map:
host = event_data.get('event_data', {}).get('host', '').strip()
if host:
@@ -1283,6 +1288,10 @@ class BaseTask(object):
if self.instance.spawned_by_workflow:
self.parent_workflow_job_id = self.instance.get_workflow_job().id
# TODO: can we count on instance always having created?
# If we can't how can we store the job_event?
self.job_created = self.instance.created
try:
self.instance.send_notification_templates("running")
private_data_dir = self.build_private_data_dir(self.instance)