mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-25 01:11:48 -05:00
Merge pull request #3534 from ryanpetrello/iso-pexpect-cleanup
replace our usage of pexpect in IsolatedManager with ansible-runner Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
# Python
|
||||
from collections import OrderedDict, namedtuple
|
||||
import errno
|
||||
import fnmatch
|
||||
import functools
|
||||
import importlib
|
||||
import json
|
||||
@@ -467,7 +466,7 @@ def awx_isolated_heartbeat():
|
||||
# Slow pass looping over isolated IGs and their isolated instances
|
||||
if len(isolated_instance_qs) > 0:
|
||||
logger.debug("Managing isolated instances {}.".format(','.join([inst.hostname for inst in isolated_instance_qs])))
|
||||
isolated_manager.IsolatedManager.health_check(isolated_instance_qs, awx_application_version)
|
||||
isolated_manager.IsolatedManager().health_check(isolated_instance_qs)
|
||||
|
||||
|
||||
@task()
|
||||
@@ -884,12 +883,8 @@ class BaseTask(object):
|
||||
raise RuntimeError(
|
||||
'a valid Python virtualenv does not exist at {}'.format(venv_path)
|
||||
)
|
||||
env.pop('PYTHONPATH', None) # default to none if no python_ver matches
|
||||
for version in os.listdir(venv_libdir):
|
||||
if fnmatch.fnmatch(version, 'python[23].*'):
|
||||
if os.path.isdir(os.path.join(venv_libdir, version)):
|
||||
env['PYTHONPATH'] = os.path.join(venv_libdir, version, "site-packages") + ":"
|
||||
break
|
||||
|
||||
isolated_manager.set_pythonpath(venv_libdir, env)
|
||||
|
||||
def add_awx_venv(self, env):
|
||||
env['VIRTUAL_ENV'] = settings.AWX_VENV_PATH
|
||||
@@ -965,9 +960,6 @@ class BaseTask(object):
|
||||
def build_credentials_list(self, instance):
|
||||
return []
|
||||
|
||||
def get_idle_timeout(self):
|
||||
return None
|
||||
|
||||
def get_instance_timeout(self, instance):
|
||||
global_timeout_setting_name = instance._global_timeout_setting()
|
||||
if global_timeout_setting_name:
|
||||
@@ -1168,7 +1160,6 @@ class BaseTask(object):
|
||||
'finished_callback': self.finished_callback,
|
||||
'status_handler': self.status_handler,
|
||||
'settings': {
|
||||
'idle_timeout': self.get_idle_timeout() or "",
|
||||
'job_timeout': self.get_instance_timeout(self.instance),
|
||||
'pexpect_timeout': getattr(settings, 'PEXPECT_TIMEOUT', 5),
|
||||
**process_isolation_params,
|
||||
@@ -1206,10 +1197,7 @@ class BaseTask(object):
|
||||
copy_tree(cwd, os.path.join(private_data_dir, 'project'))
|
||||
ansible_runner.utils.dump_artifacts(params)
|
||||
manager_instance = isolated_manager.IsolatedManager(
|
||||
env,
|
||||
cancelled_callback=lambda: self.update_model(self.instance.pk).cancel_flag,
|
||||
job_timeout=self.get_instance_timeout(self.instance),
|
||||
idle_timeout=self.get_idle_timeout(),
|
||||
cancelled_callback=lambda: self.update_model(self.instance.pk).cancel_flag
|
||||
)
|
||||
status, rc = manager_instance.run(self.instance,
|
||||
private_data_dir,
|
||||
@@ -1230,7 +1218,6 @@ class BaseTask(object):
|
||||
extra_update_fields['job_explanation'] = self.instance.job_explanation
|
||||
|
||||
except Exception:
|
||||
# run_pexpect does not throw exceptions for cancel or timeout
|
||||
# this could catch programming or file system errors
|
||||
tb = traceback.format_exc()
|
||||
logger.exception('%s Exception occurred while running task', self.instance.log_format)
|
||||
@@ -1514,9 +1501,6 @@ class RunJob(BaseTask):
|
||||
def build_credentials_list(self, job):
|
||||
return job.credentials.all()
|
||||
|
||||
def get_idle_timeout(self):
|
||||
return getattr(settings, 'JOB_RUN_IDLE_TIMEOUT', None)
|
||||
|
||||
def get_password_prompts(self, passwords={}):
|
||||
d = super(RunJob, self).get_password_prompts(passwords)
|
||||
d[r'Enter passphrase for .*:\s*?$'] = 'ssh_key_unlock'
|
||||
@@ -1790,9 +1774,6 @@ class RunProjectUpdate(BaseTask):
|
||||
d[r'^Are you sure you want to continue connecting \(yes/no\)\?\s*?$'] = 'yes'
|
||||
return d
|
||||
|
||||
def get_idle_timeout(self):
|
||||
return getattr(settings, 'PROJECT_UPDATE_IDLE_TIMEOUT', None)
|
||||
|
||||
def _update_dependent_inventories(self, project_update, dependent_inventory_sources):
|
||||
scm_revision = project_update.project.scm_revision
|
||||
inv_update_class = InventoryUpdate._get_task_class()
|
||||
@@ -2151,9 +2132,6 @@ class RunInventoryUpdate(BaseTask):
|
||||
# All credentials not used by inventory source injector
|
||||
return inventory_update.get_extra_credentials()
|
||||
|
||||
def get_idle_timeout(self):
|
||||
return getattr(settings, 'INVENTORY_UPDATE_IDLE_TIMEOUT', None)
|
||||
|
||||
def pre_run_hook(self, inventory_update):
|
||||
source_project = None
|
||||
if inventory_update.inventory_source:
|
||||
@@ -2341,9 +2319,6 @@ class RunAdHocCommand(BaseTask):
|
||||
def build_playbook_path_relative_to_cwd(self, job, private_data_dir):
|
||||
return None
|
||||
|
||||
def get_idle_timeout(self):
|
||||
return getattr(settings, 'JOB_RUN_IDLE_TIMEOUT', None)
|
||||
|
||||
def get_password_prompts(self, passwords={}):
|
||||
d = super(RunAdHocCommand, self).get_password_prompts()
|
||||
d[r'Enter passphrase for .*:\s*?$'] = 'ssh_key_unlock'
|
||||
|
||||
Reference in New Issue
Block a user