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

SOLR-16240: Fix kerberosPlugin module classloading #1546

Merged
merged 5 commits into from Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion solr/CHANGES.txt
Expand Up @@ -108,7 +108,10 @@ Bug Fixes
* SOLR-16728: Fix Classloading Exception for inter-node requests when using SSL and HTTP2.
All Jetty classes are able to be shared between the Jetty server and webApp now. (Houston Putman)

* NPE in QueryResultKey when running clustering search query in some cases. (Roman Kagan, Christine Poerschke via Eric Pugh)
* SOLR-9775: NPE in QueryResultKey when running clustering search query in some cases. (Roman Kagan, Christine Poerschke via Eric Pugh)

* SOLR-16240: Fix KerberosPlugin module classloading when using the hadoop-auth module.
Plugins in modules/packages that require the Thread contextClassLoader on startup should now work. (Houston Putman)

Dependency Upgrades
---------------------
Expand Down
6 changes: 6 additions & 0 deletions solr/core/src/java/org/apache/solr/core/CoreContainer.java
Expand Up @@ -101,6 +101,7 @@
import org.apache.solr.common.util.ObjectCache;
import org.apache.solr.common.util.SolrNamedThreadFactory;
import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.SuppressForbidden;
import org.apache.solr.common.util.Utils;
import org.apache.solr.core.DirectoryFactory.DirContext;
import org.apache.solr.core.backup.repository.BackupRepository;
Expand Down Expand Up @@ -742,10 +743,15 @@ private void registerV2ApiIfEnabled(Class<? extends JerseyResource> clazz) {
// -------------------------------------------------------------------

/** Load the cores defined for this CoreContainer */
@SuppressForbidden(
reason =
"Set the thread contextClassLoader for all 3rd party dependencies that we cannot control")
public void load() {
if (log.isDebugEnabled()) {
log.debug("Loading cores into CoreContainer [instanceDir={}]", getSolrHome());
}
// Set the thread's contextClassLoader for any plugins that are loaded via Modules or Packages
Thread.currentThread().setContextClassLoader(loader.getClassLoader());

logging = LogWatcher.newRegisteredLogWatcher(cfg.getLogWatcherConfig(), loader);

Expand Down
Expand Up @@ -98,7 +98,7 @@ public void init(Map<String, Object> pluginConfig) {
kerberosFilter.init(conf);
} catch (ServletException e) {
throw new SolrException(
ErrorCode.SERVER_ERROR, "Error initializing kerberos authentication plugin: " + e);
ErrorCode.SERVER_ERROR, "Error initializing kerberos authentication plugin", e);
}
}

Expand Down
23 changes: 22 additions & 1 deletion solr/packaging/test/test_modules.bats
Expand Up @@ -26,7 +26,7 @@ teardown() {
save_home_on_failure

delete_all_collections
solr stop -all >/dev/null 2>&1
SOLR_STOP_WAIT=1 solr stop -all >/dev/null 2>&1
}

@test "SQL Module" {
Expand All @@ -39,6 +39,27 @@ teardown() {
refute_output --partial '"EXCEPTION"'
}

@test "Hadoop-Auth Module: KerberosPlugin Classloading" {
# Write a security.json that uses the KerberosPlugin
local security_json="${BATS_TEST_TMPDIR}/kerberos-security.json"
echo '{"authentication": {"class": "solr.KerberosPlugin"}}' > "${security_json}"

# Start Solr
export SOLR_MODULES=hadoop-auth
solr start -c \
-Dsolr.kerberos.principal=test \
-Dsolr.kerberos.keytab=test \
-Dsolr.kerberos.cookie.domain=test

# Upload the custom security.json and wait for Solr to try to load it
solr zk cp "${security_json}" zk:security.json -z localhost:9983
sleep 1

run cat "${SOLR_LOGS_DIR}/solr.log"
assert_output --partial "Initializing authentication plugin: solr.KerberosPlugin"
refute_output --partial "java.lang.ClassNotFoundException"
}

@test "icu collation in analysis-extras module" {
run solr start -c -Dsolr.modules=analysis-extras
run solr create_collection -c COLL_NAME -d test/analysis_extras_config/conf
Expand Down
4 changes: 2 additions & 2 deletions solr/packaging/test/test_placement_plugin.bats
Expand Up @@ -34,7 +34,7 @@ teardown() {
solr assert -c http://localhost:8983/solr -t 3000
run solr create_collection -c COLL_NAME
collection_exists COLL_NAME
assert_file_contains ${SOLR_LOGS_DIR}/solr.log 'Default replica placement plugin set in solr\.placementplugin\.default to affinity'
assert_file_contains "${SOLR_LOGS_DIR}/solr.log" 'Default replica placement plugin set in solr\.placementplugin\.default to affinity'
}

@test "Affinity placement plugin using ENV" {
Expand All @@ -43,5 +43,5 @@ teardown() {
solr assert -c http://localhost:8983/solr -t 3000
run solr create_collection -c COLL_NAME
collection_exists COLL_NAME
assert_file_contains ${SOLR_LOGS_DIR}/solr.log 'Default replica placement plugin set in solr\.placementplugin\.default to random'
assert_file_contains "${SOLR_LOGS_DIR}/solr.log" 'Default replica placement plugin set in solr\.placementplugin\.default to random'
}