diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala index 6afe3257be9..fcfadc11256 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala @@ -372,9 +372,22 @@ object KubernetesApplicationOperation extends Logging { } val applicationState = containerStateToBuildAppState.map(containerStateToApplicationState) .getOrElse(podStateToApplicationState(pod.getStatus.getPhase)) - val applicationError = containerStateToBuildAppState - .map(cs => containerStateToApplicationError(cs).map(r => s"$podName/$appStateContainer[$r]")) - .getOrElse(Option(pod.getStatus.getReason).map(r => s"$podName[$r]")) + val applicationError = if (ApplicationState.isFailed(applicationState)) { + containerStateToBuildAppState + .map(cs => + s""" + |Pod: $podName + |Container: $appStateContainer + |ContainerStatus: $cs + |""".stripMargin) + .orElse(Some( + s""" + |Pod: $podName + |PodStatus: ${pod.getStatus} + |""".stripMargin)) + } else { + None + } applicationState -> applicationError } @@ -393,12 +406,6 @@ object KubernetesApplicationOperation extends Logging { } } - def containerStateToApplicationError(containerState: ContainerState): Option[String] = { - // https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-states - Option(containerState.getWaiting).map(_.getReason) - .orElse(Option(containerState.getTerminated).map(_.getReason)) - } - def podStateToApplicationState(podState: String): ApplicationState = podState match { // https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase case "Pending" => PENDING