Fail if unsupported environment variables are set

This commit adds a hard failure on startup if any unsupported
environment variables from older versions of Elasticsearch are still
set.
This commit is contained in:
Jason Tedor 2016-04-12 13:13:42 -04:00
parent 2b1c191b12
commit d4cf0f021a
3 changed files with 71 additions and 0 deletions

View File

@ -54,6 +54,33 @@ EOF
exit 1
fi
# TODO: remove for Elasticsearch 6.x
unsupported_environment_variable() {
if [ ! -z "$1" ]; then
echo "$2=$1"
fi
}
if [[ !(-z "$ES_MIN_MEM" &&
-z "$ES_MAX_MEM" &&
-z "$ES_HEAP_SIZE" &&
-z "$ES_HEAP_NEWSIZE" &&
-z "$ES_DIRECT_SIZE" &&
-z "$ES_USE_IPV4" &&
-z "$ES_GC_OPTS") ]]; then
echo "Error: encountered environment variables that are no longer supported"
echo "Use jvm.options or ES_JAVA_OPTS to configure the JVM"
unsupported_environment_variable "$ES_MIN_MEM" ES_MIN_MEM
unsupported_environment_variable "$ES_MAX_MEM" ES_MAX_MEM
unsupported_environment_variable "$ES_HEAP_SIZE" ES_HEAP_SIZE
unsupported_environment_variable "$ES_HEAP_NEWSIZE" ES_HEAP_NEWSIZE
unsupported_environment_variable "$ES_DIRECT_SIZE" ES_DIRECT_SIZE
unsupported_environment_variable "$ES_USE_IPV4" ES_USE_IPV4
unsupported_environment_variable "$ES_GC_OPTS" ES_GC_OPTS
exit 1
fi
# end TODO: remove for Elasticsearch 6.x
parse_jvm_options() {
if [ -f "$1" ]; then
echo "$(grep "^-" "$1" | tr '\n' ' ')"

View File

@ -5,6 +5,28 @@ TITLE Elasticsearch ${project.version}
SET params='%*'
rem TODO: remove for Elasticsearch 6.x
if not "%ES_MIN_MEM%" == "" set bad_env_var=1
if not "%ES_MAX_MEM%" == "" set bad_env_var=1
if not "%ES_HEAP_SIZE%" == "" set bad_env_var=1
if not "%ES_HEAP_NEWSIZE%" == "" set bad_env_var=1
if not "%ES_DIRECT_SIZE%" == "" set bad_env_var=1
if not "%ES_USE_IPV4%" == "" set bad_env_var=1
if not "%ES_GC_OPTS%" == "" set bad_env_var=1
if %bad_env_var% == 1 (
echo Error: encountered environment variables that are no longer supported
echo Use jvm.options or ES_JAVA_OPTS to configure the JVM
if not "%ES_MIN_MEM%" == "" echo ES_MIN_MEM=%ES_MIN_MEM%
if not "%ES_MAX_MEM%" == "" echo ES_MAX_MEM=%ES_MAX_MEM%
if not "%ES_HEAP_SIZE%" == "" echo ES_HEAP_SIZE=%ES_HEAP_SIZE%
if not "%ES_HEAP_NEWSIZE%" == "" echo ES_HEAP_NEWSIZE=%ES_HEAP_NEWSIZE%
if not "%ES_DIRECT_SIZE%" == "" echo ES_DIRECT_SIZE=%ES_DIRECT_SIZE%
if not "%ES_USE_IPV4%" == "" echo ES_USE_IPV4=%ES_USE_IPV4%
if not "%ES_GC_OPTS%" == "" echo ES_GC_OPTS=%ES_GC_OPTS%
exit /b 1
)
rem end TODO: remove for Elasticsearch 6.x
:loop
FOR /F "usebackq tokens=1* delims= " %%A IN (!params!) DO (
SET current=%%A

View File

@ -3,6 +3,28 @@ SETLOCAL enabledelayedexpansion
TITLE Elasticsearch Service ${project.version}
rem TODO: remove for Elasticsearch 6.x
if not "%ES_MIN_MEM%" == "" set bad_env_var=1
if not "%ES_MAX_MEM%" == "" set bad_env_var=1
if not "%ES_HEAP_SIZE%" == "" set bad_env_var=1
if not "%ES_HEAP_NEWSIZE%" == "" set bad_env_var=1
if not "%ES_DIRECT_SIZE%" == "" set bad_env_var=1
if not "%ES_USE_IPV4%" == "" set bad_env_var=1
if not "%ES_GC_OPTS%" == "" set bad_env_var=1
if %bad_env_var% == 1 (
echo Error: encountered environment variables that are no longer supported
echo Use jvm.options or ES_JAVA_OPTS to configure the JVM
if not "%ES_MIN_MEM%" == "" echo ES_MIN_MEM=%ES_MIN_MEM%
if not "%ES_MAX_MEM%" == "" echo ES_MAX_MEM=%ES_MAX_MEM%
if not "%ES_HEAP_SIZE%" == "" echo ES_HEAP_SIZE=%ES_HEAP_SIZE%
if not "%ES_HEAP_NEWSIZE%" == "" echo ES_HEAP_NEWSIZE=%ES_HEAP_NEWSIZE%
if not "%ES_DIRECT_SIZE%" == "" echo ES_DIRECT_SIZE=%ES_DIRECT_SIZE%
if not "%ES_USE_IPV4%" == "" echo ES_USE_IPV4=%ES_USE_IPV4%
if not "%ES_GC_OPTS%" == "" echo ES_GC_OPTS=%ES_GC_OPTS%
exit /b 1
)
rem end TODO: remove for Elasticsearch 6.x
if NOT DEFINED JAVA_HOME goto err
if not "%CONF_FILE%" == "" goto conffileset