Skip to content

Commit

Permalink
Rename CONF_DIR to ES_PATH_CONF
Browse files Browse the repository at this point in the history
The environment variable CONF_DIR was previously inconsistently used in
our packaging to customize the location of Elasticsearch configuration
files. The importance of this environment variable has increased
starting in 6.0.0 as it's now used consistently to ensure Elasticsearch
and all secondary scripts (e.g., elasticsearch-keystore) all use the
same configuration. The name CONF_DIR is there for legacy reasons yet
it's too generic. This commit renames CONF_DIR to ES_PATH_CONF.

Relates elastic#26197
  • Loading branch information
jasontedor authored Aug 14, 2017
1 parent 6202114 commit e968762
Show file tree
Hide file tree
Showing 35 changed files with 86 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class ClusterFormationTasks {
if (unicastTransportUri != null) {
esConfig['discovery.zen.ping.unicast.hosts'] = "\"${unicastTransportUri}\""
}
File configFile = new File(node.confDir, 'elasticsearch.yml')
File configFile = new File(node.pathConf, 'elasticsearch.yml')
logger.info("Configuring ${configFile}")
configFile.setText(esConfig.collect { key, value -> "${key}: ${value}" }.join('\n'), 'UTF-8')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class NodeInfo {
File homeDir

/** config directory */
File confDir
File pathConf

/** data directory (as an Object, to allow lazy evaluation) */
Object dataDir
Expand Down Expand Up @@ -110,13 +110,13 @@ class NodeInfo {
pidFile = new File(baseDir, 'es.pid')
this.nodeVersion = nodeVersion
homeDir = homeDir(baseDir, config.distribution, nodeVersion)
confDir = confDir(baseDir, config.distribution, nodeVersion)
pathConf = pathConf(baseDir, config.distribution, nodeVersion)
if (config.dataDir != null) {
dataDir = "${config.dataDir(nodeNum)}"
} else {
dataDir = new File(homeDir, "data")
}
configFile = new File(confDir, 'elasticsearch.yml')
configFile = new File(pathConf, 'elasticsearch.yml')
// even for rpm/deb, the logs are under home because we dont start with real services
File logsDir = new File(homeDir, 'logs')
httpPortsFile = new File(logsDir, 'http.ports')
Expand Down Expand Up @@ -158,9 +158,9 @@ class NodeInfo {
args.add("${property.key.substring('tests.es.'.size())}=${property.value}")
}
}
env.put('CONF_DIR', confDir)
env.put('ES_PATH_CONF', pathConf)
if (Version.fromString(nodeVersion).major == 5) {
args.addAll("-E", "path.conf=${confDir}")
args.addAll("-E", "path.conf=${pathConf}")
}
if (!System.properties.containsKey("tests.es.path.data")) {
args.addAll("-E", "path.data=${-> dataDir.toString()}")
Expand Down Expand Up @@ -240,7 +240,7 @@ class NodeInfo {
return new File(baseDir, path)
}

static File confDir(File baseDir, String distro, String nodeVersion) {
static File pathConf(File baseDir, String distro, String nodeVersion) {
switch (distro) {
case 'integ-test-zip':
case 'zip':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import org.gradle.api.DefaultTask
import org.gradle.api.Task
import org.gradle.api.execution.TaskExecutionAdapter
import org.gradle.api.internal.tasks.options.Option
import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskState

Expand Down Expand Up @@ -68,7 +67,7 @@ public class RestIntegTestTask extends DefaultTask {
// we pass all nodes to the rest cluster to allow the clients to round-robin between them
// this is more realistic than just talking to a single node
runner.systemProperty('tests.rest.cluster', "${-> nodes.collect{it.httpUri()}.join(",")}")
runner.systemProperty('tests.config.dir', "${-> nodes[0].confDir}")
runner.systemProperty('tests.config.dir', "${-> nodes[0].pathConf}")
// TODO: our "client" qa tests currently use the rest-test plugin. instead they should have their own plugin
// that sets up the test cluster and passes this transport uri instead of http uri. Until then, we pass
// both as separate sysprops
Expand Down
4 changes: 2 additions & 2 deletions distribution/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -521,12 +521,12 @@ Map<String, String> expansionsForDistribution(distributionType) {
'rpm': '/etc/sysconfig/elasticsearch',
/* There isn't one of these files for tar or zip but its important to
make an empty string here so the script can properly skip it. */
'def': 'if [ -z "$CONF_DIR" ]; then CONF_DIR="$ES_HOME"/config; done',
'def': 'if [ -z "$ES_PATH_CONF" ]; then ES_PATH_CONF="$ES_HOME"/config; done',
],
'source.path.env': [
'deb': 'if [ -f /etc/default/elasticsearch ]; then source /etc/default/elasticsearch; fi',
'rpm': 'if [ -f /etc/sysconfig/elasticsearch ]; then source /etc/sysconfig/elasticsearch; fi',
'def': 'if [ -z "$CONF_DIR" ]; then CONF_DIR="$ES_HOME"/config; fi',
'def': 'if [ -z "$ES_PATH_CONF" ]; then ES_PATH_CONF="$ES_HOME"/config; fi',
],
'path.logs': [
'deb': packagingPathLogs,
Expand Down
4 changes: 2 additions & 2 deletions distribution/deb/src/main/packaging/init.d/elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ MAX_OPEN_FILES=65536
#MAX_LOCKED_MEMORY=

# Elasticsearch configuration directory
CONF_DIR=/etc/$NAME
ES_PATH_CONF=/etc/$NAME

# Maximum number of VMA (Virtual Memory Areas) a process can own
MAX_MAP_COUNT=262144
Expand Down Expand Up @@ -73,7 +73,7 @@ DAEMON_OPTS="-d -p $PID_FILE"

export ES_JAVA_OPTS
export JAVA_HOME
export CONF_DIR
export ES_PATH_CONF

if [ ! -x "$DAEMON" ]; then
echo "The elasticsearch startup script does not exists or it is not executable, tried: $DAEMON"
Expand Down
4 changes: 2 additions & 2 deletions distribution/rpm/src/main/packaging/init.d/elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fi
ES_HOME="/usr/share/elasticsearch"
MAX_OPEN_FILES=65536
MAX_MAP_COUNT=262144
CONF_DIR="${path.conf}"
ES_PATH_CONF="${path.conf}"

PID_DIR="/var/run/elasticsearch"

Expand All @@ -57,7 +57,7 @@ pidfile="$PID_DIR/${prog}.pid"

export ES_JAVA_OPTS
export JAVA_HOME
export CONF_DIR
export ES_PATH_CONF
export ES_STARTUP_SLEEP_TIME

lockfile=/var/lock/subsys/$prog
Expand Down
2 changes: 1 addition & 1 deletion distribution/src/main/packaging/env/elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#JAVA_HOME=

# Elasticsearch configuration directory
CONF_DIR=${path.conf}
ES_PATH_CONF=${path.conf}

# Elasticsearch PID directory
#PID_DIR=/var/run/elasticsearch
Expand Down
6 changes: 3 additions & 3 deletions distribution/src/main/packaging/scripts/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ LOG_DIR="/var/log/elasticsearch"
PLUGINS_DIR="/usr/share/elasticsearch/plugins"
PID_DIR="/var/run/elasticsearch"
DATA_DIR="/var/lib/elasticsearch"
CONF_DIR="/etc/elasticsearch"
ES_PATH_CONF="/etc/elasticsearch"

# Source the default env file
if [ "$SOURCE_ENV_FILE" = "true" ]; then
Expand Down Expand Up @@ -86,8 +86,8 @@ if [ "$REMOVE_DIRS" = "true" ]; then
fi

# delete the conf directory if and only if empty
if [ -d "$CONF_DIR" ]; then
rmdir --ignore-fail-on-non-empty "$CONF_DIR"
if [ -d "$ES_PATH_CONF" ]; then
rmdir --ignore-fail-on-non-empty "$ES_PATH_CONF"
fi

fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ After=network-online.target

[Service]
Environment=ES_HOME=/usr/share/elasticsearch
Environment=CONF_DIR=${path.conf}
Environment=ES_PATH_CONF=${path.conf}
Environment=PID_DIR=/var/run/elasticsearch
EnvironmentFile=-${path.env}

Expand Down
8 changes: 4 additions & 4 deletions distribution/src/main/resources/bin/elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This script relies on a few environment variables to determine startup
# behavior, those variables are:
#
# CONF_DIR -- Path to config directory
# ES_PATH_CONF -- Path to config directory
# ES_JAVA_OPTS -- External Java Opts on top of the defaults set
#
# Optionally, exact memory values can be set using the `ES_JAVA_OPTS`. Note that
Expand All @@ -22,7 +22,7 @@ parse_jvm_options() {
fi
}

ES_JVM_OPTIONS="$CONF_DIR"/jvm.options
ES_JVM_OPTIONS="$ES_PATH_CONF"/jvm.options

ES_JAVA_OPTS="`parse_jvm_options "$ES_JVM_OPTIONS"` $ES_JAVA_OPTS"

Expand All @@ -32,7 +32,7 @@ if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' > /dev/null;
"$JAVA" \
$ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \
-Des.path.conf="$CONF_DIR" \
-Des.path.conf="$ES_PATH_CONF" \
-cp "$ES_CLASSPATH" \
org.elasticsearch.bootstrap.Elasticsearch \
"$@"
Expand All @@ -41,7 +41,7 @@ else
"$JAVA" \
$ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \
-Des.path.conf="$CONF_DIR" \
-Des.path.conf="$ES_PATH_CONF" \
-cp "$ES_CLASSPATH" \
org.elasticsearch.bootstrap.Elasticsearch \
"$@" \
Expand Down
4 changes: 2 additions & 2 deletions distribution/src/main/resources/bin/elasticsearch-env
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fi

${source.path.env}

if [ -z "$CONF_DIR" ]; then
echo "CONF_DIR must be set to the configuration path"
if [ -z "$ES_PATH_CONF" ]; then
echo "ES_PATH_CONF must be set to the configuration path"
exit 1
fi
4 changes: 2 additions & 2 deletions distribution/src/main/resources/bin/elasticsearch-env.bat
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ if not "%JAVA_OPTS%" == "" (
rem check the Java version
%JAVA% -cp "%ES_CLASSPATH%" "org.elasticsearch.tools.JavaVersionChecker" || exit /b 1

if "%CONF_DIR%" == "" (
set CONF_DIR=!ES_HOME!\config
if "%ES_PATH_CONF%" == "" (
set ES_PATH_CONF=!ES_HOME!\config
)
2 changes: 1 addition & 1 deletion distribution/src/main/resources/bin/elasticsearch-keystore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exec \
"$JAVA" \
$ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \
-Des.path.conf="$CONF_DIR" \
-Des.path.conf="$ES_PATH_CONF" \
-cp "$ES_CLASSPATH" \
org.elasticsearch.common.settings.KeyStoreCli \
"$@"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1
%JAVA% ^
%ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^
-Des.path.conf="%CONF_DIR%" ^
-Des.path.conf="%ES_PATH_CONF%" ^
-cp "%ES_CLASSPATH%" ^
org.elasticsearch.common.settings.KeyStoreCli ^
%*
Expand Down
2 changes: 1 addition & 1 deletion distribution/src/main/resources/bin/elasticsearch-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exec \
"$JAVA" \
$ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \
-Des.path.conf="$CONF_DIR" \
-Des.path.conf="$ES_PATH_CONF" \
-cp "$ES_CLASSPATH" \
org.elasticsearch.plugins.PluginCli \
"$@"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1
%JAVA% ^
%ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^
-Des.path.conf="%CONF_DIR%" ^
-Des.path.conf="%ES_PATH_CONF%" ^
-cp "%ES_CLASSPATH%" ^
org.elasticsearch.plugins.PluginCli ^
%*
Expand Down
4 changes: 2 additions & 2 deletions distribution/src/main/resources/bin/elasticsearch-service.bat
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ if exist "%JAVA_HOME%\bin\server\jvm.dll" (
)

:foundJVM
set ES_JVM_OPTIONS=%CONF_DIR%\jvm.options
set ES_JVM_OPTIONS=%ES_PATH_CONF%\jvm.options

if not "%ES_JAVA_OPTS%" == "" set ES_JAVA_OPTS=%ES_JAVA_OPTS: =;%

Expand Down Expand Up @@ -174,7 +174,7 @@ if "%JVM_SS%" == "" (
goto:eof
)

set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%CONF_DIR%"
set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%ES_PATH_CONF%"

if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual
if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0
Expand Down
2 changes: 1 addition & 1 deletion distribution/src/main/resources/bin/elasticsearch-translog
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exec \
"$JAVA" \
$ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \
-Des.path.conf="$CONF_DIR" \
-Des.path.conf="$ES_PATH_CONF" \
-cp "$ES_CLASSPATH" \
org.elasticsearch.index.translog.TranslogToolCli \
"$@"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1
%JAVA% ^
%ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^
-Des.path.conf="%CONF_DIR%" ^
-Des.path.conf="%ES_PATH_CONF%" ^
-cp "%ES_CLASSPATH%" ^
org.elasticsearch.index.translog.TranslogToolCli ^
%*
Expand Down
4 changes: 2 additions & 2 deletions distribution/src/main/resources/bin/elasticsearch.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ IF ERRORLEVEL 1 (
EXIT /B %ERRORLEVEL%
)

set "ES_JVM_OPTIONS=%CONF_DIR%\jvm.options"
set "ES_JVM_OPTIONS=%ES_PATH_CONF%\jvm.options"

@setlocal
rem extract the options from the JVM options file %ES_JVM_OPTIONS%
rem such options are the lines beginning with '-', thus "findstr /b"
for /F "usebackq delims=" %%a in (`findstr /b \- "%ES_JVM_OPTIONS%"`) do set JVM_OPTIONS=!JVM_OPTIONS! %%a
@endlocal & set ES_JAVA_OPTS=%JVM_OPTIONS% %ES_JAVA_OPTS%

%JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%CONF_DIR%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams!
%JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams!

endlocal
2 changes: 1 addition & 1 deletion docs/plugins/plugin-script.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ can do this as follows:

[source,sh]
---------------------
sudo CONF_DIR=/path/to/conf/dir bin/elasticsearch-plugin install <plugin name>
sudo ES_PATH_CONF=/path/to/conf/dir bin/elasticsearch-plugin install <plugin name>
---------------------

[float]
Expand Down
13 changes: 11 additions & 2 deletions docs/reference/migration/migrate_6_0/packaging.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@ Previous versions of Elasticsearch enabled setting `path.conf` as a
setting. This was rather convoluted as it meant that you could start
Elasticsearch with a config file that specified via `path.conf` that
Elasticsearch should use another config file. Instead, to configure a custom
config directory, use the <<config-files-location,`CONF_DIR` environment
config directory, use the <<config-files-location,`ES_PATH_CONF` environment
variable>>.

==== `CONF_DIR` is no longer supported

Previous versions of Elasticsearch enabled using the `CONF_DIR` environment
variable to specify a custom configuration directory for some configuration
files and some scripts (it was used inconsistently). Starting in Elasticsearch
6.0.0, the usage of this environment variable has been superceded by
`ES_PATH_CONF`, and this new environment variable is consistently used for all
configuration files and scripts.

==== Default path settings are removed

Previous versions of Elasticsearch enabled setting `default.path.data` and
Expand Down Expand Up @@ -56,7 +65,7 @@ are no longer maintaining this attempt.

The environment variable `ES_JVM_OPTIONS` that enabled a custom location for the
`jvm.options` file has been removed in favor of using the environment variable
`CONF_DIR`. This environment variable is already used in the packaging to
`ES_PATH_CONF`. This environment variable is already used in the packaging to
support relocating the configuration files so this change merely aligns the
other configuration files with the location of the `jvm.options` file.

Expand Down
12 changes: 6 additions & 6 deletions docs/reference/setup/configuration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ on whether or not the installation is from an archive distribution (`tar.gz` or

For the archive distributions, the config directory location defaults to
`$ES_HOME/config`. The location of the config directory can be changed via the
`CONF_DIR` environment variable as follows:
`ES_PATH_CONF` environment variable as follows:

[source,sh]
-------------------------------
CONF_DIR=/path/to/my/config ./bin/elasticsearch
ES_PATH_CONF=/path/to/my/config ./bin/elasticsearch
-------------------------------

Alternatively, you can `export` the `CONF_DIR` environment variable via the
Alternatively, you can `export` the `ES_PATH_CONF` environment variable via the
command line or via your shell profile.

For the package distributions, the config directory location defaults to
`/etc/elasticsearch`. The location of the config directory can also be changed
via the `CONF_DIR` environment variable, but note that setting this in your
via the `ES_PATH_CONF` environment variable, but note that setting this in your
shell is not sufficient. Instead, this variabled is sourced from
`/etc/default/elasticsearch` (for the Debian package) and
`/etc/sysconfig/elasticsearch` (for the RPM package). You will need to edit the
`CONF_DIR=/etc/elasticsearch` entry in one of these files accordingly to change
the config directory location.
`ES_PATH_CONF=/etc/elasticsearch` entry in one of these files accordingly to
change the config directory location.


[float]
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/setup/install/deb.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ locations for a Debian-based system:
| conf
| Configuration files including `elasticsearch.yml`
| /etc/elasticsearch
| <<config-files-location,CONF_DIR>>
| <<config-files-location,ES_PATH_CONF>>

| conf
| Environment variables including heap size, file descriptors.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/setup/install/rpm.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ locations for an RPM-based system:
| conf
| Configuration files including `elasticsearch.yml`
| /etc/elasticsearch
| <<config-files-location,CONF_DIR>>
| <<config-files-location,ES_PATH_CONF>>

| conf
| Environment variables including heap size, file descriptors.
Expand Down
Loading

0 comments on commit e968762

Please sign in to comment.