From 9437d276e76b18a2cf6c469fa886a027115ece03 Mon Sep 17 00:00:00 2001 From: Wenjun Ruan Date: Tue, 16 Apr 2024 22:49:11 +0800 Subject: [PATCH] Change ssh heartbeat type to IGNORE (#15858) --- .../dolphinscheduler/plugin/datasource/ssh/SSHUtils.java | 2 +- .../plugin/task/remoteshell/RemoteExecutor.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-ssh/src/main/java/org/apache/dolphinscheduler/plugin/datasource/ssh/SSHUtils.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-ssh/src/main/java/org/apache/dolphinscheduler/plugin/datasource/ssh/SSHUtils.java index 42e1175e2efd..7abb18cee891 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-ssh/src/main/java/org/apache/dolphinscheduler/plugin/datasource/ssh/SSHUtils.java +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-ssh/src/main/java/org/apache/dolphinscheduler/plugin/datasource/ssh/SSHUtils.java @@ -59,7 +59,7 @@ public static ClientSession getSession(SshClient client, SSHConnectionParam conn throw new Exception("Failed to add public key identity", e); } } - session.setSessionHeartbeat(SessionHeartbeatController.HeartbeatType.RESERVED, Duration.ofSeconds(3)); + session.setSessionHeartbeat(SessionHeartbeatController.HeartbeatType.IGNORE, Duration.ofSeconds(3)); return session; } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-remoteshell/src/main/java/org/apache/dolphinscheduler/plugin/task/remoteshell/RemoteExecutor.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-remoteshell/src/main/java/org/apache/dolphinscheduler/plugin/task/remoteshell/RemoteExecutor.java index 334ebb61958f..307023043a4e 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-remoteshell/src/main/java/org/apache/dolphinscheduler/plugin/task/remoteshell/RemoteExecutor.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-remoteshell/src/main/java/org/apache/dolphinscheduler/plugin/task/remoteshell/RemoteExecutor.java @@ -141,7 +141,6 @@ public Integer getTaskExitCode(String taskId) throws IOException { } } cleanData(taskId); - log.error("Remote shell task failed"); return exitCode; } @@ -232,8 +231,10 @@ public String runRemote(String command) throws IOException { channel.open(); channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0); channel.close(); - if (channel.getExitStatus() != 0) { - throw new TaskException("Remote shell task error, error message: " + err.toString()); + Integer exitStatus = channel.getExitStatus(); + if (exitStatus == null || exitStatus != 0) { + throw new TaskException( + "Remote shell task error, exitStatus: " + exitStatus + " error message: " + err); } return out.toString(); }