Skip to content

Commit abc8d64

Browse files
dongjoon-hyunericm-db
authored andcommitted
[SPARK-51956][K8S] Fix KerberosConfDriverFeatureStep to warn in case of failures
### What changes were proposed in this pull request? This PR aims to fix `KerberosConfDriverFeatureStep` to warn in case of failures and continue. ### Why are the changes needed? `DelegationTokenProvider.obtainDelegationTokens` functions are designed to warn in case of failures. https://github.com/apache/spark/blob/54eb1a2f863bd7d8706c5c9a568895adb026c78d/sql/hive/src/main/scala/org/apache/spark/sql/hive/security/HiveDelegationTokenProvider.scala#L115-L121 https://github.com/apache/spark/blob/54eb1a2f863bd7d8706c5c9a568895adb026c78d/core/src/main/scala/org/apache/spark/deploy/security/HBaseDelegationTokenProvider.scala#L100-L101 `KerberosConfDriverFeatureStep` had better follow the behavior during getting credentials and obtaining delegation tokens instead of failing at job submission. https://github.com/apache/spark/blob/54eb1a2f863bd7d8706c5c9a568895adb026c78d/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/KerberosConfDriverFeatureStep.scala#L94-L95 ``` Failed to request driver from scheduler backend. StackTrace: ... at ....KerberosConfDriverFeatureStep.delegationTokens$lzycompute (KerberosConfDriverFeatureStep.scala:94) at ....KerberosConfDriverFeatureStep$$delegationTokens (KerberosConfDriverFeatureStep.scala:90) ``` ### Does this PR introduce _any_ user-facing change? Previously `KerberosConfDriverFeatureStep` fails if there are exceptions. Now, it will continue to next steps. ### How was this patch tested? It's a little difficult to write a test case. ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#50758 from dongjoon-hyun/SPARK-51956. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
1 parent 9cc163d commit abc8d64

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/features/KerberosConfDriverFeatureStep.scala

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import java.io.File
2020
import java.nio.charset.StandardCharsets
2121

2222
import scala.jdk.CollectionConverters._
23+
import scala.util.control.NonFatal
2324

2425
import com.google.common.io.Files
2526
import io.fabric8.kubernetes.api.model._
@@ -91,14 +92,20 @@ private[spark] class KerberosConfDriverFeatureStep(kubernetesConf: KubernetesDri
9192
if (keytab.isEmpty && existingSecretName.isEmpty) {
9293
val tokenManager = new HadoopDelegationTokenManager(kubernetesConf.sparkConf,
9394
SparkHadoopUtil.get.newConfiguration(kubernetesConf.sparkConf), null)
94-
val creds = UserGroupInformation.getCurrentUser().getCredentials()
95-
tokenManager.obtainDelegationTokens(creds)
96-
// If no tokens and no secrets are stored in the credentials, make sure nothing is returned,
97-
// to avoid creating an unnecessary secret.
98-
if (creds.numberOfTokens() > 0 || creds.numberOfSecretKeys() > 0) {
99-
SparkHadoopUtil.get.serialize(creds)
100-
} else {
101-
null
95+
try {
96+
val creds = UserGroupInformation.getCurrentUser().getCredentials()
97+
tokenManager.obtainDelegationTokens(creds)
98+
// If no tokens and no secrets are stored in the credentials, make sure nothing is returned,
99+
// to avoid creating an unnecessary secret.
100+
if (creds.numberOfTokens() > 0 || creds.numberOfSecretKeys() > 0) {
101+
SparkHadoopUtil.get.serialize(creds)
102+
} else {
103+
null
104+
}
105+
} catch {
106+
case NonFatal(e) =>
107+
logWarning("Fail to get credentials", e)
108+
null
102109
}
103110
} else {
104111
null

0 commit comments

Comments
 (0)