sarutak commented on code in PR #56274:
URL: https://github.com/apache/spark/pull/56274#discussion_r3345126824
##########
resource-managers/yarn/src/main/scala/org/apache/spark/scheduler/cluster/YarnClientSchedulerBackend.scala:
##########
@@ -135,6 +136,10 @@ private[spark] class YarnClientSchedulerBackend(
} catch {
case _: InterruptedException | _: InterruptedIOException =>
logInfo("Interrupting monitor thread")
+ case NonFatal(e) =>
+ logError("Unexpected error in YARN application state monitor
thread.", e)
+ allowInterrupt = false
+ sc.stop()
Review Comment:
Should we exit JVM here like as follows?
```scala
if (conf.get(AM_CLIENT_MODE_EXIT_ON_ERROR)) {
System.exit(1)
}
```
##########
resource-managers/yarn/src/main/scala/org/apache/spark/scheduler/cluster/YarnClientSchedulerBackend.scala:
##########
@@ -135,6 +136,10 @@ private[spark] class YarnClientSchedulerBackend(
} catch {
case _: InterruptedException | _: InterruptedIOException =>
logInfo("Interrupting monitor thread")
+ case NonFatal(e) =>
+ logError("Unexpected error in YARN application state monitor
thread.", e)
Review Comment:
Can we use the structured logging API like `logError(log"...")`?
##########
resource-managers/yarn/src/test/scala/org/apache/spark/scheduler/cluster/YarnClientSchedulerBackendSuite.scala:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.spark.scheduler.cluster
+
+import java.util.concurrent.{CountDownLatch, TimeUnit}
+
+import org.mockito.ArgumentMatchers.{anyBoolean, anyLong}
+import org.mockito.Mockito.{mock, when}
+
+import org.apache.spark._
+import org.apache.spark.deploy.yarn.Client
+import org.apache.spark.scheduler.{SparkListener, SparkListenerApplicationEnd,
TaskSchedulerImpl}
+
+class YarnClientSchedulerBackendSuite extends SparkFunSuite with
LocalSparkContext {
+
+ test("SPARK-57191: MonitorThread calls sc.stop() on unexpected exception") {
+ val stopCalled = new CountDownLatch(1)
+ sc = new SparkContext("local", "test", new
SparkConf().set("spark.testing", "true"))
+ sc.addSparkListener(new SparkListener {
+ override def onApplicationEnd(e: SparkListenerApplicationEnd): Unit =
+ stopCalled.countDown()
+ })
+
+ val backend = new YarnClientSchedulerBackend(
+ sc.taskScheduler.asInstanceOf[TaskSchedulerImpl], sc)
+
+ // Simulate MonitorThread hitting a fatal error (e.g., credential expiry,
network failure)
Review Comment:
`fatal error` -> `unexpected non-fatal error`?
--
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]