Skip to content

Commit a3b2a5a

Browse files
committed
comments
1 parent 4356d1b commit a3b2a5a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -498,19 +498,18 @@ object KubernetesApplicationOperation extends Logging {
498498
}
499499

500500
val podAppState = podStateToApplicationState(pod.getStatus.getPhase)
501-
val containerAppState = containerStatusToBuildAppState
501+
val containerAppStateOpt = containerStatusToBuildAppState
502502
.map(_.getState)
503503
.map(containerStateToApplicationState)
504504

505-
// 1. if the container state is already terminated, use the container state
506-
// 2. if the pod state is terminated, use the pod state and ignore the container state
507-
// 3. otherwise, use the container state if it exists or the pod state
508-
val applicationState = if (containerAppState.exists(ApplicationState.isTerminated)) {
509-
containerAppState.get
510-
} else if (ApplicationState.isTerminated(podAppState)) {
511-
podAppState
512-
} else {
513-
containerAppState.getOrElse(podAppState)
505+
val applicationState = containerAppStateOpt match {
506+
// for cases that spark container already terminated, but sidecar containers live
507+
case Some(containerAppState)
508+
if ApplicationState.isTerminated(containerAppState) => containerAppState
509+
// we don't need to care about container state if pod is already terminated
510+
case _ if ApplicationState.isTerminated(podAppState) => podAppState
511+
case Some(containerAppState) => containerAppState
512+
case None => podAppState
514513
}
515514
val applicationError =
516515
if (ApplicationState.isFailed(applicationState)) {

0 commit comments

Comments
 (0)