Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix compile errors
  • Loading branch information
victors-oai committed Oct 16, 2025
commit 0b7abd80087a107e8eb2f3b10d2a7140d7dd0e60
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package org.apache.spark.deploy.k8s

import io.fabric8.kubernetes.api.model.{Pod, PodBuilder}
import io.fabric8.kubernetes.client.KubernetesClient
import org.apache.hadoop.util.StringUtils

import org.apache.spark.SparkConf
import org.apache.spark.deploy.SparkDiagnosticsSetter
import org.apache.spark.deploy.k8s.Config._
Expand Down Expand Up @@ -59,8 +61,7 @@ private[spark] class SparkKubernetesDiagnosticsSetter(
override def setDiagnostics(throwable: Throwable, conf: SparkConf): Unit = {
require(conf.get(KUBERNETES_DRIVER_POD_NAME).isDefined,
"Driver pod name must be set in order to set diagnostics on the driver pod.")
val diagnostics = SparkStringUtils.abbreviate(
org.apache.hadoop.util.StringUtils.stringifyException(throwable),
val diagnostics = SparkStringUtils.abbreviate(StringUtils.stringifyException(throwable),
KUBERNETES_DIAGNOSTICS_MESSAGE_LIMIT_BYTES)
Utils.tryWithResource(clientProvider.create(conf)) { client =>
conf.get(KUBERNETES_DRIVER_POD_NAME).foreach { podName =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import java.util.function.UnaryOperator
import io.fabric8.kubernetes.api.model.Pod
import io.fabric8.kubernetes.client.KubernetesClient
import io.fabric8.kubernetes.client.dsl.PodResource
import org.apache.hadoop.util.StringUtils
import org.mockito.{ArgumentCaptor, Mock, MockitoAnnotations}
import org.mockito.ArgumentMatchers.any
import org.mockito.Mockito._
Expand Down Expand Up @@ -75,12 +76,12 @@ class SparkKubernetesDiagnosticsSetterSuite extends SparkFunSuite
.set(KUBERNETES_NAMESPACE, namespace)

assertThrows[IllegalArgumentException] {
setter.setDiagnostics("diag", conf)
setter.setDiagnostics(new Throwable("diag"), conf)
}
}

test("setDiagnostics should patch pod with diagnostics annotation") {
val diagnostics = "Fake diagnostics stack trace"
val diagnostics = new Throwable("Fake diagnostics stack trace")
val conf = new SparkConf()
.set(KUBERNETES_DRIVER_MASTER_URL, k8sClusterManagerUrl)
.set(KUBERNETES_NAMESPACE, namespace)
Expand All @@ -96,6 +97,7 @@ class SparkKubernetesDiagnosticsSetterSuite extends SparkFunSuite
val initialPod = SparkPod.initialPod().pod
val editedPod = fn.apply(initialPod)

assert(editedPod.getMetadata.getAnnotations.get(DIAGNOSTICS_ANNOTATION) == diagnostics)
assert(editedPod.getMetadata.getAnnotations.get(DIAGNOSTICS_ANNOTATION)
== StringUtils.stringifyException(diagnostics))
}
}