You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by as...@apache.org on 2020/01/30 16:17:04 UTC
[oozie] branch master updated: OOZIE-3569 SSH Action should add
checking success file (zuston via asalamon74)
This is an automated email from the ASF dual-hosted git repository.
asalamon74 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/oozie.git
The following commit(s) were added to refs/heads/master by this push:
new 7b47626 OOZIE-3569 SSH Action should add checking success file (zuston via asalamon74)
7b47626 is described below
commit 7b47626d95dca27a3d0c5dedf7e0c901ee1d6576
Author: Andras Salamon <as...@apache.org>
AuthorDate: Thu Jan 30 17:16:36 2020 +0100
OOZIE-3569 SSH Action should add checking success file (zuston via asalamon74)
---
.../apache/oozie/action/ssh/SshActionExecutor.java | 31 ++++++++++++++--------
core/src/main/resources/ssh-wrapper.sh | 3 +++
docs/src/site/markdown/DG_SshActionExtension.md | 5 ++++
release-log.txt | 1 +
4 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/core/src/main/java/org/apache/oozie/action/ssh/SshActionExecutor.java b/core/src/main/java/org/apache/oozie/action/ssh/SshActionExecutor.java
index fbc94f1..4e418cb 100644
--- a/core/src/main/java/org/apache/oozie/action/ssh/SshActionExecutor.java
+++ b/core/src/main/java/org/apache/oozie/action/ssh/SshActionExecutor.java
@@ -27,19 +27,17 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.hadoop.util.StringUtils;
-
import org.apache.oozie.ErrorCode;
-import org.apache.oozie.client.WorkflowAction;
-import org.apache.oozie.client.OozieClient;
-import org.apache.oozie.client.WorkflowAction.Status;
import org.apache.oozie.action.ActionExecutor;
import org.apache.oozie.action.ActionExecutorException;
+import org.apache.oozie.client.OozieClient;
+import org.apache.oozie.client.WorkflowAction;
+import org.apache.oozie.client.WorkflowAction.Status;
import org.apache.oozie.service.CallbackService;
import org.apache.oozie.service.ConfigurationService;
-import org.apache.oozie.servlet.CallbackServlet;
import org.apache.oozie.service.Services;
+import org.apache.oozie.servlet.CallbackServlet;
import org.apache.oozie.util.BufferDrainer;
import org.apache.oozie.util.IOUtils;
import org.apache.oozie.util.PropertiesUtils;
@@ -49,6 +47,8 @@ import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.Namespace;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
/**
* Ssh action executor. <ul> <li>Execute the shell commands on the remote host</li> <li>Copies the base and wrapper
* scripts on to the remote location</li> <li>Base script is used to run the command on the remote host</li> <li>Wrapper
@@ -595,19 +595,28 @@ public class SshActionExecutor extends ActionExecutor {
aStatus = Status.RUNNING;
}
else {
- String outFile = getRemoteFileName(context, action, "error", false, true);
- String checkErrorCmd = SSH_COMMAND_BASE + action.getTrackerUri() + " ls " + outFile;
- int retVal = getReturnValue(checkErrorCmd);
- if (retVal == 0) {
+ if (checkSSHActionFileExistence(context, action, "error")) {
aStatus = Status.ERROR;
}
else {
- aStatus = Status.OK;
+ if (checkSSHActionFileExistence(context, action, "success")) {
+ aStatus = Status.OK;
+ } else {
+ aStatus = Status.ERROR;
+ }
}
}
return aStatus;
}
+ private boolean checkSSHActionFileExistence(final Context context, final WorkflowAction action,
+ String fileExtension) throws ActionExecutorException {
+ String outFile = getRemoteFileName(context, action, fileExtension, false, true);
+ String checkCmd = SSH_COMMAND_BASE + action.getTrackerUri() + " ls " + outFile;
+ int retVal = getReturnValue(checkCmd);
+ return retVal == 0 ? true : false;
+ }
+
private long handleRetry(long sleepBeforeRetryMs, final int retries) {
LOG.warn("failed to check ssh action status, sleeping {0} milliseconds before retry #{1}", sleepBeforeRetryMs,
retries);
diff --git a/core/src/main/resources/ssh-wrapper.sh b/core/src/main/resources/ssh-wrapper.sh
index 4bd6b8c..5aa6293 100644
--- a/core/src/main/resources/ssh-wrapper.sh
+++ b/core/src/main/resources/ssh-wrapper.sh
@@ -34,6 +34,7 @@ echo $mpid > $dir/$actionId.pid
stdout="$dir/$mpid.$actionId.stdout"
stderr="$dir/$mpid.$actionId.stderr"
errorFile="$dir/$mpid.$actionId.error"
+successFile="$dir/$mpid.$actionId.success"
exitCodeMsg="Exit code:"
if [ $preserveArgs == "PRESERVE_ARGS" ]
@@ -42,6 +43,7 @@ then
shift
if $cmnd "$@" >>${stdout} 2>>${stderr}; then
export callbackUrl=`echo ${callbackUrl} | sed -e 's/#status/OK/'`
+ touch $successFile
else
ec=$?
export callbackUrl=`echo ${callbackUrl} | sed -e 's/#status/ERROR/'`
@@ -51,6 +53,7 @@ else
cmnd="${*}"
if $cmnd >>${stdout} 2>>${stderr}; then
export callbackUrl=`echo ${callbackUrl} | sed -e 's/#status/OK/'`
+ touch $successFile
else
ec=$?
export callbackUrl=`echo ${callbackUrl} | sed -e 's/#status/ERROR/'`
diff --git a/docs/src/site/markdown/DG_SshActionExtension.md b/docs/src/site/markdown/DG_SshActionExtension.md
index e53e1c3..0434505 100644
--- a/docs/src/site/markdown/DG_SshActionExtension.md
+++ b/docs/src/site/markdown/DG_SshActionExtension.md
@@ -32,6 +32,11 @@ Note: Ssh Action will fail if oozie fails to ssh connect to host for action stat
The first retry will wait a configurable period of time ( 3 seconds by default) before check.
The following retries will wait 2 times of previous wait time.
+Note: [OOZIE-3569](https://issues.apache.org/jira/browse/OOZIE-3569) patch fixes the bug that
+SSH Action will be incorrectly determined to be successful when Oozie pid is killed externally.
+It's released in version 5.3.0.
+Please note that this is an incompatible change and may cause some SSH Action tasks to fail during updating.
+
**Syntax:**
diff --git a/release-log.txt b/release-log.txt
index ca9042e..21f70f7 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
-- Oozie 5.3.0 release (trunk - unreleased)
+OOZIE-3569 SSH Action should add checking success file (zuston via asalamon74)
OOZIE-3305 Prometheus /metrics http endpoint for monitoring integration (qsbao via gezapeti)
OOZIE-3575 Add credential support for cloud file systems (matijhs via gezapeti)
OOZIE-3579 [docs] Fix typos in coordinator documentation (qsbao via asalamon74)