mirror of
https://github.com/ansible/awx.git
synced 2026-02-24 06:26:00 -03:30
Merge pull request #169 from AlanCoding/isolated_verbose
provide the job id in isolated management logs
This commit is contained in:
@@ -175,7 +175,7 @@ class IsolatedManager(object):
|
|||||||
if self.instance.verbosity:
|
if self.instance.verbosity:
|
||||||
args.append('-%s' % ('v' * min(5, self.instance.verbosity)))
|
args.append('-%s' % ('v' * min(5, self.instance.verbosity)))
|
||||||
buff = StringIO.StringIO()
|
buff = StringIO.StringIO()
|
||||||
logger.debug('Starting job on isolated host with `run_isolated.yml` playbook.')
|
logger.debug('Starting job {} on isolated host with `run_isolated.yml` playbook.'.format(self.instance.id))
|
||||||
status, rc = IsolatedManager.run_pexpect(
|
status, rc = IsolatedManager.run_pexpect(
|
||||||
args, self.awx_playbook_path(), self.management_env, buff,
|
args, self.awx_playbook_path(), self.management_env, buff,
|
||||||
idle_timeout=self.idle_timeout,
|
idle_timeout=self.idle_timeout,
|
||||||
@@ -183,7 +183,7 @@ class IsolatedManager(object):
|
|||||||
pexpect_timeout=5
|
pexpect_timeout=5
|
||||||
)
|
)
|
||||||
output = buff.getvalue()
|
output = buff.getvalue()
|
||||||
playbook_logger.info('Job {} management started\n{}'.format(self.instance.id, output))
|
playbook_logger.info('Isolated job {} dispatch:\n{}'.format(self.instance.id, output))
|
||||||
if status != 'successful':
|
if status != 'successful':
|
||||||
self.stdout_handle.write(output)
|
self.stdout_handle.write(output)
|
||||||
return status, rc
|
return status, rc
|
||||||
@@ -300,7 +300,7 @@ class IsolatedManager(object):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
buff = cStringIO.StringIO()
|
buff = cStringIO.StringIO()
|
||||||
logger.debug('Checking job on isolated host with `check_isolated.yml` playbook.')
|
logger.debug('Checking on isolated job {} with `check_isolated.yml`.'.format(self.instance.id))
|
||||||
status, rc = IsolatedManager.run_pexpect(
|
status, rc = IsolatedManager.run_pexpect(
|
||||||
args, self.awx_playbook_path(), self.management_env, buff,
|
args, self.awx_playbook_path(), self.management_env, buff,
|
||||||
cancelled_callback=self.cancelled_callback,
|
cancelled_callback=self.cancelled_callback,
|
||||||
@@ -310,7 +310,7 @@ class IsolatedManager(object):
|
|||||||
proot_cmd=self.proot_cmd
|
proot_cmd=self.proot_cmd
|
||||||
)
|
)
|
||||||
output = buff.getvalue()
|
output = buff.getvalue()
|
||||||
playbook_logger.info(output)
|
playbook_logger.info('Isolated job {} check:\n{}'.format(self.instance.id, output))
|
||||||
|
|
||||||
path = self.path_to('artifacts', 'stdout')
|
path = self.path_to('artifacts', 'stdout')
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
@@ -350,7 +350,7 @@ class IsolatedManager(object):
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
args = self._build_args('clean_isolated.yml', '%s,' % self.host, extra_vars)
|
args = self._build_args('clean_isolated.yml', '%s,' % self.host, extra_vars)
|
||||||
logger.debug('Cleaning up job on isolated host with `clean_isolated.yml` playbook.')
|
logger.debug('Cleaning up job {} on isolated host with `clean_isolated.yml` playbook.'.format(self.instance.id))
|
||||||
buff = cStringIO.StringIO()
|
buff = cStringIO.StringIO()
|
||||||
timeout = max(60, 2 * settings.AWX_ISOLATED_CONNECTION_TIMEOUT)
|
timeout = max(60, 2 * settings.AWX_ISOLATED_CONNECTION_TIMEOUT)
|
||||||
status, rc = IsolatedManager.run_pexpect(
|
status, rc = IsolatedManager.run_pexpect(
|
||||||
@@ -359,11 +359,11 @@ class IsolatedManager(object):
|
|||||||
pexpect_timeout=5
|
pexpect_timeout=5
|
||||||
)
|
)
|
||||||
output = buff.getvalue()
|
output = buff.getvalue()
|
||||||
playbook_logger.info(output)
|
playbook_logger.info('Isolated job {} cleanup:\n{}'.format(self.instance.id, output))
|
||||||
|
|
||||||
if status != 'successful':
|
if status != 'successful':
|
||||||
# stdout_handle is closed by this point so writing output to logs is our only option
|
# stdout_handle is closed by this point so writing output to logs is our only option
|
||||||
logger.warning('Cleanup from isolated job encountered error, output:\n{}'.format(output))
|
logger.warning('Isolated job {} cleanup error, output:\n{}'.format(self.instance.id, output))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def health_check(cls, instance_qs):
|
def health_check(cls, instance_qs):
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ def test_check_isolated_job(private_data_dir, rsa_key):
|
|||||||
stdout = cStringIO.StringIO()
|
stdout = cStringIO.StringIO()
|
||||||
mgr = isolated_manager.IsolatedManager(['ls', '-la'], HERE, {}, stdout, '')
|
mgr = isolated_manager.IsolatedManager(['ls', '-la'], HERE, {}, stdout, '')
|
||||||
mgr.private_data_dir = private_data_dir
|
mgr.private_data_dir = private_data_dir
|
||||||
mgr.instance = mock.Mock(pk=123, verbosity=5, spec_set=['pk', 'verbosity'])
|
mgr.instance = mock.Mock(id=123, pk=123, verbosity=5, spec_set=['id', 'pk', 'verbosity'])
|
||||||
mgr.started_at = time.time()
|
mgr.started_at = time.time()
|
||||||
mgr.host = 'isolated-host'
|
mgr.host = 'isolated-host'
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ def test_check_isolated_job_timeout(private_data_dir, rsa_key):
|
|||||||
job_timeout=1,
|
job_timeout=1,
|
||||||
extra_update_fields=extra_update_fields)
|
extra_update_fields=extra_update_fields)
|
||||||
mgr.private_data_dir = private_data_dir
|
mgr.private_data_dir = private_data_dir
|
||||||
mgr.instance = mock.Mock(pk=123, verbosity=5, spec_set=['pk', 'verbosity'])
|
mgr.instance = mock.Mock(id=123, pk=123, verbosity=5, spec_set=['id', 'pk', 'verbosity'])
|
||||||
mgr.started_at = time.time()
|
mgr.started_at = time.time()
|
||||||
mgr.host = 'isolated-host'
|
mgr.host = 'isolated-host'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user