From 892ca98709ff887b0c58bd94cca1393aebff8daf Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Wed, 20 Sep 2017 09:41:19 -0400 Subject: [PATCH] set execution_node right when jobs are accepted --- awx/main/scheduler/__init__.py | 2 ++ awx/main/tasks.py | 12 +++++------- awx/main/tests/unit/test_tasks.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/awx/main/scheduler/__init__.py b/awx/main/scheduler/__init__.py index 549f1546f3..821cdcc537 100644 --- a/awx/main/scheduler/__init__.py +++ b/awx/main/scheduler/__init__.py @@ -495,6 +495,8 @@ class TaskManager(): - instance is reported as down, then fail all jobs on the node - instance is an isolated node, then check running tasks 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() diff --git a/awx/main/tasks.py b/awx/main/tasks.py index f583d56c14..4dc4873e51 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -769,7 +769,10 @@ class BaseTask(LogErrorsTask): ''' 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") status, rc, tb = 'error', None, '' @@ -856,12 +859,7 @@ class BaseTask(LogErrorsTask): pexpect_timeout=getattr(settings, 'PEXPECT_TIMEOUT', 5), proot_cmd=getattr(settings, 'AWX_PROOT_CMD', 'bwrap'), ) - execution_node = settings.CLUSTER_HOST_ID - 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) + instance = self.update_model(instance.pk, output_replacements=output_replacements) if isolated_host: manager_instance = isolated_manager.IsolatedManager( args, cwd, env, stdout_handle, ssh_key_path, **_kw diff --git a/awx/main/tests/unit/test_tasks.py b/awx/main/tests/unit/test_tasks.py index 7070f59b34..8cb748eb30 100644 --- a/awx/main/tests/unit/test_tasks.py +++ b/awx/main/tests/unit/test_tasks.py @@ -259,7 +259,7 @@ class TestGenericRun(TestJobExecution): with pytest.raises(Exception): self.task.run(self.pk) 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') ]: assert c in self.task.update_model.call_args_list