ruanwenjun commented on code in PR #17523:
URL:
https://github.com/apache/dolphinscheduler/pull/17523#discussion_r2365279592
##########
dolphinscheduler-task-executor/src/main/java/org/apache/dolphinscheduler/task/executor/container/AbstractTaskExecutorContainer.java:
##########
@@ -98,6 +102,7 @@ public void finalize(final ITaskExecutor taskExecutor) {
}
log.info(FINALIZE_SESSION_MARKER, FINALIZE_SESSION_MARKER.toString());
pushTaskExecutorLogToRemote(taskExecutor);
+ deleteExecPathIfProduction(taskExecutor);
Review Comment:
```suggestion
taskExecutor.finalize();
```
##########
dolphinscheduler-task-executor/src/main/java/org/apache/dolphinscheduler/task/executor/container/AbstractTaskExecutorContainer.java:
##########
@@ -145,4 +150,26 @@ private void pushTaskExecutorLogToRemote(final
ITaskExecutor taskExecutor) {
}
}
+ /**
+ * Delete task exec Directory if set development.state=false in
common.properties explicit
+ * otherwise keep it for debug reason.
+ */
+ private void deleteExecPathIfProduction(ITaskExecutor taskExecutor) {
+ boolean isDev = PropertyUtils.getBoolean(Constants.DEVELOPMENT_STATE,
true);
+ if (!isDev) {
+ try {
+ final TaskExecutionContext ctx =
taskExecutor.getTaskExecutionContext();
+ final String execPath = ctx.getExecutePath();
+ if (StringUtils.isNotEmpty(execPath)) {
+ FileUtils.deleteFile(execPath);
+ log.info("Deleted task exec directory: {}", execPath);
+ }
+ } catch (Exception e) {
+ log.warn("Failed to delete task exec directory in prod mode.",
e);
+ }
+ } else {
+ log.debug("Development mode is on, skip deleting executePath for
debug reason");
+ }
+ }
Review Comment:
It's better to add a `finalize` method in `ITaskExecutor` to clear the
`taskInstanceWorkingDirectory`.
We can add a method `clearTaskInstanceWorkingDirectory` in
`TaskExecutionContextUtils` to do the real clear logic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]