SOLR-11108: Shorten/improve _default-configset msg

The bin/solr scripts print a warning message when a user creates a
collection that makes use of the default config (which has settings
not recommended for production).

While helpful, this warning was a little too noisy.  It also suggested
users resolve the issue with a provided curl command, but bin/solr is
also capable of performing the same action.

This commit cleans up the error message a bit.
This commit is contained in:
Jason Gerlowski 2018-02-17 19:08:26 -05:00
parent d91e4cbea2
commit b4f8cd7ea6
3 changed files with 52 additions and 14 deletions

View File

@ -295,7 +295,7 @@ function print_usage() {
if [ -z "$CMD" ]; then
echo ""
echo "Usage: solr COMMAND OPTIONS"
echo " where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert"
echo " where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config"
echo ""
echo " Standalone server example (start Solr running in the background on port 8984):"
echo ""
@ -895,6 +895,11 @@ if [ "$SCRIPT_CMD" == "healthcheck" ]; then
exit $?
fi
if [[ "$SCRIPT_CMD" == "config" ]]; then
run_tool config $*
exit $?
fi
# create a core or collection
if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMD" == "create_collection" ]]; then
@ -1015,11 +1020,8 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CM
fi
if [[ "$CREATE_CONFDIR" == "_default" ]] && ([[ "$CREATE_CONFNAME" == "" ]] || [[ "$CREATE_CONFNAME" == "_default" ]]); then
echo "WARNING: Using _default configset. Data driven schema functionality is enabled by default, which is"
echo " NOT RECOMMENDED for production use."
echo
echo " To turn it off:"
echo " curl http://$SOLR_TOOL_HOST:$CREATE_PORT/solr/$CREATE_NAME/config -d '{\"set-user-property\": {\"update.autoCreateFields\":\"false\"}}'"
echo "WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use."
echo " To turn off: bin/solr config -c $CREATE_NAME -p $CREATE_PORT -property update.autoCreateFields -value false"
fi
if [[ "$(whoami)" == "root" ]] && [[ "$FORCE" == "false" ]] ; then

View File

@ -200,6 +200,7 @@ IF "%1"=="version" goto get_version
IF "%1"=="-v" goto get_version
IF "%1"=="-version" goto get_version
IF "%1"=="assert" goto run_assert
if "%1"=="config" goto run_config
REM Only allow the command to be the first argument, assume start if not supplied
IF "%1"=="start" goto set_script_cmd
@ -268,7 +269,7 @@ goto done
:script_usage
@echo.
@echo Usage: solr COMMAND OPTIONS
@echo where COMMAND is one of: start, stop, restart, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert
@echo where COMMAND is one of: start, stop, restart, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config
@echo.
@echo Standalone server example (start Solr running in the background on port 8984):
@echo.
@ -1363,6 +1364,16 @@ if errorlevel 1 (
)
goto done
:run_config
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
org.apache.solr.util.SolrCLI %*
if errorlevel 1 (
exit /b 1
)
goto done
:get_version
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
@ -1475,10 +1486,8 @@ if "!CREATE_PORT!"=="" (
)
if "!CREATE_CONFDIR!"=="_default" (
echo WARNING: Using _default configset. Data driven schema functionality is enabled by default, which is
echo NOT RECOMMENDED for production use.
echo To turn it off:
echo curl http://%SOLR_TOOL_HOST%:!CREATE_PORT!/solr/!CREATE_NAME!/config -d '{"set-user-property": {"update.autoCreateFields":"false"}}'
echo WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use.
echo To turn off: bin\solr config -c !CREATE_NAME! -p !CREATE_PORT! -property update.autoCreateFields -value false
)
if "%SCRIPT_CMD%"=="create_core" (

View File

@ -238,7 +238,8 @@ public class SolrCLI {
.hasArg()
.isRequired(false)
.withDescription("Name of collection; no default")
.create("collection"),
.withLongOpt("collection")
.create("c"),
OptionBuilder
.isRequired(false)
.withDescription("Enable more verbose command output.")
@ -2525,13 +2526,39 @@ public class SolrCLI {
.hasArg()
.isRequired(false)
.withDescription("Base Solr URL, which can be used to determine the zkHost if that's not known")
.create("solrUrl")
.create("solrUrl"),
OptionBuilder
.withArgName("PORT")
.hasArg()
.isRequired(false)
.withDescription("The port of the Solr node to use when applying configuration change")
.withLongOpt("port")
.create('p'),
OptionBuilder
.withArgName("SCHEME")
.hasArg()
.isRequired(false)
.withDescription("The scheme for accessing Solr. Accepted values: http or https. Default: http")
.withLongOpt("scheme")
.create('s')
};
return joinOptions(configOptions, cloudOptions);
}
protected void runImpl(CommandLine cli) throws Exception {
String solrUrl = resolveSolrUrl(cli);
String solrUrl;
try {
solrUrl = resolveSolrUrl(cli);
} catch (IllegalStateException e) {
// Fallback to using the provided scheme and port
final String scheme = cli.getOptionValue("scheme", "http");
if (cli.hasOption("port")) {
solrUrl = scheme + "://localhost:" + cli.getOptionValue("port", "8983") + "/solr";
} else {
throw e;
}
}
String action = cli.getOptionValue("action", "set-property");
String collection = cli.getOptionValue("collection", "gettingstarted");
String property = cli.getOptionValue("property");