mirror of
https://github.com/ansible/awx.git
synced 2026-03-27 05:45:02 -02:30
move legacy UnifiedJob stdout data to a separate unmanaged model
This data often (in the case of inventory updates) represents large data blobs (5+MB per job run). Storing it on the polymorphic base class table, `main_unifiedjob`, causes it to be automatically fetched on every query (and every polymorphic join) against that table, which can result in _very_ poor performance for awx across the board. Django offers `defer()`, but it's quite complicated to sprinkle this everywhere (and easy to get wrong/introduce side effects related to our RBAC and usage of polymorphism). This change moves the field definition to a separate unmanaged model (which references the same underlying `main_unifiedjob` table) and adds a proxy for fetching the data as needed see https://github.com/ansible/awx/issues/200
This commit is contained in:
@@ -145,17 +145,3 @@ activity_stream_registrar.connect(WorkflowJob)
|
||||
|
||||
# prevent API filtering on certain Django-supplied sensitive fields
|
||||
prevent_search(User._meta.get_field('password'))
|
||||
|
||||
|
||||
# Always, always, always defer result_stdout_text for polymorphic UnifiedJob rows
|
||||
# TODO: remove this defer in 3.3 when we implement https://github.com/ansible/ansible-tower/issues/5436
|
||||
def defer_stdout(f):
|
||||
def _wrapped(*args, **kwargs):
|
||||
objs = f(*args, **kwargs)
|
||||
objs.query.deferred_loading[0].add('result_stdout_text')
|
||||
return objs
|
||||
return _wrapped
|
||||
|
||||
|
||||
for cls in UnifiedJob.__subclasses__():
|
||||
cls.base_objects.filter = defer_stdout(cls.base_objects.filter)
|
||||
|
||||
Reference in New Issue
Block a user