abhishekagarwal87 commented on a change in pull request #11446:
URL: https://github.com/apache/druid/pull/11446#discussion_r672154705



##########
File path: 
indexing-service/src/main/java/org/apache/druid/indexing/overlord/ForkingTaskRunner.java
##########
@@ -364,38 +362,19 @@ public TaskStatus call()
                       );
 
                       LOGGER.info("Logging task %s output to: %s", 
task.getId(), logFile);
-                      boolean runFailed = true;
-
-                      final ByteSink logSink = Files.asByteSink(logFile, 
FileWriteMode.APPEND);
-
-                      // This will block for a while. So we append the thread 
information with more details
-                      final String priorThreadName = 
Thread.currentThread().getName();
-                      
Thread.currentThread().setName(StringUtils.format("%s-[%s]", priorThreadName, 
task.getId()));
-
-                      try (final OutputStream toLogfile = 
logSink.openStream()) {
-                        
ByteStreams.copy(processHolder.process.getInputStream(), toLogfile);
-                        final int statusCode = processHolder.process.waitFor();
-                        LOGGER.info("Process exited with status[%d] for task: 
%s", statusCode, task.getId());
-                        if (statusCode == 0) {
-                          runFailed = false;
-                        }
-                      }
-                      finally {
-                        Thread.currentThread().setName(priorThreadName);
-                        // Upload task logs
-                        taskLogPusher.pushTaskLog(task.getId(), logFile);
-                        if (reportsFile.exists()) {
-                          taskLogPusher.pushTaskReports(task.getId(), 
reportsFile);
-                        }
-                      }
-
-                      TaskStatus status;
-                      if (!runFailed) {
+                      final int exitCode = waitForTaskProcessToComplete(task, 
processHolder, logFile, reportsFile);
+                      final TaskStatus status;
+                      if (exitCode == 0) {
+                        LOGGER.info("Process exited successfully for task: 
%s", task.getId());
                         // Process exited successfully
                         status = jsonMapper.readValue(statusFile, 
TaskStatus.class);
                       } else {
+                        LOGGER.error("Process exited with code[%d] for task: 
%s", exitCode, task.getId());
                         // Process exited unsuccessfully
-                        status = TaskStatus.failure(task.getId());
+                        status = TaskStatus.failure(
+                            task.getId(),
+                            "Task execution process exited unsuccessfully. See 
middleManager logs for more details."

Review comment:
       do you want to add the exit code in the message here? 




-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to