-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-29957][TEST] Reset MiniKDC's default enctypes to fit jdk8/jdk11 #26594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
e9ef3ba
3ec2891
2e282f2
a224fad
3456ff9
dfdf589
7ab6192
476d60e
b782e99
10a0006
03f7fb1
e252dd0
4facbee
223533f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,14 +17,15 @@ | |
|
|
||
| package org.apache.spark.sql.kafka010 | ||
|
|
||
| import java.io.{File, IOException} | ||
| import java.io.{File, IOException, PrintWriter} | ||
| import java.net.{InetAddress, InetSocketAddress} | ||
| import java.nio.charset.StandardCharsets | ||
| import java.util.{Collections, Properties, UUID} | ||
| import java.util.concurrent.TimeUnit | ||
| import javax.security.auth.login.Configuration | ||
|
|
||
| import scala.collection.JavaConverters._ | ||
| import scala.io.Source | ||
| import scala.util.Random | ||
|
|
||
| import com.google.common.io.Files | ||
|
|
@@ -136,9 +137,49 @@ class KafkaTestUtils( | |
| kdcConf.setProperty(MiniKdc.DEBUG, "true") | ||
| kdc = new MiniKdc(kdcConf, kdcDir) | ||
| kdc.start() | ||
| // TODO https://issues.apache.org/jira/browse/SPARK-30037 | ||
| // Need to customize krb5.conf like Kafka | ||
|
AngersZhuuuu marked this conversation as resolved.
Outdated
|
||
| rewriteKrb5Conf() | ||
| kdcReady = true | ||
| } | ||
|
|
||
| /** | ||
| * In this method we rewrite krb5.conf to make kdc nad client use the same enctypes | ||
| * | ||
|
AngersZhuuuu marked this conversation as resolved.
Outdated
|
||
| */ | ||
| private def rewriteKrb5Conf(): Unit = { | ||
| val krb5Conf = Source.fromFile(kdc.getKrb5conf, "UTF-8").getLines() | ||
|
dongjoon-hyun marked this conversation as resolved.
|
||
| var rewritten = false | ||
| val addedConfig = | ||
| addedKrb5Config("default_tkt_enctypes", "aes128-cts-hmac-sha1-96") + | ||
| addedKrb5Config("default_tgs_enctypes", "aes128-cts-hmac-sha1-96") | ||
| val rewriteKrb5Conf = krb5Conf.map(s => | ||
| if (s.contains("libdefaults")) { | ||
| rewritten = true | ||
| s + addedConfig | ||
| } else { | ||
| s | ||
| }).filter(!_.trim.startsWith("#")).mkString(System.lineSeparator()) | ||
|
|
||
| val krb5confStr = if (!rewritten) { | ||
| "[libdefaults]" + addedConfig + System.lineSeparator() + | ||
| System.lineSeparator() + rewriteKrb5Conf | ||
| } else { | ||
| rewriteKrb5Conf | ||
| } | ||
|
|
||
| kdc.getKrb5conf.delete() | ||
| val writer = new PrintWriter(kdc.getKrb5conf) | ||
| // scalastyle:off println | ||
| writer.println(krb5confStr) | ||
| // scalastyle:on println | ||
| writer.close() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. - val writer = new PrintWriter(kdc.getKrb5conf)
- // scalastyle:off println
- writer.println(krb5confStr)
- // scalastyle:on println
- writer.close()
+ Files.write(krb5confStr, kdc.getKrb5conf, StandardCharsets.UTF_8)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Done thanks. |
||
| } | ||
|
|
||
| private def addedKrb5Config(key: String, value: String): String = { | ||
| System.lineSeparator() + s" $key=$value" | ||
| } | ||
|
|
||
| private def createKeytabsAndJaasConfigFile(): String = { | ||
| assert(kdcReady, "KDC should be set up beforehand") | ||
| val baseDir = Utils.createTempDir() | ||
|
|
@@ -171,6 +212,7 @@ class KafkaTestUtils( | |
| | useKeyTab=true | ||
| | storeKey=true | ||
| | useTicketCache=false | ||
| | refreshKrb5Config=true | ||
|
AngersZhuuuu marked this conversation as resolved.
|
||
| | keyTab="${zkServerKeytabFile.getAbsolutePath()}" | ||
| | principal="$zkServerUser@$realm"; | ||
| |}; | ||
|
|
@@ -180,6 +222,7 @@ class KafkaTestUtils( | |
| | useKeyTab=true | ||
| | storeKey=true | ||
| | useTicketCache=false | ||
| | refreshKrb5Config=true | ||
| | keyTab="${zkClientKeytabFile.getAbsolutePath()}" | ||
| | principal="$zkClientUser@$realm"; | ||
| |}; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.