ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-12548 Ambari Agent does not register / heartbeat if "df" command hangs (dsen)
Date Mon, 27 Jul 2015 10:20:47 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 2b53f2aba -> 1906e5d86


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/1906e5d8
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1906e5d8
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1906e5d8

Branch: refs/heads/branch-2.1
Commit: 1906e5d8645031c552d3d732073d154d47f4f239
Parents: 2b53f2a
Author: Dmytro Sen <dsen@apache.org>
Authored: Mon Jul 27 13:16:56 2015 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Mon Jul 27 13:20:37 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/1906e5d8/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/1906e5d8/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 29870d5..f35ff98 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHardware.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHardware.py
@@ -74,20 +74,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/1906e5d8/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 80c94e8..ffbbf36 100644
--- a/ambari-server/src/test/python/custom_actions/TestCheckHost.py
+++ b/ambari-server/src/test/python/custom_actions/TestCheckHost.py
@@ -293,12 +293,15 @@ class TestCheckHost(TestCase):
     put_structured_out_mock.assert_called_with({'last_agent_env_check': {'message': 'test
exception', 'exit_code': 1}})
 
 
+  @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()


Mime
View raw message