Skip to content
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

[SPARK-29580][TESTS] Add kerberos debug messages for Kafka secure tests #26252

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class KafkaTestUtils(
secure: Boolean = false) extends Logging {

private val JAVA_AUTH_CONFIG = "java.security.auth.login.config"
private val IBM_KRB_DEBUG_CONFIG = "com.ibm.security.krb5.Krb5Debug"
private val SUN_KRB_DEBUG_CONFIG = "sun.security.krb5.debug"

private val localCanonicalHostName = InetAddress.getLoopbackAddress().getCanonicalHostName()
logInfo(s"Local host name is $localCanonicalHostName")
Expand Down Expand Up @@ -133,6 +135,7 @@ class KafkaTestUtils(
private def setUpMiniKdc(): Unit = {
val kdcDir = Utils.createTempDir()
val kdcConf = MiniKdc.createConf()
kdcConf.setProperty(MiniKdc.DEBUG, "true")
kdc = new MiniKdc(kdcConf, kdcDir)
kdc.start()
kdcReady = true
Expand Down Expand Up @@ -238,6 +241,7 @@ class KafkaTestUtils(
}

if (secure) {
setupKrbDebug()
setUpMiniKdc()
val jaasConfigFile = createKeytabsAndJaasConfigFile()
System.setProperty(JAVA_AUTH_CONFIG, jaasConfigFile)
Expand All @@ -252,6 +256,14 @@ class KafkaTestUtils(
}
}

private def setupKrbDebug(): Unit = {
if (System.getProperty("java.vendor").contains("IBM")) {
System.setProperty(IBM_KRB_DEBUG_CONFIG, "all")
} else {
System.setProperty(SUN_KRB_DEBUG_CONFIG, "true")
}
}

/** Teardown the whole servers, including Kafka broker and Zookeeper */
def teardown(): Unit = {
if (leakDetector != null) {
Expand Down Expand Up @@ -303,6 +315,15 @@ class KafkaTestUtils(
kdc.stop()
}
UserGroupInformation.reset()
teardownKrbDebug()
}

private def teardownKrbDebug(): Unit = {
if (System.getProperty("java.vendor").contains("IBM")) {
System.clearProperty(IBM_KRB_DEBUG_CONFIG)
} else {
System.clearProperty(SUN_KRB_DEBUG_CONFIG)
}
}

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