dongjoon-hyun commented on code in PR #45613:
URL: https://github.com/apache/spark/pull/45613#discussion_r1532200417


##########
core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala:
##########
@@ -984,20 +984,39 @@ private[spark] class SparkSubmit extends Logging {
         e
     }
 
+    //    this variable is used to judge whether driver pod is normal if spark 
is on k8s
+    var DriverPodIsNormal: Boolean = if (args.master.startsWith("k8s")) true 
else false
+    var driverThrow: Throwable = null
     try {
       app.start(childArgs.toArray, sparkConf)
     } catch {
       case t: Throwable =>
-        throw findCause(t)
+        logWarning("Some ERR/Exception happened when app is running.")
+        if (args.master.startsWith("k8s")) {
+          DriverPodIsNormal = false
+          driverThrow = t
+        } else {
+          throw findCause(t)
+        }
     } finally {
       if (args.master.startsWith("k8s") && !isShell(args.primaryResource) &&
           !isSqlShell(args.mainClass) && !isThriftServer(args.mainClass) &&
           !isConnectServer(args.mainClass)) {
         try {
+          logWarning("Begin to close SparkContext inside driver pod......")
           SparkContext.getActive.foreach(_.stop())
         } catch {
           case e: Throwable => logError(s"Failed to close SparkContext: $e")
-        }
+        } finally {
+          if (SparkContext.getActive.isEmpty) {
+            logWarning("Finished to close SparkContext inside driver pod 
successfully.")
+            if (!DriverPodIsNormal) {
+              logError(s"Driver Pod will exit because: $driverThrow")
+              System.exit(1)
+            }
+          } else {
+            logWarning("Failed to close SparkContext.")

Review Comment:
   May I ask when does this happen actually? And, what was the previous 
behavior?



-- 
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