pan3793 commented on code in PR #7025:
URL: https://github.com/apache/kyuubi/pull/7025#discussion_r2046175094


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala:
##########
@@ -502,8 +502,12 @@ object KubernetesApplicationOperation extends Logging {
       .map(_.getState)
       .map(containerStateToApplicationState)
 
-    // When the pod app state is terminated, the container app state will be 
ignored
-    val applicationState = if (ApplicationState.isTerminated(podAppState)) {
+    // 1. if the container state is already terminated, use the container state
+    // 2. if the pod state is terminated, use the pod state and ignore the 
container state
+    // 3. otherwise, use the container state if it exists or the pod state
+    val applicationState = if 
(containerAppState.exists(ApplicationState.isTerminated)) {

Review Comment:
   can you rewrite it with the pattern match? I think the logic is clearer than 
if else
   ```
   containerAppStateOpt match {
     // for cases that spark container already terminated, but sidecar 
containers live
     case Some(containerAppState) if 
ApplicationState.isTerminated(containerAppState) =>
       containerAppState
     // we don't need to care about container state if pod is already terminated
     case podAppState => ApplicationState.isTerminated(podAppState) =>
       podAppState
     case Some(containerAppState) =>
       containerAppState
     case None =>
       podAppState
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@kyuubi.apache.org
For additional commands, e-mail: notifications-h...@kyuubi.apache.org

Reply via email to