Skip to content

Commit dacb685

Browse files
committed
[SPARK-59914][K8S] Make ExecutorResizePlugin skip executor pods with the placeholder EXECID label
(cherry picked from commit d0fe25b) Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 5885bed commit dacb685

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

‎resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorResizePlugin.scala‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,17 @@ class ExecutorResizeDriverPlugin extends DriverPlugin with Logging {
106106
.list()
107107
.getItems.asScala
108108

109-
pods.filter(_.getMetadata.getLabels.get(SPARK_EXECUTOR_ID_LABEL) != null).foreach { pod =>
110-
val execId = pod.getMetadata.getLabels.get(SPARK_EXECUTOR_ID_LABEL)
109+
val executorPods = pods.flatMap { pod =>
110+
pod.getMetadata.getLabels.get(SPARK_EXECUTOR_ID_LABEL) match {
111+
case "EXECID" | null =>
112+
// The exec label has not yet been assigned
113+
None
114+
case id =>
115+
Some((id, pod))
116+
}
117+
}
118+
119+
executorPods.foreach { case (execId, pod) =>
111120
try {
112121
val metrics = kubernetesClient.top().pods().metrics(namespace, pod.getMetadata.getName)
113122

‎resource-managers/kubernetes/core/src/test/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorResizePluginSuite.scala‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,24 @@ class ExecutorResizePluginSuite
149149
verify(podMetricOperations, never()).metrics(anyString(), anyString())
150150
}
151151

152+
test("Pod with placeholder executor ID label should be skipped") {
153+
val plugin = createPlugin()
154+
val pod = new PodBuilder()
155+
.withNewMetadata()
156+
.withName("spark-executor-1")
157+
.addToLabels(SPARK_APP_ID_LABEL, appId)
158+
.addToLabels(SPARK_ROLE_LABEL, SPARK_POD_EXECUTOR_ROLE)
159+
.addToLabels(SPARK_EXECUTOR_ID_LABEL, "EXECID")
160+
.endMetadata()
161+
.build()
162+
163+
when(podList.getItems).thenReturn(Collections.singletonList(pod))
164+
165+
plugin.invokePrivate(_checkAndIncreaseMemory(namespace, 0.9, 0.1, kubernetesClient))
166+
167+
verify(podMetricOperations, never()).metrics(anyString(), anyString())
168+
}
169+
152170
test("SPARK-59840: Inactive executor pods are excluded from the listing") {
153171
val plugin = createPlugin()
154172
when(podList.getItems).thenReturn(Collections.emptyList())

0 commit comments

Comments
 (0)