Skip to content

Commit 349e25b

Browse files
Stavros KontopoulosMarcelo Vanzin
authored andcommitted
[SPARK-26256][K8S] Fix labels for pod deletion
Adds proper labels when deleting executor pods. Manually with tests. Closes #23209 from skonto/fix-deletion-labels. Authored-by: Stavros Kontopoulos <[email protected]> Signed-off-by: Marcelo Vanzin <[email protected]> (cherry picked from commit a24e1a1) Signed-off-by: Marcelo Vanzin <[email protected]>
1 parent f716a47 commit 349e25b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ private[spark] class ExecutorPodsAllocator(
8989
Utils.tryLogNonFatalError {
9090
kubernetesClient
9191
.pods()
92+
.withLabel(SPARK_APP_ID_LABEL, applicationId)
93+
.withLabel(SPARK_ROLE_LABEL, SPARK_POD_EXECUTOR_ROLE)
9294
.withLabel(SPARK_EXECUTOR_ID_LABEL, execId.toString)
9395
.delete()
9496
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,15 @@ class ExecutorPodsAllocatorSuite extends SparkFunSuite with BeforeAndAfter {
138138
snapshotsStore.notifySubscribers()
139139
snapshotsStore.replaceSnapshot(Seq.empty[Pod])
140140
waitForExecutorPodsClock.setTime(podCreationTimeout + 1)
141-
when(podOperations.withLabel(SPARK_EXECUTOR_ID_LABEL, "1")).thenReturn(labeledPods)
141+
when(podOperations
142+
.withLabel(SPARK_APP_ID_LABEL, TEST_SPARK_APP_ID))
143+
.thenReturn(podOperations)
144+
when(podOperations
145+
withLabel(SPARK_ROLE_LABEL, SPARK_POD_EXECUTOR_ROLE))
146+
.thenReturn(podOperations)
147+
when(podOperations
148+
.withLabel(SPARK_EXECUTOR_ID_LABEL, "1"))
149+
.thenReturn(labeledPods)
142150
snapshotsStore.notifySubscribers()
143151
verify(labeledPods).delete()
144152
verify(podOperations).create(podWithAttachedContainerForId(2))

0 commit comments

Comments
 (0)