1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

set execution_node right when jobs are accepted

This commit is contained in:
AlanCoding 2017-09-20 09:41:19 -04:00
parent c868f7e91f
commit 892ca98709
No known key found for this signature in database
GPG Key ID: FD2C3C012A72926B
3 changed files with 8 additions and 8 deletions

View File

@ -495,6 +495,8 @@ class TaskManager():
- instance is reported as down, then fail all jobs on the node - instance is reported as down, then fail all jobs on the node
- instance is an isolated node, then check running tasks - instance is an isolated node, then check running tasks
among all allowed controller nodes for management process among all allowed controller nodes for management process
- valid healthy instance not included in celery task list
probably a netsplit case, leave it alone
''' '''
instance = Instance.objects.filter(hostname=node).first() instance = Instance.objects.filter(hostname=node).first()

View File

@ -769,7 +769,10 @@ class BaseTask(LogErrorsTask):
''' '''
Run the job/task and capture its output. Run the job/task and capture its output.
''' '''
instance = self.update_model(pk, status='running') execution_node = settings.CLUSTER_HOST_ID
if isolated_host is not None:
execution_node = isolated_host
instance = self.update_model(pk, status='running', execution_node=execution_node)
instance.websocket_emit_status("running") instance.websocket_emit_status("running")
status, rc, tb = 'error', None, '' status, rc, tb = 'error', None, ''
@ -856,12 +859,7 @@ class BaseTask(LogErrorsTask):
pexpect_timeout=getattr(settings, 'PEXPECT_TIMEOUT', 5), pexpect_timeout=getattr(settings, 'PEXPECT_TIMEOUT', 5),
proot_cmd=getattr(settings, 'AWX_PROOT_CMD', 'bwrap'), proot_cmd=getattr(settings, 'AWX_PROOT_CMD', 'bwrap'),
) )
execution_node = settings.CLUSTER_HOST_ID instance = self.update_model(instance.pk, output_replacements=output_replacements)
if isolated_host is not None:
execution_node = isolated_host
instance = self.update_model(instance.pk, status='running',
execution_node=execution_node,
output_replacements=output_replacements)
if isolated_host: if isolated_host:
manager_instance = isolated_manager.IsolatedManager( manager_instance = isolated_manager.IsolatedManager(
args, cwd, env, stdout_handle, ssh_key_path, **_kw args, cwd, env, stdout_handle, ssh_key_path, **_kw

View File

@ -259,7 +259,7 @@ class TestGenericRun(TestJobExecution):
with pytest.raises(Exception): with pytest.raises(Exception):
self.task.run(self.pk) self.task.run(self.pk)
for c in [ for c in [
mock.call(self.pk, status='running'), mock.call(self.pk, execution_node=settings.CLUSTER_HOST_ID, status='running'),
mock.call(self.pk, output_replacements=[], result_traceback=mock.ANY, status='canceled') mock.call(self.pk, output_replacements=[], result_traceback=mock.ANY, status='canceled')
]: ]:
assert c in self.task.update_model.call_args_list assert c in self.task.update_model.call_args_list