Skip to content

Commit

Permalink
Addressed review feedback: fixed the example in documentation; added …
Browse files Browse the repository at this point in the history
…'NETWORK_NAME' to config object.
  • Loading branch information
susanxhuynh committed Aug 11, 2017
1 parent 255e519 commit d261593
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/running-on-mesos.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ See the [configuration page](configuration.html) for information on Spark config
of key-value pairs, where each key-value pair has the format key:value.
Example:

<pre>key1=val1,key2=val2</pre>
<pre>key1:val1,key2:val2</pre>
See
<a href="http://mesos.apache.org/documentation/latest/cni/#mesos-meta-data-to-cni-plugins">the Mesos CNI docs</a>
for more details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ package object config {
.doubleConf
.createWithDefault(0.0)

private [spark] val NETWORK_NAME =
ConfigBuilder("spark.mesos.network.name")
.doc("Attach containers to the given named network. If this job is launched " +
"in cluster mode, also launch the driver in the given named network.")
.stringConf
.createOptional

private [spark] val NETWORK_LABELS =
ConfigBuilder("spark.mesos.network.labels")
.doc("Network labels to pass to CNI plugins. This is a comma-separated list " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ private[spark] class MesosCoarseGrainedSchedulerBackend(
}

private def executorHostname(offer: Offer): String = {
if (sc.conf.getOption("spark.mesos.network.name").isDefined) {
if (sc.conf.get(NETWORK_NAME).isDefined) {
// The agent's IP is not visible in a CNI container, so we bind to 0.0.0.0
"0.0.0.0"
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.apache.mesos.Protos.{ContainerInfo, Image, NetworkInfo, Parameter, Vo
import org.apache.mesos.Protos.ContainerInfo.{DockerInfo, MesosInfo}

import org.apache.spark.{SparkConf, SparkException}
import org.apache.spark.deploy.mesos.config._
import org.apache.spark.deploy.mesos.config.{NETWORK_LABELS, NETWORK_NAME}
import org.apache.spark.internal.Logging

/**
Expand Down Expand Up @@ -162,7 +162,7 @@ private[mesos] object MesosSchedulerBackendUtil extends Logging {
volumes.foreach(_.foreach(containerInfo.addVolumes(_)))
}

conf.getOption("spark.mesos.network.name").map { name =>
conf.get(NETWORK_NAME).map { name =>
val networkLabels = MesosProtoUtils.mesosLabels(conf.get(NETWORK_LABELS).getOrElse(""))
val info = NetworkInfo.newBuilder()
.setName(name)
Expand Down

0 comments on commit d261593

Please sign in to comment.