dongjoon-hyun commented on code in PR #57285:
URL: https://github.com/apache/spark/pull/57285#discussion_r3641983891
##########
core/src/main/scala/org/apache/spark/deploy/security/HadoopDelegationTokenManager.scala:
##########
@@ -76,28 +77,50 @@ private[spark] class HadoopDelegationTokenManager(
require((principal == null) == (keytab == null),
"Both principal and keytab must be defined, or neither.")
+ if (sparkConf.get(CREDENTIALS_DIRECT_PROVIDERS_ENABLED)) {
+ val hasEncryption = sparkConf.get(NETWORK_CRYPTO_ENABLED) ||
+ sparkConf.get(SASL_ENCRYPTION_ENABLED) ||
+ sparkConf.getBoolean("spark.ssl.rpc.enabled", false)
+ require(hasEncryption,
+ "RPC channel encryption (spark.network.crypto.enabled, " +
+ "spark.authenticate.enableSaslEncryption, or spark.ssl.rpc.enabled) must
be enabled when " +
+ "spark.security.credentials.directProviders.enabled is true. " +
+ "Credential tokens must not be transmitted over unencrypted channels.")
+ }
+
private val delegationTokenProviders = loadProviders()
+ if (sparkConf.get(CREDENTIALS_DIRECT_PROVIDERS_ENABLED) &&
delegationTokenProviders.isEmpty) {
+ logWarning("spark.security.credentials.directProviders.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(CREDENTIALS_DIRECT_PROVIDERS_ENABLED)
Review Comment:
If the switch is on but no providers were discovered (the WARN case above),
`renewalEnabled` is still true, so `start()` sends an empty
`UpdateDelegationTokens` and schedules the next renewal ~never (`nextRenewal ==
Long.MaxValue`, `failureCount == 0`). Simpler to not start the renewer at all
like the following.
```suggestion
hasKerberosCredentials ||
(sparkConf.get(CREDENTIALS_DIRECT_PROVIDERS_ENABLED) &&
delegationTokenProviders.nonEmpty)
```
--
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]