Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1005,17 +1005,20 @@ private[spark] class SparkSubmit extends Logging {
e
}

var exitCode = 0

try {
app.start(childArgs.toArray, sparkConf)
} catch {
case t: Throwable =>
exitCode = -1
throw findCause(t)
} finally {
if (args.master.startsWith("k8s") && !isShell(args.primaryResource) &&
!isSqlShell(args.mainClass) && !isThriftServer(args.mainClass) &&
!isConnectServer(args.mainClass)) {
if ((args.master.startsWith("k8s") || args.master.startsWith("yarn")) &&
!isShell(args.primaryResource) && !isSqlShell(args.mainClass) &&
!isThriftServer(args.mainClass) && !isConnectServer(args.mainClass)) {
try {
SparkContext.getActive.foreach(_.stop())
SparkContext.getActive.foreach(_.stop(exitCode))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is related to YARN AM because this is guarded by if (args.master.startsWith("k8s"). Is this K8s patch instead of YARN AM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code in spark-3.1.2 is

      if (!isShell(args.primaryResource) && !isSqlShell(args.mainClass) &&
        !isThriftServer(args.mainClass)) {

Seems #33403 change the behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know too much about K8S scheduler, but for yarn client mode we also need to keep a same exit code.

} catch {
case e: Throwable => logError(s"Failed to close SparkContext: $e")
}
Expand Down