Github user uncleGen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16827#discussion_r99743099
  
    --- Diff: core/src/main/scala/org/apache/spark/SparkConf.scala ---
    @@ -779,6 +781,30 @@ private[spark] object SparkConf extends Logging {
       }
     
       /**
    +   * check if the given config key-value is valid.
    +   */
    +  def checkValidSetting(key: String, value: String, conf: SparkConf): Unit 
= {
    +    if (key.equals("spark.master")) {
    +      // First, there is no need to set 'spark.master' multi-times with 
different values.
    +      // Second, It is possible for users to set the different 
'spark.master' in code with
    +      // `spark-submit` command, and will confuse users.
    +      // So, we should do once check if the 'spark.master' already exists 
in settings and if
    +      // the previous value is the same with current value. Throw a 
IllegalArgumentException when
    +      // previous value is different with current value.
    +      val previousOne = try {
    +        Some(conf.get(key))
    +      } catch {
    +        case e: NoSuchElementException =>
    +          None
    +      }
    +      if (previousOne.isDefined && !previousOne.get.equals(value)) {
    +        throw new IllegalArgumentException(s"'spark.master' should not be 
set with different " +
    +          s"value, previous value is ${previousOne.get} and current value 
is $value")
    +      }
    --- End diff --
    
    here, we choose to throw IllegalArgumentException to fail job. Besides, we 
can also choose to log a warning in a gentle way.


---
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

Reply via email to