Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,14 @@ private[spark] class ExecutorPodsAllocator(

private val namespace = conf.get(KUBERNETES_NAMESPACE)

private val kubernetesDriverPodName = conf
.get(KUBERNETES_DRIVER_POD_NAME)

private val shouldDeleteExecutors = conf.get(KUBERNETES_DELETE_EXECUTORS)

val driverPod = kubernetesDriverPodName
.map(name => Option(kubernetesClient.pods()
.withName(name)
.get())
val driverPod = conf.get(KUBERNETES_DRIVER_POD_NAME).map { name =>
Option(kubernetesClient.pods().withName(name).get())
.getOrElse(throw new SparkException(
s"No pod was found named $kubernetesDriverPodName in the cluster in the " +
s"namespace $namespace (this was supposed to be the driver pod.).")))
s"No pod was found named $name in the cluster in the " +
s"namespace $namespace (this was supposed to be the driver pod.)."))
}

// Executor IDs that have been requested from Kubernetes but have not been detected in any
// snapshot yet. Mapped to the (ResourceProfile id, timestamp) when they were created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import org.mockito.stubbing.Answer
import org.scalatest.BeforeAndAfter
import org.scalatest.PrivateMethodTester._

import org.apache.spark.{SecurityManager, SparkConf, SparkFunSuite}
import org.apache.spark.{SecurityManager, SparkConf, SparkException, SparkFunSuite}
import org.apache.spark.deploy.k8s.{KubernetesExecutorConf, KubernetesExecutorSpec}
import org.apache.spark.deploy.k8s.Config._
import org.apache.spark.deploy.k8s.Constants._
Expand Down Expand Up @@ -653,6 +653,18 @@ class ExecutorPodsAllocatorSuite extends SparkFunSuite with BeforeAndAfter {
verify(persistentVolumeClaims, never()).create(any())
}

test("print the pod name instead of Some(name) if pod is absent") {
val nonexistentPod = "i-do-not-exist"
val conf = new SparkConf().set(KUBERNETES_DRIVER_POD_NAME, nonexistentPod)
when(kubernetesClient.pods()).thenReturn(podOperations)
when(podOperations.withName(nonexistentPod)).thenReturn(driverPodOperations)
when(driverPodOperations.get()).thenReturn(null)
val e = intercept[SparkException](new ExecutorPodsAllocator(
conf, secMgr, executorBuilder, kubernetesClient, snapshotsStore, waitForExecutorPodsClock))
assert(e.getMessage.contains("No pod was found named i-do-not-exist in the cluster in the" +
" namespace default"))
}

private def executorPodAnswer(): Answer[KubernetesExecutorSpec] =
(invocation: InvocationOnMock) => {
val k8sConf: KubernetesExecutorConf = invocation.getArgument(0)
Expand Down