diff options
author | Denny <dennybritz@gmail.com> | 2012-10-13 13:57:59 -0700 |
---|---|---|
committer | Denny <dennybritz@gmail.com> | 2012-10-13 13:57:59 -0700 |
commit | 0700d1920a4a33648b7461f1ca64e3a94638ad65 (patch) | |
tree | 5152d033e3ef2901d000b4f72de3d788ebef3f79 | |
parent | 21047d923e4364023c556250c9f1cfbab6cc68ff (diff) | |
download | spark-0700d1920a4a33648b7461f1ca64e3a94638ad65.tar.gz spark-0700d1920a4a33648b7461f1ca64e3a94638ad65.tar.bz2 spark-0700d1920a4a33648b7461f1ca64e3a94638ad65.zip |
Protect from null env variables in mesos.
-rw-r--r-- | core/src/main/scala/spark/scheduler/mesos/CoarseMesosSchedulerBackend.scala | 12 | ||||
-rw-r--r-- | core/src/main/scala/spark/scheduler/mesos/MesosSchedulerBackend.scala | 12 |
2 files changed, 16 insertions, 8 deletions
diff --git a/core/src/main/scala/spark/scheduler/mesos/CoarseMesosSchedulerBackend.scala b/core/src/main/scala/spark/scheduler/mesos/CoarseMesosSchedulerBackend.scala index cb378e62fc..29dd36be15 100644 --- a/core/src/main/scala/spark/scheduler/mesos/CoarseMesosSchedulerBackend.scala +++ b/core/src/main/scala/spark/scheduler/mesos/CoarseMesosSchedulerBackend.scala @@ -114,11 +114,15 @@ private[spark] class CoarseMesosSchedulerBackend( val command = "\"%s\" spark.executor.StandaloneExecutorBackend %s %s %s %d".format( runScript, masterUrl, offer.getSlaveId.getValue, offer.getHostname, numCores) val environment = Environment.newBuilder() - sc.executorEnvs.foreach { case(k,v) => - environment.addVariables(Environment.Variable.newBuilder() - .setName(k) - .setValue(v) + sc.executorEnvs.foreach { case(key, value) => + if (value == null) { + logInfo("Environment variable not set: " + key) + } else { + environment.addVariables(Environment.Variable.newBuilder() + .setName(key) + .setValue(value) .build()) + } } return CommandInfo.newBuilder().setValue(command).setEnvironment(environment).build() } diff --git a/core/src/main/scala/spark/scheduler/mesos/MesosSchedulerBackend.scala b/core/src/main/scala/spark/scheduler/mesos/MesosSchedulerBackend.scala index 055ad7b728..c4aee5c9cb 100644 --- a/core/src/main/scala/spark/scheduler/mesos/MesosSchedulerBackend.scala +++ b/core/src/main/scala/spark/scheduler/mesos/MesosSchedulerBackend.scala @@ -85,11 +85,15 @@ private[spark] class MesosSchedulerBackend( } val execScript = new File(sparkHome, "spark-executor").getCanonicalPath val environment = Environment.newBuilder() - sc.executorEnvs.foreach { case(k,v) => - environment.addVariables(Environment.Variable.newBuilder() - .setName(k) - .setValue(v) + sc.executorEnvs.foreach { case(key, value) => + if (value == null) { + logInfo("Environment variable not set: " + key) + } else { + environment.addVariables(Environment.Variable.newBuilder() + .setName(key) + .setValue(value) .build()) + } } val memory = Resource.newBuilder() .setName("mem") |