You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2015/07/27 12:19:33 UTC

ambari git commit: AMBARI-12548 Ambari Agent does not register / heartbeat if "df" command hangs (dsen)

Repository: ambari
Updated Branches:
  refs/heads/trunk bdcdb4b99 -> 819ab1049


AMBARI-12548 Ambari Agent does not register / heartbeat if "df" command hangs (dsen)


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

Branch: refs/heads/trunk
Commit: 819ab1049fbe57bd12e94331e0823a5c153e7a78
Parents: bdcdb4b
Author: Dmytro Sen <ds...@apache.org>
Authored: Mon Jul 27 13:16:56 2015 +0300
Committer: Dmytro Sen <ds...@apache.org>
Committed: Mon Jul 27 13:16:56 2015 +0300

----------------------------------------------------------------------
 ambari-agent/src/main/python/ambari_agent/Hardware.py     |  7 +++++--
 ambari-agent/src/test/python/ambari_agent/TestHardware.py | 10 +++++-----
 .../src/test/python/custom_actions/TestCheckHost.py       |  5 ++++-
 3 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/819ab104/ambari-agent/src/main/python/ambari_agent/Hardware.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/Hardware.py b/ambari-agent/src/main/python/ambari_agent/Hardware.py
index 5567286..36b4f4b 100644
--- a/ambari-agent/src/main/python/ambari_agent/Hardware.py
+++ b/ambari-agent/src/main/python/ambari_agent/Hardware.py
@@ -34,6 +34,7 @@ class Hardware:
   WINDOWS_GET_DRIVES_CMD = "foreach ($drive in [System.IO.DriveInfo]::getdrives()){$available = $drive.TotalFreeSpace;$used = $drive.TotalSize-$drive.TotalFreeSpace;$percent = ($used*100)/$drive.TotalSize;$size = $drive.TotalSize;$type = $drive.DriveFormat;$mountpoint = $drive.RootDirectory.FullName;echo \"$available $used $percent% $size $type $mountpoint\"}"
   CHECK_REMOTE_MOUNTS_KEY = 'agent.check.remote.mounts'
   CHECK_REMOTE_MOUNTS_TIMEOUT_KEY = 'agent.check.mounts.timeout'
+  CHECK_REMOTE_MOUNTS_TIMEOUT_DEFAULT = '10'
 
   def __init__(self):
     self.hardware = {}
@@ -70,11 +71,13 @@ class Hardware:
     and any mounts with spaces. """
     mounts = []
     command = []
+    timeout = Hardware.CHECK_REMOTE_MOUNTS_TIMEOUT_DEFAULT
     if config and \
         config.has_option(AmbariConfig.AMBARI_PROPERTIES_CATEGORY, Hardware.CHECK_REMOTE_MOUNTS_TIMEOUT_KEY) and \
         config.get(AmbariConfig.AMBARI_PROPERTIES_CATEGORY, Hardware.CHECK_REMOTE_MOUNTS_TIMEOUT_KEY) != "0":
-      command.append("timeout")
-      command.append(config.get(AmbariConfig.AMBARI_PROPERTIES_CATEGORY, Hardware.CHECK_REMOTE_MOUNTS_TIMEOUT_KEY))
+        timeout = config.get(AmbariConfig.AMBARI_PROPERTIES_CATEGORY, Hardware.CHECK_REMOTE_MOUNTS_TIMEOUT_KEY)
+    command.append("timeout")
+    command.append(timeout)
     command.append("df")
     command.append("-kPT")
     if config and \

http://git-wip-us.apache.org/repos/asf/ambari/blob/819ab104/ambari-agent/src/test/python/ambari_agent/TestHardware.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHardware.py b/ambari-agent/src/test/python/ambari_agent/TestHardware.py
index d1bc2e6..c24c166 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHardware.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHardware.py
@@ -80,20 +80,20 @@ class TestHardware(TestCase):
     get_os_type_mock.return_value = "suse"
     get_os_version_mock.return_value = "11"
     Hardware.osdisks()
-    popen_mock.assert_called_with(["df","-kPT"], stdout=-1)
+    popen_mock.assert_called_with(['timeout', '10', "df","-kPT"], stdout=-1)
     config = AmbariConfig()
     Hardware.osdisks(config)
-    popen_mock.assert_called_with(["df","-kPT"], stdout=-1)
+    popen_mock.assert_called_with(['timeout', '10', "df","-kPT"], stdout=-1)
     config.add_section(AmbariConfig.AMBARI_PROPERTIES_CATEGORY)
     config.set(AmbariConfig.AMBARI_PROPERTIES_CATEGORY, Hardware.CHECK_REMOTE_MOUNTS_KEY, "true")
     Hardware.osdisks(config)
-    popen_mock.assert_called_with(["df","-kPT"], stdout=-1)
+    popen_mock.assert_called_with(['timeout', '10', "df","-kPT"], stdout=-1)
     config.set(AmbariConfig.AMBARI_PROPERTIES_CATEGORY, Hardware.CHECK_REMOTE_MOUNTS_KEY, "false")
     Hardware.osdisks(config)
-    popen_mock.assert_called_with(["df","-kPT", "-l"], stdout=-1)
+    popen_mock.assert_called_with(['timeout', '10', "df","-kPT", "-l"], stdout=-1)
     config.set(AmbariConfig.AMBARI_PROPERTIES_CATEGORY, Hardware.CHECK_REMOTE_MOUNTS_TIMEOUT_KEY, "0")
     Hardware.osdisks(config)
-    popen_mock.assert_called_with(["df","-kPT","-l"], stdout=-1)
+    popen_mock.assert_called_with(['timeout', '10', "df","-kPT","-l"], stdout=-1)
     config.set(AmbariConfig.AMBARI_PROPERTIES_CATEGORY, Hardware.CHECK_REMOTE_MOUNTS_TIMEOUT_KEY, "1")
     Hardware.osdisks(config)
     popen_mock.assert_called_with(["timeout","1","df","-kPT","-l"], stdout=-1)

http://git-wip-us.apache.org/repos/asf/ambari/blob/819ab104/ambari-server/src/test/python/custom_actions/TestCheckHost.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/TestCheckHost.py b/ambari-server/src/test/python/custom_actions/TestCheckHost.py
index 024aab2..ee9be64 100644
--- a/ambari-server/src/test/python/custom_actions/TestCheckHost.py
+++ b/ambari-server/src/test/python/custom_actions/TestCheckHost.py
@@ -345,12 +345,15 @@ class TestCheckHost(TestCase):
     pass
 
 
+  @patch.object(HostCheckReportFileHandler, "resolve_ambari_config")
   @patch("resource_management.libraries.script.Script.put_structured_out")
   @patch.object(Script, 'get_tmp_dir')
   @patch.object(Script, 'get_config')
   @patch("os.path.isfile")
   @patch('__builtin__.open')
-  def testTransparentHugePage(self, open_mock, os_path_isfile_mock, mock_config, get_tmp_dir_mock, structured_out_mock):
+  def testTransparentHugePage(self, open_mock, os_path_isfile_mock, mock_config,
+                              get_tmp_dir_mock, structured_out_mock,
+                              resolve_config_mock):
     context_manager_mock = MagicMock()
     open_mock.return_value = context_manager_mock
     file_mock = MagicMock()