浏览代码

AMBARI-17776. HiveServer interactive stop should wait for 30 second before sending hard kill command (ajit)

Ajit Kumar 9 年之前
父节点
当前提交
aa259ae444

+ 10 - 4
ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service_interactive.py

@@ -87,10 +87,16 @@ def hive_service_interactive(name, action='start', upgrade_type=None):
             not_if = format("! ({process_id_exists_command})")
             )
 
-    wait_time = 5
-    Execute(daemon_hard_kill_cmd,
-            not_if = format("! ({process_id_exists_command}) || ( sleep {wait_time} && ! ({process_id_exists_command}) )")
-            )
+    # check if stopped the process, otherwise send hard kill command.
+    try:
+      Execute(format("! ({process_id_exists_command})"),
+              tries=10,
+              try_sleep=3,
+              )
+    except:
+      Execute(daemon_hard_kill_cmd,
+              not_if = format("! ({process_id_exists_command}) ")
+              )
 
     # check if stopped the process, else fail the task
     Execute(format("! ({process_id_exists_command})"),

+ 6 - 3
ambari-server/src/test/python/stacks/2.5/HIVE/test_hive_server_int.py

@@ -202,9 +202,12 @@ class TestHiveServerInteractive(RMFTestCase):
     self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
                               not_if="! (ls /var/run/hive/hive-interactive.pid >/dev/null 2>&1 && ps -p 123 >/dev/null 2>&1)",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
-                              not_if="! (ls /var/run/hive/hive-interactive.pid >/dev/null 2>&1 && ps -p 123 >/dev/null 2>&1) || ( sleep 5 && ! (ls /var/run/hive/hive-interactive.pid >/dev/null 2>&1 && ps -p 123 >/dev/null 2>&1) )",
-    )
+    self.assertResourceCalled('Execute',
+                              "! (ls /var/run/hive/hive-interactive.pid >/dev/null 2>&1 && ps -p 123 >/dev/null 2>&1)",
+                              tries=10,
+                              try_sleep=3,
+                              )
+
     self.assertResourceCalled('Execute',
                               "! (ls /var/run/hive/hive-interactive.pid >/dev/null 2>&1 && ps -p 123 >/dev/null 2>&1)",
                               tries=20,