Convert job_created to string for serialization

This commit is contained in:
Jim Ladd 2021-02-10 20:35:37 -08:00
parent c0d38e91f5
commit 1af1a5e9da
2 changed files with 11 additions and 1 deletions

View File

@ -423,6 +423,16 @@ class BasePlaybookEvent(CreatedModifiedModel):
except (KeyError, ValueError):
kwargs.pop('created', None)
# same as above, for job_created
# TODO: if this approach, identical to above, works, can convert to for loop
try:
if not isinstance(kwargs['job_created'], datetime.datetime):
kwargs['job_created'] = parse_datetime(kwargs['job_created'])
if not kwargs['job_created'].tzinfo:
kwargs['job_created'] = kwargs['job_created'].replace(tzinfo=utc)
except (KeyError, ValueError):
kwargs.pop('job_created', None)
host_map = kwargs.pop('host_map', {})
sanitize_event_keys(kwargs, cls.VALID_KEYS)

View File

@ -1290,7 +1290,7 @@ class BaseTask(object):
# 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
self.job_created = str(self.instance.created)
try:
self.instance.send_notification_templates("running")