Skip to content

Commit ee142c0

Browse files
yaooqinnfishcus
authored andcommitted
[MINOR][K8S] Print the driver pod name instead of Some(name) if absent
Print the driver pod name instead of Some(name) if absent fix error hint no new test Closes apache#32889 from yaooqinn/minork8s. Authored-by: Kent Yao <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 1125afd) Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 38ec106 commit ee142c0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private[spark] class ExecutorPodsAllocator(
7878
.withName(name)
7979
.get())
8080
.getOrElse(throw new SparkException(
81-
s"No pod was found named $kubernetesDriverPodName in the cluster in the " +
81+
s"No pod was found named $name in the cluster in the " +
8282
s"namespace $namespace (this was supposed to be the driver pod.).")))
8383

8484
// Executor IDs that have been requested from Kubernetes but have not been detected in any

resource-managers/kubernetes/core/src/test/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocatorSuite.scala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import org.mockito.invocation.InvocationOnMock
2828
import org.mockito.stubbing.Answer
2929
import org.scalatest.BeforeAndAfter
3030

31-
import org.apache.spark.{SecurityManager, SparkConf, SparkFunSuite}
31+
import org.apache.spark.{SecurityManager, SparkConf, SparkException, SparkFunSuite}
3232
import org.apache.spark.deploy.k8s.{KubernetesExecutorConf, KubernetesExecutorSpec}
3333
import org.apache.spark.deploy.k8s.Config._
3434
import org.apache.spark.deploy.k8s.Constants._
@@ -570,6 +570,18 @@ class ExecutorPodsAllocatorSuite extends SparkFunSuite with BeforeAndAfter {
570570
verify(podOperations).create(podWithAttachedContainerForId(6))
571571
}
572572

573+
test("print the pod name instead of Some(name) if pod is absent") {
574+
val nonexistentPod = "i-do-not-exist"
575+
val conf = new SparkConf().set(KUBERNETES_DRIVER_POD_NAME, nonexistentPod)
576+
when(kubernetesClient.pods()).thenReturn(podOperations)
577+
when(podOperations.withName(nonexistentPod)).thenReturn(driverPodOperations)
578+
when(driverPodOperations.get()).thenReturn(null)
579+
val e = intercept[SparkException](new ExecutorPodsAllocator(
580+
conf, secMgr, executorBuilder, kubernetesClient, snapshotsStore, waitForExecutorPodsClock))
581+
assert(e.getMessage.contains("No pod was found named i-do-not-exist in the cluster in the" +
582+
" namespace default"))
583+
}
584+
573585
private def executorPodAnswer(): Answer[KubernetesExecutorSpec] =
574586
(invocation: InvocationOnMock) => {
575587
val k8sConf: KubernetesExecutorConf = invocation.getArgument(0)

0 commit comments

Comments
 (0)