holdenk commented on a change in pull request #32289:
URL: https://github.com/apache/spark/pull/32289#discussion_r673499689



##########
File path: 
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/PodStatusWatcher.scala
##########
@@ -82,11 +94,29 @@ private[k8s] class LoggingPodStatusWatcherImpl(conf: 
KubernetesDriverConf)
     closeWatch()
   }
 
+  private def notifyStatusChanged(): Unit = {
+    if (phase != latestPhase) {
+      latestPhase = phase
+      latestPhase match {
+        case "Pending" => reportStatusChanged(SparkAppHandle.State.SUBMITTED)
+        case "Running" => reportStatusChanged(SparkAppHandle.State.RUNNING)
+        case "Succeeded" => reportStatusChanged(SparkAppHandle.State.FINISHED)
+        case "Failed" => reportStatusChanged(SparkAppHandle.State.FAILED)
+        case "Unknown" => reportStatusChanged(SparkAppHandle.State.LOST)
+        case _ => reportStatusChanged(SparkAppHandle.State.UNKNOWN)

Review comment:
       Why is Unknown lost? wouldn't it be unknown?

##########
File path: 
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/PodStatusWatcher.scala
##########
@@ -47,21 +49,31 @@ private[k8s] class LoggingPodStatusWatcherImpl(conf: 
KubernetesDriverConf)
 
   private var pod = Option.empty[Pod]
 
+  private var launcherBackend = Option.empty[LauncherBackend]
+
+  private var latestPhase: String = _
+
   private def phase: String = 
pod.map(_.getStatus.getPhase).getOrElse("unknown")
 
   override def reset(): Unit = {
     resourceTooOldReceived = false
   }
 
+  override def registerLauncherBackend(launcherBackend: LauncherBackend): Unit 
= {
+    this.launcherBackend = Option(launcherBackend)
+  }
+
   override def eventReceived(action: Action, pod: Pod): Unit = {
     this.pod = Option(pod)
     action match {
       case Action.DELETED | Action.ERROR =>
+        notifyStatusChanged()

Review comment:
       If we do this every time (e.g. in the Action.DELTED or Action.ERROR or _ 
case), maybe just move it out of the match?

##########
File path: 
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/PodStatusWatcher.scala
##########
@@ -82,11 +94,29 @@ private[k8s] class LoggingPodStatusWatcherImpl(conf: 
KubernetesDriverConf)
     closeWatch()
   }
 
+  private def notifyStatusChanged(): Unit = {
+    if (phase != latestPhase) {
+      latestPhase = phase
+      latestPhase match {
+        case "Pending" => reportStatusChanged(SparkAppHandle.State.SUBMITTED)
+        case "Running" => reportStatusChanged(SparkAppHandle.State.RUNNING)
+        case "Succeeded" => reportStatusChanged(SparkAppHandle.State.FINISHED)
+        case "Failed" => reportStatusChanged(SparkAppHandle.State.FAILED)
+        case "Unknown" => reportStatusChanged(SparkAppHandle.State.LOST)
+        case _ => reportStatusChanged(SparkAppHandle.State.UNKNOWN)

Review comment:
       Why is Unknown lost? wouldn't it be unknown?




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to