dongjoon-hyun commented on code in PR #57285:
URL: https://github.com/apache/spark/pull/57285#discussion_r3678301415
##########
core/src/main/scala/org/apache/spark/deploy/security/HadoopDelegationTokenManager.scala:
##########
@@ -76,28 +77,52 @@ private[spark] class HadoopDelegationTokenManager(
require((principal == null) == (keytab == null),
"Both principal and keytab must be defined, or neither.")
+ if (sparkConf.get(DIRECT_CREDENTIAL_PROVIDERS_ENABLED)) {
+ val hasEncryption = sparkConf.getBoolean("spark.ssl.rpc.enabled", false) ||
+ (sparkConf.get(NETWORK_AUTH_ENABLED) &&
+ (sparkConf.get(NETWORK_CRYPTO_ENABLED) ||
sparkConf.get(SASL_ENCRYPTION_ENABLED)))
+ require(hasEncryption,
+ "RPC channel encryption must be enabled when " +
+ "spark.security.directCredentialProviders.enabled is true: either " +
+ "spark.ssl.rpc.enabled=true, or spark.authenticate=true together with " +
+ "spark.network.crypto.enabled or
spark.authenticate.enableSaslEncryption. " +
+ "Credential tokens must not be transmitted over unencrypted channels.")
+ }
+
private val delegationTokenProviders = loadProviders()
+ if (sparkConf.get(DIRECT_CREDENTIAL_PROVIDERS_ENABLED) &&
delegationTokenProviders.isEmpty) {
+ logWarning("spark.security.directCredentialProviders.enabled is true but "
+
+ "no HadoopDelegationTokenProvider implementations were discovered. " +
+ "Ensure provider JARs are on the classpath with META-INF/services
registration.")
+ }
logDebug("Using the following builtin delegation token providers: " +
s"${delegationTokenProviders.keys.mkString(", ")}.")
private var renewalExecutor: ScheduledExecutorService = _
+ private def hasKerberosCredentials: Boolean =
+ sparkConf.get(KERBEROS_RENEWAL_CREDENTIALS) match {
+ case "keytab" => principal != null
+ case "ccache" =>
UserGroupInformation.getCurrentUser().hasKerberosCredentials()
+ case _ => false
+ }
+
/** @return Whether delegation token renewal is enabled. */
- def renewalEnabled: Boolean = sparkConf.get(KERBEROS_RENEWAL_CREDENTIALS)
match {
- case "keytab" => principal != null
- case "ccache" =>
UserGroupInformation.getCurrentUser().hasKerberosCredentials()
- case _ => false
+ def renewalEnabled: Boolean = {
+ hasKerberosCredentials ||
+ (sparkConf.get(DIRECT_CREDENTIAL_PROVIDERS_ENABLED) &&
delegationTokenProviders.nonEmpty)
Review Comment:
Technically, `delegationTokenProviders.nonEmpty` is insufficient. The
following is the correct way to check the existence of tokens, isn't it? WDYT,
@parthchandra ?
```suggestion
hasKerberosCredentials ||
(sparkConf.get(DIRECT_CREDENTIAL_PROVIDERS_ENABLED) &&
delegationTokenProviders.values.exists(_.delegationTokensRequired(sparkConf,
hadoopConf)))
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]