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

    https://github.com/apache/spark/pull/14926#discussion_r79199040
  
    --- Diff: 
core/src/main/scala/org/apache/spark/ExecutorAllocationManager.scala ---
    @@ -392,10 +397,70 @@ private[spark] class ExecutorAllocationManager(
       }
     
       /**
    +   * Request the cluster manager to remove the given executors.
    +   * Return whether the request is acknowledged. Ideally we should be 
returning the list of
    +   * executors which were removed as the requested executors and the one's 
actually removed can be
    +   * different (CoarseGrainedSchedulerBackend can filter some executors). 
To avoid breaking the API
    +   * we continue to return a Boolean.
    +   */
    +  private def removeExecutors(executors: Seq[String]): Boolean = 
synchronized {
    +
    +    val executorIdsToBeRemoved = new ArrayBuffer[String]
    +
    +    logInfo("Request to remove executorIds: " + executors.mkString(", "))
    +    val numExistingExecutors = executorIds.size - 
executorsPendingToRemove.size
    +    for(executorId <- executors) {
    +      // Do not kill the executor if we have already reached the lower 
bound
    +      val newExecutorTotal = numExistingExecutors - 
executorIdsToBeRemoved.size
    +      if (newExecutorTotal - 1 < minNumExecutors) {
    +        logDebug(s"Not removing idle executor $executorId because there 
are only " +
    +          s"$numExistingExecutors executor(s) left (limit 
$minNumExecutors)")
    +      } else if (canBeKilled(executorId)) {
    +        executorIdsToBeRemoved += executorId
    +      }
    +    }
    +
    +    if (executorIdsToBeRemoved.isEmpty) {
    +      return false
    +    }
    +
    +    // Send a request to the backend to kill this executor(s)
    +    val executorsRemoved = if (testing) {
    +      executorIdsToBeRemoved
    +    } else {
    +      client.killExecutors(executorIdsToBeRemoved)
    +    }
    +
    +    if (testing || executorsRemoved.nonEmpty) {
    +      val numExistingExecutors = allocationManager.executorIds.size - 
executorsPendingToRemove.size
    +      var index = 0
    +      for(index <- 0 until executorsRemoved.size) {
    --- End diff --
    
    I would like to keep the numExistingExecutors, its easier to skim through 
logs for validating sequential release of executors with dynamic allocation 
enabled. 


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