in computer-k8s-operator/src/main/java/org/apache/hugegraph/computer/k8s/operator/controller/ComputerJobController.java [527:561]
private String getErrorLog(List<Pod> pods) {
for (Pod pod : pods) {
String namespace = pod.getMetadata().getNamespace();
String name = pod.getMetadata().getName();
if (pod.getStatus() != null &&
PodPhase.FAILED.value().equals(pod.getStatus().getPhase())) {
KubernetesClient client = this.kubeClient;
if (!Objects.equals(this.kubeClient.getNamespace(),
namespace)) {
client = this.kubeClient.inNamespace(namespace);
}
String log;
try {
log = client.pods().withName(name)
.tailingLines(ERROR_LOG_TAILING_LINES)
.getLog(true);
} catch (KubernetesClientException e) {
if (e.getCode() == HttpURLConnection.HTTP_NOT_FOUND) {
// Fixed the pod deleted when job failed
continue;
} else {
throw e;
}
}
if (StringUtils.isNotBlank(log) &&
!log.contains("Unable to retrieve container logs")) {
return log + "\n podName:" + pod.getMetadata().getName() +
"\n nodeIp:" + pod.getStatus().getHostIP();
}
}
}
return StringUtils.EMPTY;
}