Kaynağa Gözat

AMBARI-18960 - Dashboards directory only needs to be sync'd for METRICS_GRAFANA

Tim Thorpe 8 yıl önce
ebeveyn
işleme
38834dd5da

+ 3 - 1
ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py

@@ -58,6 +58,7 @@ class CustomServiceOrchestrator():
   AMBARI_SERVER_HOST = "ambari_server_host"
   AMBARI_SERVER_PORT = "ambari_server_port"
   AMBARI_SERVER_USE_SSL = "ambari_server_use_ssl"
+  METRICS_GRAFANA = "METRICS_GRAFANA"
 
   FREQUENT_COMMANDS = [COMMAND_NAME_SECURITY_STATUS, COMMAND_NAME_STATUS]
   DONT_DEBUG_FAILURES_FOR_COMMANDS = FREQUENT_COMMANDS
@@ -153,7 +154,8 @@ class CustomServiceOrchestrator():
         self.file_cache.get_host_scripts_base_dir(server_url_prefix)          
         hook_dir = self.file_cache.get_hook_base_dir(command, server_url_prefix)
         base_dir = self.file_cache.get_service_base_dir(command, server_url_prefix)
-        self.file_cache.get_dashboard_base_dir(server_url_prefix)
+        if command['role'] == self.METRICS_GRAFANA:
+          self.file_cache.get_dashboard_base_dir(server_url_prefix)
 
         script_path = self.resolve_script_path(base_dir, script)
         script_tuple = (script_path, base_dir)

+ 21 - 0
ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py

@@ -277,6 +277,8 @@ class TestCustomServiceOrchestrator(TestCase):
     self.assertEqual(ret['exitcode'], 0)
     self.assertTrue(run_file_mock.called)
     self.assertEqual(run_file_mock.call_count, 3)
+    # Should only be called for METRICS_GRAFANA
+    self.assertFalse(get_dashboard_base_dir_mock.called)
 
     run_file_mock.reset_mock()
 
@@ -299,6 +301,25 @@ class TestCustomServiceOrchestrator(TestCase):
 
     run_file_mock.reset_mock()
 
+    # For role=METRICS_GRAFANA, dashboards should be sync'd
+    command['role'] = 'METRICS_GRAFANA'
+    get_dashboard_base_dir_mock.reset_mock()
+    get_dashboard_base_dir_mock.return_value = "/dashboards/"
+
+    run_file_mock.return_value = {
+        'stdout' : 'sss',
+        'stderr' : 'eee',
+        'exitcode': 0,
+      }
+    ret = orchestrator.runCommand(command, "out.txt", "err.txt")
+    self.assertEqual(ret['exitcode'], 0)
+    self.assertTrue(run_file_mock.called)
+    self.assertEqual(run_file_mock.call_count, 3)
+    self.assertTrue(get_dashboard_base_dir_mock.called)
+
+    command['role'] = 'REGION_SERVER'
+    run_file_mock.reset_mock()
+
     # unknown script type case
     command['commandParams']['script_type'] = "SOME_TYPE"
     ret = orchestrator.runCommand(command, "out.txt", "err.txt")