diff --git a/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala b/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala index d5a42c1ee90ac..3519efd3fcb10 100644 --- a/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala +++ b/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala @@ -456,11 +456,11 @@ class ExecutorPodsAllocator( private def isExecutorIdleTimedOut(state: ExecutorPodState, currentTime: Long): Boolean = { try { - val startTime = Instant.parse(state.pod.getStatus.getStartTime).toEpochMilli() - currentTime - startTime > executorIdleTimeout + val creationTime = Instant.parse(state.pod.getMetadata.getCreationTimestamp).toEpochMilli() + currentTime - creationTime > executorIdleTimeout } catch { - case _: Exception => - logDebug(s"Cannot get startTime of pod ${state.pod}") + case e: Exception => + logError(s"Cannot get the creationTimestamp of the pod: ${state.pod}", e) true } } diff --git a/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorLifecycleTestUtils.scala b/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorLifecycleTestUtils.scala index 78f11f9aa34d4..de9da0de7da2f 100644 --- a/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorLifecycleTestUtils.scala +++ b/resource-managers/kubernetes/core/src/test/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorLifecycleTestUtils.scala @@ -64,9 +64,11 @@ object ExecutorLifecycleTestUtils { def pendingExecutor(executorId: Long, rpId: Int = DEFAULT_RESOURCE_PROFILE_ID): Pod = { new PodBuilder(podWithAttachedContainerForId(executorId, rpId)) + .editOrNewMetadata() + .withCreationTimestamp(Instant.now.toString) + .endMetadata() .editOrNewStatus() .withPhase("pending") - .withStartTime(Instant.now.toString) .endStatus() .build() }