Skip to content

Commit 2cedce2

Browse files
authored
SOLR-17875: Redo of Rationalize bootstrap_conf, bootstrap_confdir, and -Dcollection.configName in start up scripts (#3604)
* add bats test for bootstrapping a configset, also verifies back compat for renaming fields. * Remove legacy bootstrap_conf parameter. This is from early SolrCloud days and should not be used these days. * Migrate boostrap_confdir and collection.configName to modern equivalents. * Simplify CreateCollectionCmd.java method createCollectionZkNode to just focus on creating a collection, no other side effects.
1 parent d5aaf27 commit 2cedce2

8 files changed

Lines changed: 27 additions & 98 deletions

File tree

solr/bin/solr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,11 +1091,6 @@ if [ "${SOLR_MODE:-}" == 'solrcloud' ]; then
10911091
CLOUD_MODE_OPTS+=("-DcreateZkChroot=$ZK_CREATE_CHROOT")
10921092
fi
10931093

1094-
# and if collection1 needs to be bootstrapped
1095-
if [ -e "$SOLR_HOME/collection1/core.properties" ]; then
1096-
CLOUD_MODE_OPTS+=('-Dbootstrap_confdir=./solr/collection1/conf' '-Dcollection.configName=myconf' '-DnumShards=1')
1097-
fi
1098-
10991094
if [ "${SOLR_SOLRXML_REQUIRED:-false}" == "true" ]; then
11001095
CLOUD_MODE_OPTS+=("-Dsolr.solrxml.required=true")
11011096
fi

solr/bin/solr.cmd

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -936,10 +936,6 @@ IF "%SOLR_MODE%"=="solrcloud" (
936936
set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -Dsolr.solrxml.required=true"
937937
)
938938

939-
IF EXIST "%SOLR_HOME%\collection1\core.properties" set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -Dbootstrap_confdir=./solr/collection1/conf -Dcollection.configName=myconf -DnumShards=1"
940-
) ELSE (
941-
REM change Cloud mode to User Managed mode with flag
942-
set "CLOUD_MODE_OPTS="
943939
IF NOT EXIST "%SOLR_HOME%\solr.xml" (
944940
IF "%SOLR_SOLRXML_REQUIRED%"=="true" (
945941
set "SCRIPT_ERROR=Solr home directory %SOLR_HOME% must contain solr.xml!"

solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import java.util.Map;
3838
import java.util.NoSuchElementException;
3939
import java.util.Objects;
40-
import java.util.Properties;
4140
import java.util.concurrent.ConcurrentHashMap;
4241
import java.util.concurrent.TimeUnit;
4342
import java.util.concurrent.TimeoutException;
@@ -683,32 +682,6 @@ public static void createCollectionZkNode(
683682
stateManager, collection, collectionPath, collectionProps, configSetService);
684683
}
685684

686-
} else if (System.getProperty("bootstrap_confdir") != null) {
687-
String defaultConfigName =
688-
System.getProperty(
689-
ZkController.COLLECTION_PARAM_PREFIX + ZkController.CONFIGNAME_PROP,
690-
collection);
691-
692-
// if we are bootstrapping a collection, default the config for
693-
// a new collection to the collection we are bootstrapping
694-
log.info("Setting config for collection: {} to {}", collection, defaultConfigName);
695-
696-
Properties sysProps = System.getProperties();
697-
for (String sprop : System.getProperties().stringPropertyNames()) {
698-
if (sprop.startsWith(ZkController.COLLECTION_PARAM_PREFIX)) {
699-
collectionProps.put(
700-
sprop.substring(ZkController.COLLECTION_PARAM_PREFIX.length()),
701-
sysProps.getProperty(sprop));
702-
}
703-
}
704-
705-
// if the config name wasn't passed in, use the default
706-
if (!collectionProps.containsKey(ZkController.CONFIGNAME_PROP))
707-
collectionProps.put(ZkController.CONFIGNAME_PROP, defaultConfigName);
708-
709-
} else if (Boolean.getBoolean("bootstrap_conf")) {
710-
// the conf name should should be the collection name of this core
711-
collectionProps.put(ZkController.CONFIGNAME_PROP, collection);
712685
} else {
713686
getConfName(
714687
stateManager, collection, collectionPath, collectionProps, configSetService);

solr/core/src/java/org/apache/solr/core/ConfigSetService.java

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
import org.apache.solr.cloud.ZkController;
3232
import org.apache.solr.common.ConfigNode;
3333
import org.apache.solr.common.SolrException;
34+
import org.apache.solr.common.util.EnvUtils;
3435
import org.apache.solr.common.util.NamedList;
35-
import org.apache.solr.common.util.StrUtils;
3636
import org.apache.solr.handler.admin.ConfigSetsHandler;
3737
import org.apache.solr.schema.IndexSchema;
3838
import org.apache.solr.schema.IndexSchemaFactory;
@@ -85,22 +85,16 @@ private static ConfigSetService instantiate(CoreContainer coreContainer) {
8585
}
8686

8787
private void bootstrapConfigSet(CoreContainer coreContainer) {
88-
// bootstrap _default conf, bootstrap_confdir and bootstrap_conf if provided via system property
88+
// bootstrap _default conf and solr.configset.bootstrap.confdir if provided via system property
8989
try {
9090
// _default conf
9191
bootstrapDefaultConf();
9292

9393
// bootstrap_confdir
94-
String confDir = System.getProperty("bootstrap_confdir");
94+
String confDir = EnvUtils.getProperty("solr.configset.bootstrap.confdir");
9595
if (confDir != null) {
9696
bootstrapConfDir(confDir);
9797
}
98-
99-
// bootstrap_conf
100-
boolean boostrapConf = Boolean.getBoolean("bootstrap_conf");
101-
if (boostrapConf == true) {
102-
bootstrapConf(coreContainer);
103-
}
10498
} catch (IOException e) {
10599
throw new SolrException(
106100
SolrException.ErrorCode.SERVER_ERROR, "Config couldn't be uploaded ", e);
@@ -129,8 +123,7 @@ private void bootstrapConfDir(String confDir) throws IOException {
129123
+ configPath);
130124
}
131125
String confName =
132-
System.getProperty(
133-
ZkController.COLLECTION_PARAM_PREFIX + ZkController.CONFIGNAME_PROP, "configuration1");
126+
EnvUtils.getProperty("solr.configset.bootstrap.config.name", "configuration1");
134127
this.uploadConfig(confName, configPath);
135128
}
136129

@@ -198,28 +191,6 @@ public static Path getConfigsetPath(String confDir, String configSetDir) {
198191
Path.of(configSetDir, confDir, "conf", "solrconfig.xml").normalize().toAbsolutePath()));
199192
}
200193

201-
/** If in SolrCloud mode, upload configSets for each SolrCore in solr.xml. */
202-
public static void bootstrapConf(CoreContainer cc) throws IOException {
203-
// List<String> allCoreNames = cfg.getAllCoreNames();
204-
List<CoreDescriptor> cds = cc.getCoresLocator().discover(cc);
205-
206-
if (log.isInfoEnabled()) {
207-
log.info(
208-
"bootstrapping config for {} cores into ZooKeeper using solr.xml from {}",
209-
cds.size(),
210-
cc.getSolrHome());
211-
}
212-
213-
for (CoreDescriptor cd : cds) {
214-
String coreName = cd.getName();
215-
String confName = cd.getCollectionName();
216-
if (StrUtils.isNullOrEmpty(confName)) confName = coreName;
217-
Path udir = cd.getInstanceDir().resolve("conf");
218-
log.info("Uploading directory {} with name {} for solrCore {}", udir, confName, coreName);
219-
cc.getConfigSetService().uploadConfig(confName, udir);
220-
}
221-
}
222-
223194
/**
224195
* Load the ConfigSet for a core
225196
*

solr/packaging/test/test_start_solr.bats

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ teardown() {
8282
}
8383

8484
@test "deprecated system properties converted to modern properties" {
85-
solr start -Denable.packages=true
86-
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.'
85+
solr start -Ddisable.v2.api=true
86+
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.'
8787
}
8888

8989
@test "start with custom jetty options" {
@@ -93,3 +93,17 @@ teardown() {
9393
solr start --jettyconfig "--module=server"
9494
solr assert --started http://localhost:${SOLR_PORT} --timeout 5000
9595
}
96+
97+
@test "bootstrapping a configset" {
98+
local confdir_path="${SOLR_TIP}/server/solr/configsets/sample_techproducts_configs/conf"
99+
100+
# Verify the source configset directory exists
101+
test -d "${confdir_path}"
102+
103+
# Start Solr with bootstrap_confdir pointing to techproducts configset
104+
solr start -Dbootstrap_confdir="${confdir_path}" -Dcollection.configName=techproducts
105+
solr assert --started http://localhost:${SOLR_PORT} --timeout 5000
106+
107+
# Verify the techproducts configset was uploaded
108+
config_exists "techproducts"
109+
}

solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ To learn about the updated options in each CLI tool, use the `--help` option or
4747
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.
4848
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.
4949

50+
The `bin/solr start --bootstrap_conf` flag is a legacy feature for converting from Solr to SolrCloud mode and has been removed.
51+
52+
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").
53+
That no longer happens in Solr 10. It is only used to load a configuration as a ConfigSet.
54+
5055
=== SolrJ
5156

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

solr/solrj-zookeeper/src/test/org/apache/solr/common/cloud/TestZkConfigSetService.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,14 @@
2323
import java.security.NoSuchAlgorithmException;
2424
import java.util.Arrays;
2525
import java.util.List;
26-
import java.util.Properties;
2726
import java.util.concurrent.TimeUnit;
2827
import org.apache.curator.framework.AuthInfo;
2928
import org.apache.curator.framework.api.ACLProvider;
3029
import org.apache.solr.SolrTestCaseJ4;
31-
import org.apache.solr.cloud.AbstractZkTestCase;
3230
import org.apache.solr.cloud.ZkConfigSetService;
3331
import org.apache.solr.cloud.ZkTestServer;
3432
import org.apache.solr.common.SolrException;
3533
import org.apache.solr.core.ConfigSetService;
36-
import org.apache.solr.core.CoreContainer;
3734
import org.apache.solr.util.LogLevel;
3835
import org.apache.zookeeper.KeeperException;
3936
import org.apache.zookeeper.ZooDefs;
@@ -228,28 +225,6 @@ public void testUploadWithACL() throws IOException, NoSuchAlgorithmException {
228225
}
229226
}
230227

231-
@Test
232-
public void testBootstrapConf() throws IOException, KeeperException, InterruptedException {
233-
234-
Path solrHome = legacyExampleCollection1SolrHome();
235-
236-
CoreContainer cc = new CoreContainer(solrHome, new Properties());
237-
System.setProperty("zkHost", zkServer.getZkAddress());
238-
239-
SolrZkClient zkClient =
240-
new SolrZkClient.Builder()
241-
.withUrl(zkServer.getZkHost())
242-
.withTimeout(AbstractZkTestCase.TIMEOUT, TimeUnit.MILLISECONDS)
243-
.build();
244-
zkClient.makePath("/solr", false, true);
245-
cc.setCoreConfigService(new ZkConfigSetService(zkClient));
246-
assertFalse(cc.getConfigSetService().checkConfigExists("collection1"));
247-
ConfigSetService.bootstrapConf(cc);
248-
assertTrue(cc.getConfigSetService().checkConfigExists("collection1"));
249-
250-
zkClient.close();
251-
}
252-
253228
static SolrZkClient buildZkClient(
254229
String zkAddress,
255230
final ACLProvider aclProvider,

solr/solrj/src/resources/DeprecatedSystemPropertyMappings.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ solr.default.confdir=solr.configset.default.confdir
1313
solr.admin.ui.disabled=solr.ui.enabled
1414
solr.admin.ui.experimental.disabled=solr.ui.experimental.enabled
1515
solr.log.dir=solr.logs.dir
16-
solr.default.confdir=solr.configset.default.confdir
1716
solr.wait.for.zk=solr.cloud.wait.for.zk.seconds
1817
solr.enable.remote.streaming=solr.requests.streaming.remote.enabled
1918
solr.enable.stream.body=solr.requests.streaming.body.enabled
@@ -26,8 +25,9 @@ solr.hide.stack.trace=solr.responses.stacktrace.enabled
2625
authentication.plugin=solr.security.auth.plugin
2726
basicauth=solr.security.auth.basicauth.credentials
2827
cloud.solr.client.max.stale.retries=solr.solrj.cloud.max.stale.retries
29-
configset.upload.enabled=solr.configset.upload.enabled
3028
solr.hidden.sys.props=solr.responses.hidden.sys.props
3129
max.file.store.size=solr.filestore.filesize.max
3230
prep.recovery.read.timeout.extra.wait=solr.cloud.prep.recovery.read.timeout.additional.ms
3331
solr.allow.unsafe.resourceloading=solr.resourceloading.restricted.enabled
32+
bootstrap_confdir=solr.configset.bootstrap.confdir
33+
collection.configName=solr.configset.bootstrap.config.name

0 commit comments

Comments
 (0)