You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by st...@apache.org on 2017/02/06 14:55:25 UTC

ambari git commit: AMBARI-19846. ambari-agent.out getting filled with dummy traceback. (Attila Doroszlai via stoader)

Repository: ambari
Updated Branches:
  refs/heads/trunk e05e5296c -> df8c06ca7


AMBARI-19846. ambari-agent.out getting filled with dummy traceback. (Attila Doroszlai via stoader)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/df8c06ca
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/df8c06ca
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/df8c06ca

Branch: refs/heads/trunk
Commit: df8c06ca7cae9fe3af75e49d7a31e197d250ba9b
Parents: e05e529
Author: Attila Doroszlai <ad...@hortonworks.com>
Authored: Mon Feb 6 15:54:55 2017 +0100
Committer: Toader, Sebastian <st...@hortonworks.com>
Committed: Mon Feb 6 15:54:55 2017 +0100

----------------------------------------------------------------------
 .../ambari_agent/CustomServiceOrchestrator.py     | 12 ++++--------
 .../ambari_agent/TestCustomServiceOrchestrator.py | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/df8c06ca/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
index 9baaf08..e70c2d2 100644
--- a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
+++ b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
@@ -309,14 +309,10 @@ class CustomServiceOrchestrator():
         server_url_prefix = command['hostLevelParams']['jdk_location']
       else:
         server_url_prefix = command['commandParams']['jdk_location']
-        
-      task_id = "status"
-      
-      try:
-        task_id = command['taskId']
-        command_name = command['roleCommand']
-      except KeyError:
-        pass  # Status commands have no taskId
+
+      # Status commands have no taskId nor roleCommand
+      task_id = command['taskId'] if 'taskId' in command else 'status'
+      command_name = command['roleCommand'] if 'roleCommand' in command else None
 
       if forced_command_name is not None:  # If not supplied as an argument
         command_name = forced_command_name

http://git-wip-us.apache.org/repos/asf/ambari/blob/df8c06ca/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
index 3985c5a..8e5e9a3 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
@@ -28,6 +28,7 @@ from unittest import TestCase
 import threading
 import tempfile
 import time
+import traceback
 from threading import Thread
 
 from mock.mock import MagicMock, patch
@@ -278,6 +279,23 @@ class TestCustomServiceOrchestrator(TestCase):
     self.assertTrue(run_file_mock.called)
     self.assertEqual(run_file_mock.call_count, 3)
 
+    # running a status command
+    run_file_mock.reset_mock()
+    def return_traceback(*args, **kwargs):
+      return {
+        'stderr': traceback.format_exc(),
+        'stdout': '',
+        'exitcode': 0,
+      }
+    run_file_mock.side_effect = return_traceback
+
+    status_command = dict(command)
+    status_command['commandType'] = 'STATUS_COMMAND'
+    del status_command['taskId']
+    del status_command['roleCommand']
+    ret = orchestrator.runCommand(status_command, "out.txt", "err.txt")
+    self.assertEqual('None\n', ret['stderr'])
+
     run_file_mock.reset_mock()
 
     # Case when we force another command