correct filter events on the migration event horizon

events that existed *prior* to the partition migration will have
`job_created=1970-01-01` auto-applied at migration time; as such,
queries for these events e.g., /api/v2/job/N/job_events/
use 1970-01-01 in related event searche

events created *after* the partition migration (net-new playbook runs
will have `job_created` values that *exactly match* the related
`UnifiedJob.created` field.
This commit is contained in:
Ryan Petrello
2021-02-25 17:51:29 -05:00
committed by Jim Ladd
parent 1e45e2ab9b
commit 08b96a0bd7
4 changed files with 41 additions and 11 deletions

View File

@@ -90,7 +90,7 @@ __all__ = [
'create_temporary_fifo',
'truncate_stdout',
'deepmerge',
'cleanup_new_process',
'get_event_partition_epoch',
]
@@ -208,6 +208,28 @@ def memoize_delete(function_name):
return cache.delete(function_name)
@memoize(ttl=3600 * 24) # in practice, we only need this to load once at process startup time
def get_event_partition_epoch():
from django.db.migrations.recorder import MigrationRecorder
return MigrationRecorder.Migration.objects.filter(
app='main', name='0124_event_partitions'
).first().applied
@memoize()
def get_ansible_version():
"""
Return Ansible version installed.
Ansible path needs to be provided to account for custom virtual environments
"""
try:
proc = subprocess.Popen(['ansible', '--version'], stdout=subprocess.PIPE)
result = smart_str(proc.communicate()[0])
return result.split('\n')[0].replace('ansible', '').strip()
except Exception:
return 'unknown'
def get_awx_version():
"""
Return AWX version as reported by setuptools.