Github user vanzin commented on a diff in the pull request: https://github.com/apache/spark/pull/2516#discussion_r18911964 --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmitDriverBootstrapper.scala --- @@ -50,71 +51,69 @@ private[spark] object SparkSubmitDriverBootstrapper { val javaOpts = sys.env("JAVA_OPTS") val defaultDriverMemory = sys.env("OUR_JAVA_MEM") - // Spark submit specific environment variables - val deployMode = sys.env("SPARK_SUBMIT_DEPLOY_MODE") - val propertiesFile = sys.env("SPARK_SUBMIT_PROPERTIES_FILE") + // SPARK_SUBMIT_BOOTSTRAP_DRIVER is used for runtime validation val bootstrapDriver = sys.env("SPARK_SUBMIT_BOOTSTRAP_DRIVER") - val submitDriverMemory = sys.env.get("SPARK_SUBMIT_DRIVER_MEMORY") - val submitLibraryPath = sys.env.get("SPARK_SUBMIT_LIBRARY_PATH") - val submitClasspath = sys.env.get("SPARK_SUBMIT_CLASSPATH") - val submitJavaOpts = sys.env.get("SPARK_SUBMIT_OPTS") + + // list of environment variables that override differently named properties + val envOverides = Map( "OUR_JAVA_MEM" -> SPARK_DRIVER_MEMORY, + "SPARK_SUBMIT_DEPLOY_MODE" -> SPARK_DEPLOY_MODE, + "SPARK_SUBMIT_DRIVER_MEMORY" -> SPARK_DRIVER_MEMORY, + "SPARK_SUBMIT_LIBRARY_PATH" -> SPARK_DRIVER_EXTRA_LIBRARY_PATH, + "SPARK_SUBMIT_CLASSPATH" -> SPARK_DRIVER_EXTRA_CLASSPATH, + "SPARK_SUBMIT_OPTS" -> SPARK_DRIVER_EXTRA_JAVA_OPTIONS + ) + + /* SPARK_SUBMIT environment variables are treated as the highest priority source + * of config information for their respective config variable (as listed in envOverrides) + */ + val submitEnvVars = new HashMap() ++ envOverides + .map { case(varName, propName) => (sys.env.get(varName), propName) } + .filter { case(variable, _) => variable.isDefined } + .map { case(variable, propName) => propName -> variable.get } + + // Property file loading comes after all SPARK* env variables are processed and should not + // overwrite existing SPARK env variables + sys.env.get("SPARK_SUBMIT_PROPERTIES_FILE") + .flatMap ( Utils.getFileIfExists ) + .map ( Utils.loadPropFile ) + .getOrElse(Map.empty) + .foreach { case(k,v) => + submitEnvVars.getOrElseUpdate(k,v) + } + + /* See docco for SparkSubmitArguments to see the various config sources and their priority. --- End diff -- alignment is wrong, also, use single-line comments.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org