|
|
@ -205,6 +205,8 @@ public class K8sTaskExecutor extends AbstractK8sTaskExecutor { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void eventReceived(Action action, Job job) { |
|
|
|
public void eventReceived(Action action, Job job) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
LogUtils.setWorkflowAndTaskInstanceIDMDC(taskRequest.getProcessInstanceId(), |
|
|
|
|
|
|
|
taskRequest.getTaskInstanceId()); |
|
|
|
LogUtils.setTaskInstanceLogFullPathMDC(taskRequest.getLogPath()); |
|
|
|
LogUtils.setTaskInstanceLogFullPathMDC(taskRequest.getLogPath()); |
|
|
|
log.info("event received : job:{} action:{}", job.getMetadata().getName(), action); |
|
|
|
log.info("event received : job:{} action:{}", job.getMetadata().getName(), action); |
|
|
|
if (action == Action.DELETED) { |
|
|
|
if (action == Action.DELETED) { |
|
|
@ -222,14 +224,18 @@ public class K8sTaskExecutor extends AbstractK8sTaskExecutor { |
|
|
|
} |
|
|
|
} |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
LogUtils.removeTaskInstanceLogFullPathMDC(); |
|
|
|
LogUtils.removeTaskInstanceLogFullPathMDC(); |
|
|
|
|
|
|
|
LogUtils.removeWorkflowAndTaskInstanceIdMDC(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClose(WatcherException e) { |
|
|
|
public void onClose(WatcherException e) { |
|
|
|
|
|
|
|
LogUtils.setWorkflowAndTaskInstanceIDMDC(taskRequest.getProcessInstanceId(), |
|
|
|
|
|
|
|
taskRequest.getTaskInstanceId()); |
|
|
|
log.error("[K8sJobExecutor-{}] fail in k8s: {}", job.getMetadata().getName(), e.getMessage()); |
|
|
|
log.error("[K8sJobExecutor-{}] fail in k8s: {}", job.getMetadata().getName(), e.getMessage()); |
|
|
|
taskResponse.setExitStatusCode(EXIT_CODE_FAILURE); |
|
|
|
taskResponse.setExitStatusCode(EXIT_CODE_FAILURE); |
|
|
|
countDownLatch.countDown(); |
|
|
|
countDownLatch.countDown(); |
|
|
|
|
|
|
|
LogUtils.removeWorkflowAndTaskInstanceIdMDC(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
try (Watch watch = k8sUtils.createBatchJobWatcher(job.getMetadata().getName(), watcher)) { |
|
|
|
try (Watch watch = k8sUtils.createBatchJobWatcher(job.getMetadata().getName(), watcher)) { |
|
|
@ -260,10 +266,12 @@ public class K8sTaskExecutor extends AbstractK8sTaskExecutor { |
|
|
|
String containerName = String.format("%s-%s", taskName, taskInstanceId); |
|
|
|
String containerName = String.format("%s-%s", taskName, taskInstanceId); |
|
|
|
podLogOutputFuture = collectPodLogExecutorService.submit(() -> { |
|
|
|
podLogOutputFuture = collectPodLogExecutorService.submit(() -> { |
|
|
|
TaskOutputParameterParser taskOutputParameterParser = new TaskOutputParameterParser(); |
|
|
|
TaskOutputParameterParser taskOutputParameterParser = new TaskOutputParameterParser(); |
|
|
|
|
|
|
|
LogUtils.setWorkflowAndTaskInstanceIDMDC(taskRequest.getProcessInstanceId(), |
|
|
|
|
|
|
|
taskRequest.getTaskInstanceId()); |
|
|
|
|
|
|
|
LogUtils.setTaskInstanceLogFullPathMDC(taskRequest.getLogPath()); |
|
|
|
try ( |
|
|
|
try ( |
|
|
|
LogWatch watcher = ProcessUtils.getPodLogWatcher(taskRequest.getK8sTaskExecutionContext(), |
|
|
|
LogWatch watcher = ProcessUtils.getPodLogWatcher(taskRequest.getK8sTaskExecutionContext(), |
|
|
|
taskRequest.getTaskAppId(), containerName)) { |
|
|
|
taskRequest.getTaskAppId(), containerName)) { |
|
|
|
LogUtils.setTaskInstanceLogFullPathMDC(taskRequest.getLogPath()); |
|
|
|
|
|
|
|
String line; |
|
|
|
String line; |
|
|
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(watcher.getOutput()))) { |
|
|
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(watcher.getOutput()))) { |
|
|
|
while ((line = reader.readLine()) != null) { |
|
|
|
while ((line = reader.readLine()) != null) { |
|
|
|