Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.

Conversation

@hustcat
Copy link

@hustcat hustcat commented May 2, 2017

Add parameter for driver pod name. #252

@lins05
Copy link

lins05 commented May 3, 2017

This could be handy. One question: IIRC the reason of appending timestamps to driver pod name (as well as the driver service name, we use the same for them) is because pod/service names must be unique within the same k8s namespace and we want to avoid conflictions. So should we check if there is already a pod/service with the same name before launching the driver pod?

If so, maybe it's also worth adding an integration test?

@hustcat
Copy link
Author

hustcat commented May 4, 2017

If pod name is exist, k8s API server will return error for spark-submit, such as:

Exception in thread "main" io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://test.k8s:6443/api/v1/namespaces/dbyin/pods. Message: pods "spark-pi-001" already exists. Received status: Status(apiVersion=v1, code=409, details=StatusDetails(causes=[], group=null, kind=pods, name=spark-pi-001, retryAfterSeconds=null, additionalProperties={}), kind=Status, message=pods "spark-pi-001" already exists, metadata=ListMeta(resourceVersion=null, selfLink=null, additionalProperties={}), reason=AlreadyExists, status=Failure, additionalProperties={}).

I think this is what we expect. Of course, we can check it before create driver pod, but I think it's unnecessary, k8s API server do this is better when creating pod.

@foxish
Copy link
Member

foxish commented May 4, 2017

The parameter is currently marked internal in config.scala.
We should probably mark that as not being internal and add documentation if we want to expose it to the user.

  private[spark] val KUBERNETES_DRIVER_POD_NAME =
    ConfigBuilder("spark.kubernetes.driver.pod.name")
      .doc("Name of the driver pod.")
      .internal()
      .stringConf
      .createOptional

@foxish
Copy link
Member

foxish commented May 4, 2017

@hustcat
Copy link
Author

hustcat commented May 8, 2017

@foxish @lins05 Some updates, PTAL.

"Unexpected value for annotation2")
}

test("Run with driver pod name") {
Copy link
Member

@foxish foxish May 9, 2017

Choose a reason for hiding this comment

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

I wish we did not add more e2es and instead used unit tests better. This one is fine for now, but it's something to consider in the future.

@foxish
Copy link
Member

foxish commented May 9, 2017

LGTM. @lins05 @ash211 any comments?

private val appName = sparkConf.getOption("spark.app.name")
.getOrElse("spark")
private val kubernetesAppId = s"$appName-$launchTime".toLowerCase.replaceAll("\\.", "-")
private val kubernetesAppId = sparkConf.getOption("spark.kubernetes.driver.pod.name")
Copy link

Choose a reason for hiding this comment

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

the pod name spark.kubernetes.driver.pod.name and the app ID spark.app.id are slightly different -- I think the change on this line should be pulling from spark.app.id if we want to make the app ID configurable.

Given that this PR is about the pod name and not the app ID, maybe drop the change on this line and leave just the pod name configurable?

Copy link
Author

Choose a reason for hiding this comment

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

It's reasonable:)

private val appName = sparkConf.getOption("spark.app.name")
.getOrElse("spark")
private val kubernetesAppId = s"$appName-$launchTime".toLowerCase.replaceAll("\\.", "-")
private val kubernetesDriverPodName = sparkConf.getOption("spark.kubernetes.driver.pod.name")
Copy link

Choose a reason for hiding this comment

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

can you use KUBERNETES_DRIVER_POD_NAME here?

private val appName = sparkConf.getOption("spark.app.name")
.getOrElse("spark")
private val kubernetesAppId = s"$appName-$launchTime".toLowerCase.replaceAll("\\.", "-")
private val kubernetesDriverPodName = sparkConf.getOption("spark.kubernetes.driver.pod.name")
Copy link

Choose a reason for hiding this comment

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

and here?

Copy link

@ash211 ash211 left a comment

Choose a reason for hiding this comment

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

LGTM let's merge if tests pass

<td><code>spark.kubernetes.driver.pod.name</code></td>
<td><code>(none)</code></td>
<td>
Name of the driver pod
Copy link

Choose a reason for hiding this comment

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

Maybe add this: If not set, the driver pod name would be "spark.app.name" suffixed by a timestamp to avoid confliction with other spark apps.

Copy link
Member

Choose a reason for hiding this comment

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

Done. Thanks @lins05

@foxish foxish merged commit eb45ae5 into apache-spark-on-k8s:branch-2.1-kubernetes May 16, 2017
foxish pushed a commit that referenced this pull request Jul 24, 2017
* Add parameter for driver pod name

* Mark KUBERNETES_DRIVER_POD_NAME not being internal. Update docment.

* Add test case for driver pod name

* Diff driver pod name with appid

* replace 'spark.kubernetes.driver.pod.name` with KUBERNETES_DRIVER_POD_NAME

* Update readme to complete item
ifilonenko pushed a commit to ifilonenko/spark that referenced this pull request Feb 26, 2019
puneetloya pushed a commit to puneetloya/spark that referenced this pull request Mar 11, 2019
* Add parameter for driver pod name

* Mark KUBERNETES_DRIVER_POD_NAME not being internal. Update docment.

* Add test case for driver pod name

* Diff driver pod name with appid

* replace 'spark.kubernetes.driver.pod.name` with KUBERNETES_DRIVER_POD_NAME

* Update readme to complete item
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants