Repository: ambari
Updated Branches:
  refs/heads/trunk 701ea2bd8 -> 40fe30bfe


AMBARI-16630. Extend logging for ActionQueue's retry logic. (Daniel Gergely via 
stoader)


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

Branch: refs/heads/trunk
Commit: 40fe30bfe7d58ce56e128d8c09be6cb947eff92f
Parents: 701ea2b
Author: Daniel Gergely <dgerg...@hortonworks.com>
Authored: Tue May 17 22:32:46 2016 +0200
Committer: Toader, Sebastian <stoa...@hortonworks.com>
Committed: Wed May 18 09:17:00 2016 +0200

----------------------------------------------------------------------
 ambari-agent/src/main/python/ambari_agent/ActionQueue.py     | 8 ++++++--
 ambari-agent/src/test/python/ambari_agent/TestActionQueue.py | 4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/40fe30bf/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py 
b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
index 85389f9..19bd18f 100644
--- a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
+++ b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
@@ -283,8 +283,8 @@ class ActionQueue(threading.Thread):
     if isAutoExecuteCommand:
       retryAble = False
 
-    logger.debug("Command execution metadata - retry enabled = {retryAble}, 
max retry duration (sec) = {retryDuration}".
-                 format(retryAble=retryAble, retryDuration=retryDuration))
+    logger.info("Command execution metadata - taskId = {taskId}, retry enabled 
= {retryAble}, max retry duration (sec) = {retryDuration}".
+                 format(taskId=taskId, retryAble=retryAble, 
retryDuration=retryDuration))
     while retryDuration >= 0:
       numAttempts += 1
       start = 0
@@ -303,6 +303,8 @@ class ActionQueue(threading.Thread):
 
       # dumping results
       if isCommandBackground:
+        logger.info("Command is background command, quit retrying. Exit code: 
{exitCode}, retryAble: {retryAble}, retryDuration (sec): {retryDuration}, last 
delay (sec): {delay}"
+                    .format(cid=taskId, exitCode=commandresult['exitcode'], 
retryAble=retryAble, retryDuration=retryDuration, delay=delay))
         return
       else:
         if commandresult['exitcode'] == 0:
@@ -320,6 +322,8 @@ class ActionQueue(threading.Thread):
         time.sleep(delay)
         continue
       else:
+        logger.info("Quit retrying for command id {cid}. Status: {status}, 
retryAble: {retryAble}, retryDuration (sec): {retryDuration}, last delay (sec): 
{delay}"
+                    .format(cid=taskId, status=status, retryAble=retryAble, 
retryDuration=retryDuration, delay=delay))
         break
 
     # final result to stdout

http://git-wip-us.apache.org/repos/asf/ambari/blob/40fe30bf/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py 
b/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
index 7d0efa2..0fd3bff 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
@@ -986,7 +986,7 @@ class TestActionQueue(TestCase):
       'status': 'FAILED'
     }
 
-    times_arr = [8, 10, 14, 18, 22, 26]
+    times_arr = [8, 10, 14, 18, 22, 26, 30, 34]
     if self.logger.isEnabledFor(logging.INFO):
       times_arr.insert(0, 4)
     time_mock.side_effect = times_arr
@@ -1003,7 +1003,7 @@ class TestActionQueue(TestCase):
     self.assertTrue(runCommand_mock.called)
     self.assertEqual(2, runCommand_mock.call_count)
     self.assertEqual(1, sleep_mock.call_count)
-    sleep_mock.assert_has_calls([call(2)], False)
+    sleep_mock.assert_has_calls([call(1)], False)
     runCommand_mock.assert_has_calls([
       call(command, os.sep + 'tmp' + os.sep + 'ambari-agent' + os.sep + 
'output-19.txt',
            os.sep + 'tmp' + os.sep + 'ambari-agent' + os.sep + 
'errors-19.txt', override_output_files=True, retry=False),

Reply via email to