attilapiros commented on code in PR #37990:
URL: https://github.com/apache/spark/pull/37990#discussion_r981696574


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/KubernetesClusterSchedulerBackend.scala:
##########
@@ -193,22 +197,19 @@ private[spark] class KubernetesClusterSchedulerBackend(
     conf.get(KUBERNETES_EXECUTOR_DECOMMISSION_LABEL).foreach { label =>
       val labelTask = new Runnable() {
         override def run(): Unit = Utils.tryLogNonFatalError {
-
-          val podsToLabel = kubernetesClient.pods()
+          kubernetesClient.pods()
+            .inNamespace(namespace)
             .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_DECOMMISSION_LABEL_VALUE).getOrElse(""))
-                .endMetadata()
-                .build()})
+            .resources()

Review Comment:
   Adding the `KUBERNETES_EXECUTOR_DECOMMISSION_LABEL_VALUE ` label was earlier 
done in two phases:
   - Using `list().getItems().asScala` which resulted into a Scala List of 
`Pod`. 
   - Iterating over the list and getting the Pods again one by one  using the 
name (using `withName`) and namespace (using `inNamespace `)  
   
   Now with the `resources()` and `forEach` the above two is merged into a 
single DSL expression.  



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to