Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-17875: Redo of Rationalize bootstrap_conf, bootstrap_confdir, and -Dcollection.configName in start up scripts (#3604)

Eric Pugh2cedce274a70
diff --git a/solr/bin/solr b/solr/bin/solr
index d9b0bacb4da..2f1cb2933bf 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -1091,11 +1091,6 @@ if [ "${SOLR_MODE:-}" == 'solrcloud' ]; then
CLOUD_MODE_OPTS+=("-DcreateZkChroot=$ZK_CREATE_CHROOT")
fi
- # and if collection1 needs to be bootstrapped
- if [ -e "$SOLR_HOME/collection1/core.properties" ]; then
- CLOUD_MODE_OPTS+=('-Dbootstrap_confdir=./solr/collection1/conf' '-Dcollection.configName=myconf' '-DnumShards=1')
- fi
-
if [ "${SOLR_SOLRXML_REQUIRED:-false}" == "true" ]; then
CLOUD_MODE_OPTS+=("-Dsolr.solrxml.required=true")
fi
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index d8c3f5d4561..744a39a45b8 100755
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -936,10 +936,6 @@ IF "%SOLR_MODE%"=="solrcloud" (
set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -Dsolr.solrxml.required=true"
)
- IF EXIST "%SOLR_HOME%\collection1\core.properties" set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -Dbootstrap_confdir=./solr/collection1/conf -Dcollection.configName=myconf -DnumShards=1"
-) ELSE (
- REM change Cloud mode to User Managed mode with flag
- set "CLOUD_MODE_OPTS="
IF NOT EXIST "%SOLR_HOME%\solr.xml" (
IF "%SOLR_SOLRXML_REQUIRED%"=="true" (
set "SCRIPT_ERROR=Solr home directory %SOLR_HOME% must contain solr.xml!"
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
index e216a7726bc..b3f1b4c5380 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
@@ -37,7 +37,6 @@ import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;
-import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -683,32 +682,6 @@ public class CreateCollectionCmd implements CollApiCmds.CollectionApiCommand {
stateManager, collection, collectionPath, collectionProps, configSetService);
}
- } else if (System.getProperty("bootstrap_confdir") != null) {
- String defaultConfigName =
- System.getProperty(
- ZkController.COLLECTION_PARAM_PREFIX + ZkController.CONFIGNAME_PROP,
- collection);
-
- // if we are bootstrapping a collection, default the config for
- // a new collection to the collection we are bootstrapping
- log.info("Setting config for collection: {} to {}", collection, defaultConfigName);
-
- Properties sysProps = System.getProperties();
- for (String sprop : System.getProperties().stringPropertyNames()) {
- if (sprop.startsWith(ZkController.COLLECTION_PARAM_PREFIX)) {
- collectionProps.put(
- sprop.substring(ZkController.COLLECTION_PARAM_PREFIX.length()),
- sysProps.getProperty(sprop));
- }
- }
-
- // if the config name wasn't passed in, use the default
- if (!collectionProps.containsKey(ZkController.CONFIGNAME_PROP))
- collectionProps.put(ZkController.CONFIGNAME_PROP, defaultConfigName);
-
- } else if (Boolean.getBoolean("bootstrap_conf")) {
- // the conf name should should be the collection name of this core
- collectionProps.put(ZkController.CONFIGNAME_PROP, collection);
} else {
getConfName(
stateManager, collection, collectionPath, collectionProps, configSetService);
diff --git a/solr/core/src/java/org/apache/solr/core/ConfigSetService.java b/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
index 0d737c27d61..40145779a0d 100644
--- a/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
+++ b/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
@@ -31,8 +31,8 @@ import org.apache.solr.cloud.ZkConfigSetService;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.common.ConfigNode;
import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.EnvUtils;
import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.StrUtils;
import org.apache.solr.handler.admin.ConfigSetsHandler;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.IndexSchemaFactory;
@@ -85,22 +85,16 @@ public abstract class ConfigSetService {
}
private void bootstrapConfigSet(CoreContainer coreContainer) {
- // bootstrap _default conf, bootstrap_confdir and bootstrap_conf if provided via system property
+ // bootstrap _default conf and solr.configset.bootstrap.confdir if provided via system property
try {
// _default conf
bootstrapDefaultConf();
// bootstrap_confdir
- String confDir = System.getProperty("bootstrap_confdir");
+ String confDir = EnvUtils.getProperty("solr.configset.bootstrap.confdir");
if (confDir != null) {
bootstrapConfDir(confDir);
}
-
- // bootstrap_conf
- boolean boostrapConf = Boolean.getBoolean("bootstrap_conf");
- if (boostrapConf == true) {
- bootstrapConf(coreContainer);
- }
} catch (IOException e) {
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR, "Config couldn't be uploaded ", e);
@@ -129,8 +123,7 @@ public abstract class ConfigSetService {
+ configPath);
}
String confName =
- System.getProperty(
- ZkController.COLLECTION_PARAM_PREFIX + ZkController.CONFIGNAME_PROP, "configuration1");
+ EnvUtils.getProperty("solr.configset.bootstrap.config.name", "configuration1");
this.uploadConfig(confName, configPath);
}
@@ -198,28 +191,6 @@ public abstract class ConfigSetService {
Path.of(configSetDir, confDir, "conf", "solrconfig.xml").normalize().toAbsolutePath()));
}
- /** If in SolrCloud mode, upload configSets for each SolrCore in solr.xml. */
- public static void bootstrapConf(CoreContainer cc) throws IOException {
- // List<String> allCoreNames = cfg.getAllCoreNames();
- List<CoreDescriptor> cds = cc.getCoresLocator().discover(cc);
-
- if (log.isInfoEnabled()) {
- log.info(
- "bootstrapping config for {} cores into ZooKeeper using solr.xml from {}",
- cds.size(),
- cc.getSolrHome());
- }
-
- for (CoreDescriptor cd : cds) {
- String coreName = cd.getName();
- String confName = cd.getCollectionName();
- if (StrUtils.isNullOrEmpty(confName)) confName = coreName;
- Path udir = cd.getInstanceDir().resolve("conf");
- log.info("Uploading directory {} with name {} for solrCore {}", udir, confName, coreName);
- cc.getConfigSetService().uploadConfig(confName, udir);
- }
- }
-
/**
* Load the ConfigSet for a core
*
diff --git a/solr/packaging/test/test_start_solr.bats b/solr/packaging/test/test_start_solr.bats
index 2ba80e44e95..27f1fe9df03 100644
--- a/solr/packaging/test/test_start_solr.bats
+++ b/solr/packaging/test/test_start_solr.bats
@@ -82,8 +82,8 @@ teardown() {
}
@test "deprecated system properties converted to modern properties" {
- solr start -Denable.packages=true
- assert_file_contains "${SOLR_LOGS_DIR}/solr.log" 'You are passing in deprecated system property enable.packages and should upgrade to using solr.packages.enabled instead.'
+ solr start -Ddisable.v2.api=true
+ assert_file_contains "${SOLR_LOGS_DIR}/solr.log" 'You are passing in deprecated system property disable.v2.api and should upgrade to using solr.api.v2.enabled instead.'
}
@test "start with custom jetty options" {
@@ -93,3 +93,17 @@ teardown() {
solr start --jettyconfig "--module=server"
solr assert --started http://localhost:${SOLR_PORT} --timeout 5000
}
+
+@test "bootstrapping a configset" {
+ local confdir_path="${SOLR_TIP}/server/solr/configsets/sample_techproducts_configs/conf"
+
+ # Verify the source configset directory exists
+ test -d "${confdir_path}"
+
+ # Start Solr with bootstrap_confdir pointing to techproducts configset
+ solr start -Dbootstrap_confdir="${confdir_path}" -Dcollection.configName=techproducts
+ solr assert --started http://localhost:${SOLR_PORT} --timeout 5000
+
+ # Verify the techproducts configset was uploaded
+ config_exists "techproducts"
+}
diff --git a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc
index b3e7f0fd340..21e6566f33c 100644
--- a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc
+++ b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc
@@ -47,6 +47,11 @@ To learn about the updated options in each CLI tool, use the `--help` option or
Additionally, the `bin/solr delete` command no longer deletes a configset when you delete a collection. Previously if you deleted a collection, it would also delete it's associated configset if it was the only user of it.
Now you have to explicitly provide a `--delete-config` option to delete the configsets. This decouples the lifecycle of a configset from that of a collection.
+The `bin/solr start --bootstrap_conf` flag is a legacy feature for converting from Solr to SolrCloud mode and has been removed.
+
+The system property "bootstrap_confdir" (recently renamed to "solr.configset.bootstrap.confdir") used in `bin/solr start` allwowed a collection creation command to default to the examination of system properties in the absence of proper creation parameters by the same name (like "collection.configName").
+That no longer happens in Solr 10. It is only used to load a configuration as a ConfigSet.
+
=== SolrJ
* Starting in 10, the Maven POM for SolrJ does not refer to SolrJ modules like ZooKeeper. If you require such functionality, you need to add additional dependencies.
diff --git a/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestZkConfigSetService.java b/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestZkConfigSetService.java
index 7d083d330a3..9928d543210 100644
--- a/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestZkConfigSetService.java
+++ b/solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestZkConfigSetService.java
@@ -23,17 +23,14 @@ import java.nio.file.Path;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.List;
-import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.apache.curator.framework.AuthInfo;
import org.apache.curator.framework.api.ACLProvider;
import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.cloud.AbstractZkTestCase;
import org.apache.solr.cloud.ZkConfigSetService;
import org.apache.solr.cloud.ZkTestServer;
import org.apache.solr.common.SolrException;
import org.apache.solr.core.ConfigSetService;
-import org.apache.solr.core.CoreContainer;
import org.apache.solr.util.LogLevel;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooDefs;
@@ -228,28 +225,6 @@ public class TestZkConfigSetService extends SolrTestCaseJ4 {
}
}
- @Test
- public void testBootstrapConf() throws IOException, KeeperException, InterruptedException {
-
- Path solrHome = legacyExampleCollection1SolrHome();
-
- CoreContainer cc = new CoreContainer(solrHome, new Properties());
- System.setProperty("zkHost", zkServer.getZkAddress());
-
- SolrZkClient zkClient =
- new SolrZkClient.Builder()
- .withUrl(zkServer.getZkHost())
- .withTimeout(AbstractZkTestCase.TIMEOUT, TimeUnit.MILLISECONDS)
- .build();
- zkClient.makePath("/solr", false, true);
- cc.setCoreConfigService(new ZkConfigSetService(zkClient));
- assertFalse(cc.getConfigSetService().checkConfigExists("collection1"));
- ConfigSetService.bootstrapConf(cc);
- assertTrue(cc.getConfigSetService().checkConfigExists("collection1"));
-
- zkClient.close();
- }
-
static SolrZkClient buildZkClient(
String zkAddress,
final ACLProvider aclProvider,
diff --git a/solr/solrj/src/resources/DeprecatedSystemPropertyMappings.properties b/solr/solrj/src/resources/DeprecatedSystemPropertyMappings.properties
index 12f11d4b057..bf07bfedffb 100644
--- a/solr/solrj/src/resources/DeprecatedSystemPropertyMappings.properties
+++ b/solr/solrj/src/resources/DeprecatedSystemPropertyMappings.properties
@@ -13,7 +13,6 @@ solr.default.confdir=solr.configset.default.confdir
solr.admin.ui.disabled=solr.ui.enabled
solr.admin.ui.experimental.disabled=solr.ui.experimental.enabled
solr.log.dir=solr.logs.dir
-solr.default.confdir=solr.configset.default.confdir
solr.wait.for.zk=solr.cloud.wait.for.zk.seconds
solr.enable.remote.streaming=solr.requests.streaming.remote.enabled
solr.enable.stream.body=solr.requests.streaming.body.enabled
@@ -26,8 +25,9 @@ solr.hide.stack.trace=solr.responses.stacktrace.enabled
authentication.plugin=solr.security.auth.plugin
basicauth=solr.security.auth.basicauth.credentials
cloud.solr.client.max.stale.retries=solr.solrj.cloud.max.stale.retries
-configset.upload.enabled=solr.configset.upload.enabled
solr.hidden.sys.props=solr.responses.hidden.sys.props
max.file.store.size=solr.filestore.filesize.max
prep.recovery.read.timeout.extra.wait=solr.cloud.prep.recovery.read.timeout.additional.ms
solr.allow.unsafe.resourceloading=solr.resourceloading.restricted.enabled
+bootstrap_confdir=solr.configset.bootstrap.confdir
+collection.configName=solr.configset.bootstrap.config.name
\ No newline at end of file