gaborgsomogyi commented on a change in pull request #28442:
URL: https://github.com/apache/spark/pull/28442#discussion_r420812607



##########
File path: 
core/src/test/scala/org/apache/spark/deploy/security/HadoopDelegationTokenManagerSuite.scala
##########
@@ -84,13 +88,35 @@ class HadoopDelegationTokenManagerSuite extends 
SparkFunSuite {
 
     var kdc: MiniKdc = null
     try {
-      // UserGroupInformation.setConfiguration needs default kerberos realm 
which can be set in
-      // krb5.conf. MiniKdc sets "java.security.krb5.conf" in start and 
removes it when stop called.
       val kdcDir = Utils.createTempDir()
       val kdcConf = MiniKdc.createConf()
-      kdc = new MiniKdc(kdcConf, kdcDir)
-      kdc.start()
+      // The port for MiniKdc service gets selected in the constructor, but 
will be bound
+      // to it later in MiniKdc.start() -> MiniKdc.initKDCServer() -> 
KdcServer.start().
+      // In meantime, when some other service might capture the port during 
this progress, and
+      // cause BindException.
+      // This makes our tests which have dedicated JVMs and rely on MiniKDC 
being flaky
+      //
+      // https://issues.apache.org/jira/browse/HADOOP-12656 get fixed in 
Hadoop 2.8.0.
+      //
+      // The workaround here is to periodically repeat this process with a 
timeout , since we are
+      // using Hadoop 2.7.4 as default.
+      // https://issues.apache.org/jira/browse/SPARK-31631
+      eventually(timeout(10.seconds), interval(100.milliseconds)) {
+        try {
+          kdc = new MiniKdc(kdcConf, kdcDir)
+          kdc.start()
+        } catch {
+          case NonFatal(e) =>
+            if (kdc != null) {
+              kdc.stop()
+              kdc = null
+            }
+            throw e
+        }
+      }
 
+      // UserGroupInformation.setConfiguration needs default kerberos realm 
which can be set in

Review comment:
       Not yet understand why this has been moved.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to