use of com.epam.pipeline.entity.pipeline.TaskStatus in project cloud-pipeline by epam.
the class RunLogManager method saveLog.
@Transactional(propagation = Propagation.REQUIRED)
public RunLog saveLog(final RunLog runLog) {
Assert.notNull(runLog.getRunId(), messageHelper.getMessage(MessageConstants.ERROR_PARAMETER_REQUIRED, "runId", RunLog.class.getSimpleName()));
Assert.notNull(runLog.getDate(), messageHelper.getMessage(MessageConstants.ERROR_PARAMETER_REQUIRED, "date", RunLog.class.getSimpleName()));
Assert.notNull(runLog.getStatus(), messageHelper.getMessage(MessageConstants.ERROR_PARAMETER_REQUIRED, "status", RunLog.class.getSimpleName()));
PipelineRun run = pipelineRunDao.loadPipelineRun(runLog.getRunId());
Assert.notNull(run, messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_NOT_FOUND, runLog.getRunId()));
if (!StringUtils.isEmpty(runLog.getLogText())) {
runLog.setLogText(runLog.getLogText().replaceAll("\\u0000", ""));
}
// Check previous status, it may differ from pod status as error may occur during
// results upload to s3
TaskStatus statusToSave = runLog.getStatus();
if (!StringUtils.isEmpty(runLog.getTaskName())) {
PipelineTask task = self.loadPreviousTaskStatus(run, runLog);
if (task != null && task.getStatus().isFinal()) {
statusToSave = task.getStatus();
}
}
// this status
if (!statusToSave.isFinal() && run.getStatus().isFinal()) {
statusToSave = run.getStatus();
}
runLog.setStatus(statusToSave);
runLogDao.createRunLog(runLog);
return runLog;
}
use of com.epam.pipeline.entity.pipeline.TaskStatus in project cloud-pipeline by epam.
the class PodMonitor method getPodLogs.
private void getPodLogs(PipelineRun pipelineRun, KubernetesClient client, Pod pod) {
String log = "";
TaskStatus status = getStatus(pipelineRun, pod);
String instance = pod == null ? pipelineRun.getPodId() : pod.getMetadata().getName();
try {
if (pod != null) {
LOGGER.debug("LOGS FOR POD: " + pod.getMetadata().getName());
log = client.pods().inNamespace(kubeNamespace).withName(pod.getMetadata().getName()).getLog();
}
} catch (KubernetesClientException e) {
LOGGER.debug(e.getMessage(), e);
} finally {
saveLog(pipelineRun, instance, log, status);
}
}
Aggregations