RANGER-5530: Fix for KMS API not working in docker kerberos env#1004
RANGER-5530: Fix for KMS API not working in docker kerberos env#1004vikaskr22 wants to merge 1 commit into
Conversation
| KMS_CONF_DIR=${RANGER_KMS_EWS_DIR}/webapp/WEB-INF/classes/conf | ||
| SERVER_NAME=rangerkms | ||
| cp="-cp ${RANGER_KMS_EWS_CONF_DIR}:${RANGER_KMS_EWS_DIR}/lib/*:${JAVA_HOME}/lib/*:${RANGER_HADOOP_CONF_DIR}/*:$CLASSPATH" | ||
| cp="-cp ${RANGER_KMS_EWS_CONF_DIR}:${RANGER_KMS_EWS_DIR}/lib/*:${RANGER_KMS_EWS_DIR}/webapp/WEB-INF/lib/*:${JAVA_HOME}/lib/*:${RANGER_HADOOP_CONF_DIR}/*:$CLASSPATH" |
There was a problem hiding this comment.
Adding WEB-INF/lib/* to the JVM-level classpath fixes the immediate issue but potentially reintroduces the same classloader duplication pattern for any jar that exists in both ews/lib/* and WEB-INF/lib/*. Could you check if there's any overlap between the two directories in the assembled KMS package? Ideally the two classpaths should be disjoint — otherwise we may just be shifting the LinkageError to a different class down the line
| <include>com.fasterxml.jackson.core:jackson-core:jar:${fasterxml.jackson.version}</include> | ||
| <include>com.fasterxml.jackson.core:jackson-databind:jar:${fasterxml.jackson.databind.version}</include> | ||
| <include>org.javassist:javassist</include> | ||
| <include>org.apache.ranger:ranger-common-utils</include> |
There was a problem hiding this comment.
The fix makes sense moving ranger-common-utils to WEB-INF/lib eliminates the dual classloader loading of Jackson. A couple of things worth verifying:
1--> Are there any other jars remaining in the ews/lib moduleSet that are also present in WEB-INF/lib? If so, we'd have the same loader constraint risk for those classes once WEB-INF/lib/* is added to the JVM classpath (see comment on kms/scripts/ranger-kms).
2--> Is there anything in the KMS startup lifecycle that runs before the webapp classloader is active and depends on ranger-common-utils? Since it's no longer in ews/lib, it won't be available at the JVM level until Tomcat loads the webapp
There was a problem hiding this comment.
@pradeepagrawal8184 could you weigh in on this? I think you'd have better insight into whether the classpath overlap is actually a concern here. Check my other comment as well.
Ranger-KMS APIs (including dev_kms TestConnection) were breaking due to authentication & authorisation error after kerberos implementation in Docker env.
This PR contains fix for following:
After kerberos fix, it was throwing following error:
As per my analysis, it happened due to duplicate jackson-*:jar jars available inside distro/kms.xml . Once inside "ews/webapp/WEB-INF/lib/" and once inside "ews/lib".
RCA: "ranger-common-utils" was part of "ews/lib" and Jackson jars were part of both moduleSets. JsonUtilsV2.java tries to load com.fasterxml.jackson.databind.ObjectMapper . It's part of Jackson jars and it was already loaded by another class loader. That is, once it gets loaded by the app loader, then the webapp loader tries to load it again → loader constraint violation → JsonUtilsV2 cannot initialize.
Fix: : Removed ranger-common-utils dependency & Jackson-*.jar from ews/lib and added ranger-common-utils inside "ews/webapp/WEB-INF/lib/".
How was this patch tested?
-mvn build is working