Skip to content

Commit 2549391

Browse files
gaborgsomogyidongjoon-hyun
authored andcommitted
[SPARK-29580][TESTS] Add kerberos debug messages for Kafka secure tests
### What changes were proposed in this pull request? `org.apache.spark.sql.kafka010.KafkaDelegationTokenSuite` failed lately. After had a look at the logs it just shows the following fact without any details: ``` Caused by: sbt.ForkMain$ForkError: sun.security.krb5.KrbException: Server not found in Kerberos database (7) - Server not found in Kerberos database ``` Since the issue is intermittent and not able to reproduce it we should add more debug information and wait for reproduction with the extended logs. ### Why are the changes needed? Failing test doesn't give enough debug information. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? I've started the test manually and checked that such additional debug messages show up: ``` >>> KrbApReq: APOptions are 00000000 00000000 00000000 00000000 >>> EType: sun.security.krb5.internal.crypto.Aes128CtsHmacSha1EType Looking for keys for: kafka/localhostEXAMPLE.COM Added key: 17version: 0 Added key: 23version: 0 Added key: 16version: 0 Found unsupported keytype (3) for kafka/localhostEXAMPLE.COM >>> EType: sun.security.krb5.internal.crypto.Aes128CtsHmacSha1EType Using builtin default etypes for permitted_enctypes default etypes for permitted_enctypes: 17 16 23. >>> EType: sun.security.krb5.internal.crypto.Aes128CtsHmacSha1EType MemoryCache: add 1571936500/174770/16C565221B70AAB2BEFE31A83D13A2F4/client/localhostEXAMPLE.COM to client/localhostEXAMPLE.COM|kafka/localhostEXAMPLE.COM MemoryCache: Existing AuthList: apache#3: 1571936493/200803/8CD70D280B0862C5DA1FF901ECAD39FE/client/localhostEXAMPLE.COM #2: 1571936499/985009/BAD33290D079DD4E3579A8686EC326B7/client/localhostEXAMPLE.COM #1: 1571936499/995208/B76B9D78A9BE283AC78340157107FD40/client/localhostEXAMPLE.COM ``` Closes apache#26252 from gaborgsomogyi/SPARK-29580. Authored-by: Gabor Somogyi <gabor.g.somogyi@gmail.com> Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
1 parent 2baf7a1 commit 2549391

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

external/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaTestUtils.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class KafkaTestUtils(
6767
secure: Boolean = false) extends Logging {
6868

6969
private val JAVA_AUTH_CONFIG = "java.security.auth.login.config"
70+
private val IBM_KRB_DEBUG_CONFIG = "com.ibm.security.krb5.Krb5Debug"
71+
private val SUN_KRB_DEBUG_CONFIG = "sun.security.krb5.debug"
7072

7173
private val localCanonicalHostName = InetAddress.getLoopbackAddress().getCanonicalHostName()
7274
logInfo(s"Local host name is $localCanonicalHostName")
@@ -133,6 +135,7 @@ class KafkaTestUtils(
133135
private def setUpMiniKdc(): Unit = {
134136
val kdcDir = Utils.createTempDir()
135137
val kdcConf = MiniKdc.createConf()
138+
kdcConf.setProperty(MiniKdc.DEBUG, "true")
136139
kdc = new MiniKdc(kdcConf, kdcDir)
137140
kdc.start()
138141
kdcReady = true
@@ -238,6 +241,7 @@ class KafkaTestUtils(
238241
}
239242

240243
if (secure) {
244+
setupKrbDebug()
241245
setUpMiniKdc()
242246
val jaasConfigFile = createKeytabsAndJaasConfigFile()
243247
System.setProperty(JAVA_AUTH_CONFIG, jaasConfigFile)
@@ -252,6 +256,14 @@ class KafkaTestUtils(
252256
}
253257
}
254258

259+
private def setupKrbDebug(): Unit = {
260+
if (System.getProperty("java.vendor").contains("IBM")) {
261+
System.setProperty(IBM_KRB_DEBUG_CONFIG, "all")
262+
} else {
263+
System.setProperty(SUN_KRB_DEBUG_CONFIG, "true")
264+
}
265+
}
266+
255267
/** Teardown the whole servers, including Kafka broker and Zookeeper */
256268
def teardown(): Unit = {
257269
if (leakDetector != null) {
@@ -303,6 +315,15 @@ class KafkaTestUtils(
303315
kdc.stop()
304316
}
305317
UserGroupInformation.reset()
318+
teardownKrbDebug()
319+
}
320+
321+
private def teardownKrbDebug(): Unit = {
322+
if (System.getProperty("java.vendor").contains("IBM")) {
323+
System.clearProperty(IBM_KRB_DEBUG_CONFIG)
324+
} else {
325+
System.clearProperty(SUN_KRB_DEBUG_CONFIG)
326+
}
306327
}
307328

308329
/** Create a Kafka topic and wait until it is propagated to the whole cluster */

0 commit comments

Comments
 (0)