You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/07/15 15:50:51 UTC

[GitHub] [spark] attilapiros commented on a change in pull request #33270: [SPARK-35956][K8S] Support auto assigning labels to decommissioning pods

attilapiros commented on a change in pull request #33270:
URL: https://github.com/apache/spark/pull/33270#discussion_r670589774



##########
File path: resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/KubernetesClusterSchedulerBackend.scala
##########
@@ -181,7 +184,51 @@ private[spark] class KubernetesClusterSchedulerBackend(
     super.getExecutorIds()
   }
 
+  private def labelLowPriorityExecs(execIds: Seq[String]) = {
+    // Only kick off the labeling task if we have a label.
+    conf.get(KUBERNETES_EXECUTOR_POD_DECOMMISSION_LABEL).foreach { label =>
+      val labelTask = new Runnable() {
+        override def run(): Unit = Utils.tryLogNonFatalError {
+
+          val podsToLabel = kubernetesClient.pods()
+            .withLabel(SPARK_APP_ID_LABEL, applicationId())
+            .withLabel(SPARK_ROLE_LABEL, SPARK_POD_EXECUTOR_ROLE)
+            .withLabelIn(SPARK_EXECUTOR_ID_LABEL, execIds: _*)
+            .list().getItems().asScala
+
+          podsToLabel.foreach { pod =>
+            kubernetesClient.pods()
+              .inNamespace(pod.getMetadata.getNamespace)
+              .withName(pod.getMetadata.getName)
+              .edit({p: Pod => new PodBuilder(p).editMetadata()
+                .addToLabels(label, conf.get(KUBERNETES_EXECUTOR_POD_DECOMMISSION_LABEL_VALUE))
+                .endMetadata()
+                .build()})

Review comment:
       I am a bit uncertain now (and no time to try this out) but do we need the Pod filtering twice? I mean `podsToLabel` already contains`Pod` instances. So is there a reason why the following lines are not enough?
   
   ```suggestion
               new PodBuilder(pod).editMetadata()
                 .addToLabels(label, conf.get(KUBERNETES_EXECUTOR_POD_DECOMMISSION_LABEL_VALUE))
                 .endMetadata()
                 .build()
   ```
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org