Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.apache.dolphinscheduler.common.constants.Constants.EMPTY_STRING;
import static org.apache.dolphinscheduler.common.constants.Constants.SLEEP_TIME_MILLIS;
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_FAILURE;
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_HARD_KILL;
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_KILL;

import org.apache.dolphinscheduler.common.thread.ThreadUtils;
Expand Down Expand Up @@ -190,13 +191,13 @@ public TaskResponse run(IShellInterceptorBuilder iShellInterceptorBuilder,
result.setExitStatusCode(this.process.exitValue());

} else {
log.error("process has failure, the task timeout configuration value is:{}, ready to kill ...",
taskRequest.getTaskTimeout());
log.error("process has failure due to timeout kill, timeout value is:{}, timeoutStrategy is:{}",
taskRequest.getTaskTimeout(), taskRequest.getTaskTimeoutStrategy());
result.setExitStatusCode(EXIT_CODE_FAILURE);
cancelApplication();
}
int exitCode = this.process.exitValue();
String exitLogMessage = EXIT_CODE_KILL == exitCode ? "process has killed." : "process has exited.";
String exitLogMessage = (EXIT_CODE_KILL == exitCode || EXIT_CODE_HARD_KILL == exitCode) ? "process has killed."
: "process has exited.";
Comment on lines +199 to +200
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to check from status in taskExecutionContext rather then check from the exit code, we don't care about the exit, only kill from ds then we think it's kill.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to check from status in taskExecutionContext rather then check from the exit code, we don't care about the exit, only kill from ds then we think it's kill.

Here it simply outputs the final execution status of the process, indicating whether it exited normally or was killed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

log.info("{} execute path:{}, processId:{} ,exitStatusCode:{} ,processWaitForStatus:{} ,processExitValue:{}",
exitLogMessage, taskRequest.getExecutePath(), processId, result.getExitStatusCode(), status, exitCode);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,14 @@
// Get all child processes
String pids = getPidsStr(processId);
String[] pidArray = PID_PATTERN.split(pids);
if (pidArray.length == 0) {
if (StringUtils.isBlank(pids) || pidArray.length == 0) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ifStringUtils.isEmpty(pids) then we don't need to execute line 117.

log.warn("No valid PIDs found for process: {}", processId);
return true;
}

// Convert PID string to list of integers
List<Integer> pidList = Arrays.stream(pidArray).map(Integer::parseInt).collect(Collectors.toList());
List<Integer> pidList = Arrays.stream(pidArray).filter(StringUtils::isNotBlank).map(Integer::parseInt)
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
.collect(Collectors.toList());

// 1. Try to terminate gracefully (SIGINT)
boolean gracefulKillSuccess = sendKillSignal("SIGINT", pidList, request.getTenantCode());
Expand Down
Loading