You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by am...@apache.org on 2018/06/13 13:14:42 UTC

[ambari] branch trunk updated: AMBARI-24087. The alert "DataNode Unmounted Data Dir" did not appear (amagyar) (#1522)

This is an automated email from the ASF dual-hosted git repository.

amagyar pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new dd2f435  AMBARI-24087. The alert "DataNode Unmounted Data Dir" did not appear (amagyar) (#1522)
dd2f435 is described below

commit dd2f43574aaeea0d05e42d81348eb34077fb08e1
Author: Attila Magyar <m....@gmail.com>
AuthorDate: Wed Jun 13 15:14:27 2018 +0200

    AMBARI-24087. The alert "DataNode Unmounted Data Dir" did not appear (amagyar) (#1522)
---
 .../alerts/alert_datanode_unmounted_data_dir.py        |  1 +
 .../HDFS/test_alert_datanode_unmounted_data_dir.py     | 18 ++++++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/alerts/alert_datanode_unmounted_data_dir.py b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/alerts/alert_datanode_unmounted_data_dir.py
index 765831d..aa1e737 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/alerts/alert_datanode_unmounted_data_dir.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/alerts/alert_datanode_unmounted_data_dir.py
@@ -107,6 +107,7 @@ def execute(configurations={}, parameters={}, host_name=None):
 
   # Sort the data dirs, which is needed for deterministic behavior when running the unit tests.
   normalized_data_dirs = sorted(normalized_data_dirs)
+  file_system.get_and_cache_mount_points(refresh=True)
   for data_dir in normalized_data_dirs:
     # This follows symlinks and will return False for a broken link (even in the middle of the linked list)
     if os.path.isdir(data_dir):
diff --git a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_alert_datanode_unmounted_data_dir.py b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_alert_datanode_unmounted_data_dir.py
index c7dd47c..48fd983 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_alert_datanode_unmounted_data_dir.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_alert_datanode_unmounted_data_dir.py
@@ -71,10 +71,11 @@ class TestAlertDataNodeUnmountedDataDir(RMFTestCase):
     [status, messages] = alert.execute(configurations=configs)
     self.assertNotEqual(status, RESULT_STATE_UNKNOWN)
 
+  @patch("resource_management.libraries.functions.file_system.get_and_cache_mount_points")
   @patch("resource_management.libraries.functions.file_system.get_mount_point_for_dir")
   @patch("os.path.exists")
   @patch("os.path.isdir")
-  def test_mount_history_file_does_not_exist(self, is_dir_mock, exists_mock, get_mount_mock):
+  def test_mount_history_file_does_not_exist(self, is_dir_mock, exists_mock, get_mount_mock, get_and_cache_mount_points_mock):
     """
     Test that the status is WARNING when the data dirs are mounted on root, but the mount history file
     does not exist.
@@ -93,11 +94,12 @@ class TestAlertDataNodeUnmountedDataDir(RMFTestCase):
     self.assertTrue(messages is not None and len(messages) == 1)
     self.assertTrue("{0} was not found".format(DATA_DIR_MOUNT_HIST_FILE_PATH) in messages[0])
 
+  @patch("resource_management.libraries.functions.file_system.get_and_cache_mount_points")
   @patch("resource_management.libraries.functions.mounted_dirs_helper.get_dir_to_mount_from_file")
   @patch("resource_management.libraries.functions.file_system.get_mount_point_for_dir")
   @patch("os.path.exists")
   @patch("os.path.isdir")
-  def test_all_dirs_on_root(self, is_dir_mock, exists_mock, get_mount_mock, get_data_dir_to_mount_from_file_mock):
+  def test_all_dirs_on_root(self, is_dir_mock, exists_mock, get_mount_mock, get_data_dir_to_mount_from_file_mock, get_and_cache_mount_points_mock):
     """
     Test that the status is OK when all drives are mounted on the root partition
     and this coincides with the expected values.
@@ -119,11 +121,12 @@ class TestAlertDataNodeUnmountedDataDir(RMFTestCase):
     self.assertTrue(messages is not None and len(messages) == 1)
     self.assertTrue("The following data dir(s) are valid" in messages[0])
 
+  @patch("resource_management.libraries.functions.file_system.get_and_cache_mount_points")
   @patch("resource_management.libraries.functions.mounted_dirs_helper.get_dir_to_mount_from_file")
   @patch("resource_management.libraries.functions.file_system.get_mount_point_for_dir")
   @patch("os.path.exists")
   @patch("os.path.isdir")
-  def test_match_expected(self, is_dir_mock, exists_mock, get_mount_mock, get_data_dir_to_mount_from_file_mock):
+  def test_match_expected(self, is_dir_mock, exists_mock, get_mount_mock, get_data_dir_to_mount_from_file_mock, get_and_cache_mount_points_mock):
     """
     Test that the status is OK when the mount points match the expected values.
     """
@@ -144,11 +147,12 @@ class TestAlertDataNodeUnmountedDataDir(RMFTestCase):
     self.assertTrue(messages is not None and len(messages) == 1)
     self.assertTrue("The following data dir(s) are valid" in messages[0])
 
+  @patch("resource_management.libraries.functions.file_system.get_and_cache_mount_points")
   @patch("resource_management.libraries.functions.mounted_dirs_helper.get_dir_to_mount_from_file")
   @patch("resource_management.libraries.functions.file_system.get_mount_point_for_dir")
   @patch("os.path.exists")
   @patch("os.path.isdir")
-  def test_critical_one_root_one_mounted(self, is_dir_mock, exists_mock, get_mount_mock, get_data_dir_to_mount_from_file_mock):
+  def test_critical_one_root_one_mounted(self, is_dir_mock, exists_mock, get_mount_mock, get_data_dir_to_mount_from_file_mock, get_and_cache_mount_points_mock):
     """
     Test that the status is CRITICAL when the history file is missing
     and at least one data dir is on a mount and at least one data dir is on the root partition.
@@ -168,11 +172,12 @@ class TestAlertDataNodeUnmountedDataDir(RMFTestCase):
     self.assertTrue(messages is not None and len(messages) == 1)
     self.assertTrue("Detected at least one data dir on a mount point, but these are writing to the root partition:\n/grid/0/data\n/grid/1/data" in messages[0])
 
+  @patch("resource_management.libraries.functions.file_system.get_and_cache_mount_points")
   @patch("resource_management.libraries.functions.mounted_dirs_helper.get_dir_to_mount_from_file")
   @patch("resource_management.libraries.functions.file_system.get_mount_point_for_dir")
   @patch("os.path.exists")
   @patch("os.path.isdir")
-  def test_critical_unmounted(self, is_dir_mock, exists_mock, get_mount_mock, get_data_dir_to_mount_from_file_mock):
+  def test_critical_unmounted(self, is_dir_mock, exists_mock, get_mount_mock, get_data_dir_to_mount_from_file_mock, get_and_cache_mount_points_mock):
     """
     Test that the status is CRITICAL when the history file exists and one of the dirs
     became unmounted.
@@ -196,11 +201,12 @@ class TestAlertDataNodeUnmountedDataDir(RMFTestCase):
     self.assertTrue("Detected data dir(s) that became unmounted and are now writing to the root partition:\n/grid/1/data" in messages[0])
 
 
+  @patch("resource_management.libraries.functions.file_system.get_and_cache_mount_points")
   @patch("resource_management.libraries.functions.mounted_dirs_helper.get_dir_to_mount_from_file")
   @patch("resource_management.libraries.functions.file_system.get_mount_point_for_dir")
   @patch("os.path.exists")
   @patch("os.path.isdir")
-  def test_file_uri_and_meta_tags(self, is_dir_mock, exists_mock, get_mount_mock, get_data_dir_to_mount_from_file_mock):
+  def test_file_uri_and_meta_tags(self, is_dir_mock, exists_mock, get_mount_mock, get_data_dir_to_mount_from_file_mock, get_and_cache_mount_points_mock):
     """
     Test that the status is OK when the locations include file:// schemes and meta tags.
     """

-- 
To stop receiving notification emails like this one, please contact
amagyar@apache.org.