Skip to content

Commit a24e1a1

Browse files
Stavros KontopoulosMarcelo Vanzin
authored andcommitted
[SPARK-26256][K8S] Fix labels for pod deletion
## What changes were proposed in this pull request? Adds proper labels when deleting executor pods. ## How was this patch tested? Manually with tests. Closes #23209 from skonto/fix-deletion-labels. Authored-by: Stavros Kontopoulos <[email protected]> Signed-off-by: Marcelo Vanzin <[email protected]>
1 parent 518a3d1 commit a24e1a1

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
@@ -93,6 +93,8 @@ private[spark] class ExecutorPodsAllocator(
9393
Utils.tryLogNonFatalError {
9494
kubernetesClient
9595
.pods()
96+
.withLabel(SPARK_APP_ID_LABEL, applicationId)
97+
.withLabel(SPARK_ROLE_LABEL, SPARK_POD_EXECUTOR_ROLE)
9698
.withLabel(SPARK_EXECUTOR_ID_LABEL, execId.toString)
9799
.delete()
98100
}

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)