hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rchi...@apache.org
Subject hadoop git commit: YARN-5567. Fix script exit code checking in NodeHealthScriptRunner#reportHealthStatus. (Yufei Gu via rchiang)
Date Mon, 29 Aug 2016 23:21:49 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.8 765139e4d -> 9ad3a7a43


YARN-5567. Fix script exit code checking in NodeHealthScriptRunner#reportHealthStatus. (Yufei
Gu via rchiang)

(cherry picked from commit 05ede003868871addc30162e9707c3dc14ed6b7a)
(cherry picked from commit 3b19bcb8f0f70606a8080bc46fa64cd34f6280d7)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/9ad3a7a4
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/9ad3a7a4
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/9ad3a7a4

Branch: refs/heads/branch-2.8
Commit: 9ad3a7a43b35dd4bb9d10bd322fbb956d3b01ff2
Parents: 765139e
Author: Ray Chiang <rchiang@apache.org>
Authored: Mon Aug 29 15:55:33 2016 -0700
Committer: Ray Chiang <rchiang@apache.org>
Committed: Mon Aug 29 16:15:39 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/hadoop/util/NodeHealthScriptRunner.java   | 3 ++-
 .../org/apache/hadoop/util/TestNodeHealthScriptRunner.java    | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/9ad3a7a4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NodeHealthScriptRunner.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NodeHealthScriptRunner.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NodeHealthScriptRunner.java
index fc392c4..c3bef37 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NodeHealthScriptRunner.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NodeHealthScriptRunner.java
@@ -106,6 +106,7 @@ public class NodeHealthScriptRunner extends AbstractService {
         shexec.execute();
       } catch (ExitCodeException e) {
         // ignore the exit code of the script
+        exceptionStackTrace = StringUtils.stringifyException(e);
         status = HealthCheckerExitStatus.FAILED_WITH_EXIT_CODE;
         // On Windows, we will not hit the Stream closed IOException
         // thrown by stdout buffered reader for timeout event.
@@ -162,7 +163,7 @@ public class NodeHealthScriptRunner extends AbstractService {
         setHealthStatus(false, exceptionStackTrace);
         break;
       case FAILED_WITH_EXIT_CODE:
-        setHealthStatus(true, "", now);
+        setHealthStatus(false, exceptionStackTrace);
         break;
       case FAILED:
         setHealthStatus(false, shexec.getOutput());

http://git-wip-us.apache.org/repos/asf/hadoop/blob/9ad3a7a4/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNodeHealthScriptRunner.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNodeHealthScriptRunner.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNodeHealthScriptRunner.java
index 8fc64d1..db61f5a 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNodeHealthScriptRunner.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNodeHealthScriptRunner.java
@@ -91,6 +91,7 @@ public class TestNodeHealthScriptRunner {
   public void testNodeHealthScript() throws Exception {
     String errorScript = "echo ERROR\n echo \"Tracker not healthy\"";
     String normalScript = "echo \"I am all fine\"";
+    String failWithExitCodeScript = "echo \"Not healthy\"; exit -1";
     String timeOutScript =
       Shell.WINDOWS ? "@echo off\nping -n 4 127.0.0.1 >nul\necho \"I am fine\""
       : "sleep 4\necho \"I am fine\"";
@@ -124,6 +125,12 @@ public class TestNodeHealthScriptRunner {
         nodeHealthScriptRunner.isHealthy());
     Assert.assertEquals("", nodeHealthScriptRunner.getHealthReport());
 
+    // Script which fails with exit code.
+    writeNodeHealthScriptFile(failWithExitCodeScript, true);
+    timerTask.run();
+    Assert.assertFalse("Node health status reported healthy",
+        nodeHealthScriptRunner.isHealthy());
+
     // Timeout script.
     writeNodeHealthScriptFile(timeOutScript, true);
     timerTask.run();


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message