You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uniffle.apache.org by ro...@apache.org on 2023/06/06 15:40:13 UTC

[incubator-uniffle] branch master updated: [MINOR] fix: Fix kerberos ut error caused by Config.singleton is not refresh. (#932)

This is an automated email from the ASF dual-hosted git repository.

roryqi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git


The following commit(s) were added to refs/heads/master by this push:
     new cb22510c [MINOR] fix: Fix kerberos ut error caused by Config.singleton is not refresh. (#932)
cb22510c is described below

commit cb22510cadedc4d3a97ee060352160bda304958c
Author: zhengchenyu <zh...@163.com>
AuthorDate: Tue Jun 6 23:40:07 2023 +0800

    [MINOR] fix: Fix kerberos ut error caused by Config.singleton is not refresh. (#932)
    
    ### What changes were proposed in this pull request?
    
    sun.security.krb5.Config should be refresh when krb5 conf file is setup.
    
    ### Why are the changes needed?
    
    We found error when use hadoop3.2 profile.
    
    By my debug, I found the static variable 'singleton' in sun.security.krb5.Config is not reload. We should refresh when krb5 config is setup. As described in https://github.com/apache/incubator-uniffle/issues/625, I refresh only in java8.
    
    Build error logs:
    
    ```
    -------------------------------------------------------------------------------
    Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.034 s <<< FAILURE! - in org.apache.uniffle.common.security.SecurityContextFactoryTest
    org.apache.uniffle.common.security.SecurityContextFactoryTest  Time elapsed: 1.034 s  <<< ERROR!
    java.lang.Exception: java.lang.IllegalArgumentException: Can't get Kerberos realm
            at org.apache.uniffle.common.KerberizedHadoop.setup(KerberizedHadoop.java:111)
            at org.apache.uniffle.common.KerberizedHadoopBase.init(KerberizedHadoopBase.java:41)
            at org.apache.uniffle.common.security.SecurityContextFactoryTest.beforeAll(SecurityContextFactoryTest.java:38)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
            at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
            at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
            at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
            at org.junit.jupiter.engine.extension.TimeoutExtension.interceptLifecycleMethod(TimeoutExtension.java:126)
            at org.junit.jupiter.engine.extension.TimeoutExtension.interceptBeforeAllMethod(TimeoutExtension.java:68)
            at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
            at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
            at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
            at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
            at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
            at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
            at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
            at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
            at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllMethods$11(ClassBasedTestDescriptor.java:397)
            at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
            at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllMethods(ClassBasedTestDescriptor.java:395)
            at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:209)
            at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:80)
            at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:148)
            at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
            at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
            at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
            at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
            at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
            at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
            at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
            at java.util.ArrayList.forEach(ArrayList.java:1259)
            at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
            at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
            at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
            at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
            at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
            at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
            at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
            at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
            at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
            at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
            at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
            at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
            at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
            at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
            at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
            at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
            at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
            at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
            at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
            at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
            at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
            at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:150)
            at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:124)
            at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
            at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
            at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
            at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
    Caused by: java.lang.IllegalArgumentException: Can't get Kerberos realm
            at org.apache.hadoop.security.HadoopKerberosName.setConfiguration(HadoopKerberosName.java:71)
            at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:319)
            at org.apache.hadoop.security.UserGroupInformation.setConfiguration(UserGroupInformation.java:365)
            at org.apache.uniffle.common.KerberizedHadoop.startKerberizedDFS(KerberizedHadoop.java:258)
            at org.apache.uniffle.common.KerberizedHadoop.setup(KerberizedHadoop.java:107)
            ... 61 more
    Caused by: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.apache.hadoop.security.authentication.util.KerberosUtil.getDefaultRealm(KerberosUtil.java:110)
            at org.apache.hadoop.security.HadoopKerberosName.setConfiguration(HadoopKerberosName.java:69)
            ... 65 more
    Caused by: KrbException: Cannot locate default realm
            at sun.security.krb5.Config.getDefaultRealm(Config.java:1137)
            ... 71 more
    
    
    ```
    
    ### How was this patch tested?
    
    CI test
---
 .../org/apache/uniffle/common/KerberizedHadoop.java     | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/common/src/test/java/org/apache/uniffle/common/KerberizedHadoop.java b/common/src/test/java/org/apache/uniffle/common/KerberizedHadoop.java
index 19364bfb..bb0b70f3 100644
--- a/common/src/test/java/org/apache/uniffle/common/KerberizedHadoop.java
+++ b/common/src/test/java/org/apache/uniffle/common/KerberizedHadoop.java
@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.Serializable;
+import java.lang.reflect.Method;
 import java.net.BindException;
 import java.net.ServerSocket;
 import java.nio.charset.StandardCharsets;
@@ -33,6 +34,8 @@ import java.util.List;
 import java.util.Properties;
 
 import com.google.common.collect.Sets;
+import org.apache.commons.lang3.JavaVersion;
+import org.apache.commons.lang3.SystemUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
 import org.apache.hadoop.fs.FSDataOutputStream;
@@ -167,9 +170,6 @@ public class KerberizedHadoop implements Serializable {
   }
 
   private void startKerberizedDFS() throws Throwable {
-    String krb5Conf = kdc.getKrb5conf().getAbsolutePath();
-    System.setProperty("java.security.krb5.conf", krb5Conf);
-
     String principal = "hdfs/" + RssUtils.getHostIp();
     File keytab = new File(workDir, "hdfs.keytab");
     kdc.createPrincipal(keytab, principal);
@@ -228,6 +228,17 @@ public class KerberizedHadoop implements Serializable {
 
     krb5ConfFile = kdc.getKrb5conf().getAbsolutePath();
     System.setProperty("java.security.krb5.conf", krb5ConfFile);
+    // Reload config when krb5 conf is setup
+    if (SystemUtils.isJavaVersionAtMost(JavaVersion.JAVA_1_8)) {
+      Class<?> classRef;
+      if (System.getProperty("java.vendor").contains("IBM")) {
+        classRef = Class.forName("com.ibm.security.krb5.internal.Config");
+      } else {
+        classRef = Class.forName("sun.security.krb5.Config");
+      }
+      Method method = classRef.getDeclaredMethod("refresh");
+      method.invoke(null);
+    }
   }
 
   public void tearDown() throws IOException {