issue #400: add logic to work around AWX callback bug.

issue260
David Wilson 6 years ago
parent a7ee23719a
commit c9ecc82f85

@ -34,6 +34,7 @@ from __future__ import absolute_import
try:
from ansible.plugins.loader import action_loader
from ansible.plugins.loader import callback_loader
from ansible.plugins.loader import connection_loader
from ansible.plugins.loader import module_loader
from ansible.plugins.loader import module_utils_loader
@ -41,6 +42,7 @@ try:
from ansible.plugins.loader import strategy_loader
except ImportError: # Ansible <2.4
from ansible.plugins import action_loader
from ansible.plugins import callback_loader
from ansible.plugins import connection_loader
from ansible.plugins import module_loader
from ansible.plugins import module_utils_loader

@ -65,6 +65,29 @@ def wrap_connection_loader__get(name, *args, **kwargs):
return connection_loader__get(name, *args, **kwargs)
def patch_awx_callback():
"""
issue #400: AWX loads a display callback that suffers from thread-safety
issues. Detect the presence of older AWX versions and patch the bug.
"""
cls = ansible_mitogen.loaders.callback_loader.get(
'awx_display',
class_only=True,
)
if cls is None: # callback does not exist.
return
# Callback load will have updated sys.path. Now import its guts.
try:
from awx_display_callback.events import event_context
except ImportError:
return # Newer or ancient AWX.
# Executing this before starting additional threads avoids race.
with event_context.set_global():
pass
class StrategyMixin(object):
"""
This mix-in enhances any built-in strategy by arranging for various Mitogen
@ -164,6 +187,7 @@ class StrategyMixin(object):
ansible_mitogen.process.MuxProcess.start()
self._add_connection_plugin_path()
self._install_wrappers()
patch_awx_callback()
try:
return super(StrategyMixin, self).run(iterator, play_context)
finally:

Loading…
Cancel
Save