cchriswu commented on a change in pull request #32752:
URL: https://github.com/apache/spark/pull/32752#discussion_r644441333
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala
##########
@@ -99,6 +102,16 @@ private[spark] class ExecutorPodsAllocator(
@volatile private var deletedExecutorIds = Set.empty[Long]
def start(applicationId: String, schedulerBackend:
KubernetesClusterSchedulerBackend): Unit = {
+ // wait until the driver pod is ready to ensure executors can connect to
driver svc
Review comment:
Thank you for the review. Makes sense to me. Addressed in the newer
commit.
##########
File path:
resource-managers/kubernetes/core/src/test/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocatorSuite.scala
##########
@@ -104,6 +105,8 @@ class ExecutorPodsAllocatorSuite extends SparkFunSuite with
BeforeAndAfter {
when(kubernetesClient.pods()).thenReturn(podOperations)
when(podOperations.withName(driverPodName)).thenReturn(driverPodOperations)
when(driverPodOperations.get).thenReturn(driverPod)
+ when(driverPodOperations.waitUntilReady(anyInt(), any(classOf[TimeUnit])))
+ .thenReturn(driverPod)
Review comment:
Sure. Thanks!
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala
##########
@@ -99,6 +102,17 @@ private[spark] class ExecutorPodsAllocator(
@volatile private var deletedExecutorIds = Set.empty[Long]
def start(applicationId: String, schedulerBackend:
KubernetesClusterSchedulerBackend): Unit = {
+ // Wait until the driver pod is ready before starting executors, as the
headless service won't
+ // be resolvable by DNS until the driver pod is ready.
+ try {
+ kubernetesClient.pods()
+ .withName(kubernetesDriverPodName.get)
+ .waitUntilReady(driverPodReadinessTimeout, TimeUnit.MINUTES)
+ } catch {
+ case e: InterruptedException =>
+ logWarning(s"Timeout waiting for driver pod
${kubernetesDriverPodName.get} get ready in " +
+ s"namespace $namespace")
+ }
Review comment:
If we just do `logWarning` and continue to create executor pods after
this timeout, it's very likely executor pods will still hit the
`UnknownHostException` issue.
Considering this, throwing a SparkException may be more intuitive and
fail-fast. Please let me know your thoughts on this. Thanks.
Like here:
https://github.com/apache/spark/blob/0342dcb6289bae67f6ab742b8fd03b2d653e52ea/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala#L73-L79
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala
##########
@@ -99,6 +102,17 @@ private[spark] class ExecutorPodsAllocator(
@volatile private var deletedExecutorIds = Set.empty[Long]
def start(applicationId: String, schedulerBackend:
KubernetesClusterSchedulerBackend): Unit = {
+ // Wait until the driver pod is ready before starting executors, as the
headless service won't
+ // be resolvable by DNS until the driver pod is ready.
+ try {
+ kubernetesClient.pods()
+ .withName(kubernetesDriverPodName.get)
+ .waitUntilReady(driverPodReadinessTimeout, TimeUnit.MINUTES)
+ } catch {
+ case e: InterruptedException =>
+ logWarning(s"Timeout waiting for driver pod
${kubernetesDriverPodName.get} get ready in " +
+ s"namespace $namespace")
+ }
Review comment:
As the [JIRA issue](https://issues.apache.org/jira/browse/SPARK-32975)
describes, driver will not create new executors when this error happens.
> Once this error happens, driver doesn't restart executor.
However, other executors may be running fine. It's just that the number of
healthy executors will be less than expected. So I agree not to use
`SparkException` here.
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/Config.scala
##########
@@ -300,6 +300,17 @@ private[spark] object Config extends Logging {
.checkValue(value => value > 0, "Allocation batch delay must be a
positive time value.")
.createWithDefaultString("1s")
+ val KUBERNETES_ALLOCATION_DRIVER_READINESS_TIMEOUT =
+ ConfigBuilder("spark.kubernetes.allocation.driver.readinessTimeout")
+ .doc("Time to wait for driver pod to get ready before creating executor
pods. This wait " +
+ "only happens on application start. If timeout happens, executor pods
will still be " +
+ "created.")
+ .version("3.2.0")
Review comment:
Sure . No worries. Updated :)
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]