Skip to content

Commit 8a5f44b

Browse files
committed
Fix for Cloudera CDS 2.2.0+ Spark credentialsRequired method (#1332)
Cloudera's CDS 2.2.0+ Spark fork introduced a non-passive method signature that results in the inability for the ES hadoop integration to work. Cloudera's CDS fork is the main means for CDH5 consumers to consume newer versions of Spark. CDS is only availble to be installed via a Cloudera Manager's parcel and is distinctly different from the (elder) version of Apache Spark that ships with CDH5. Supporting this fork is challenging since it difficult difficult to test manually, and even more so with the integration tests. CDS is for CDH5 consumers (likely the majority at this time) that want to use Java 8 (likey the majority at this time), and run newer versions of Spark (a very popular integration). Related commit: https://github.com/cloudera/spark/commit/0972663ef3a87f4dcf2f4a936216bb5da0232b4e#diff-73c35ef723336affd463d9657df7583f Fixes #1301
1 parent d12f111 commit 8a5f44b

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

spark/sql-20/src/main/scala/org/elasticsearch/spark/deploy/yarn/security/EsServiceCredentialProvider.scala

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,31 @@ class EsServiceCredentialProvider extends ServiceCredentialProvider {
7575
override def serviceName: String = "elasticsearch"
7676

7777
/**
78-
* Given a configuration, check to see if tokens would be required.
79-
* @param hadoopConf the current configuration
80-
* @return true if tokens should be gathered, false if they should not be
81-
*/
78+
* Given a configuration, check to see if tokens would be required.
79+
*
80+
* @param hadoopConf the current Hadoop configuration
81+
* @return true if tokens should be gathered, false if they should not be
82+
*/
8283
override def credentialsRequired(hadoopConf: Configuration): Boolean = {
83-
val settings = HadoopSettingsManager.loadFrom(hadoopConf)
84+
credentialsRequired(null, hadoopConf)
85+
}
86+
87+
/**
88+
* Given a configuration, check to see if tokens would be required.
89+
*
90+
* @param sparkConf the current Spark configuration - used by Cloudera's CDS Spark fork (#1301)
91+
* @param hadoopConf the current Hadoop configuration
92+
* @return true if tokens should be gathered, false if they should not be
93+
*/
94+
def credentialsRequired(sparkConf: SparkConf, hadoopConf: Configuration): Boolean = {
95+
val settings = if (sparkConf != null) {
96+
new CompositeSettings(util.Arrays.asList(
97+
new SparkSettingsManager().load(sparkConf),
98+
new HadoopSettingsManager().load(hadoopConf)
99+
))
100+
} else {
101+
HadoopSettingsManager.loadFrom(hadoopConf)
102+
}
84103
val isSecurityEnabled = UserGroupInformation.isSecurityEnabled
85104
val esAuthMethod = settings.getSecurityAuthenticationMethod
86105
val required = isSecurityEnabled && AuthenticationMethod.KERBEROS.equals(esAuthMethod)

0 commit comments

Comments
 (0)