diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index 0b25737128d..d6e131170f3 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -387,7 +387,7 @@ class ClusterFormationTasks { Map esConfig = [ 'cluster.name' : node.clusterName, 'node.name' : "node-" + node.nodeNum, - 'pidfile' : node.pidFile, + (node.nodeVersion.onOrAfter('7.4.0') ? 'node.pidfile' : 'pidfile') : node.pidFile, 'path.repo' : "${node.sharedDir}/repo", 'path.shared_data' : "${node.sharedDir}/", // Define a node attribute so we can test that it exists diff --git a/dev-tools/smoke_test_rc.py b/dev-tools/smoke_test_rc.py index f78e2c2adf4..f600e7c5bcf 100644 --- a/dev-tools/smoke_test_rc.py +++ b/dev-tools/smoke_test_rc.py @@ -200,7 +200,7 @@ def smoke_test_release(release, files, hash, plugins): headers = {} print(' Starting elasticsearch deamon from [%s]' % es_dir) try: - run('%s; %s -Enode.name=smoke_tester -Ecluster.name=prepare_release -Erepositories.url.allowed_urls=http://snapshot.test* %s -Epidfile=%s -Enode.portsfile=true' + run('%s; %s -Enode.name=smoke_tester -Ecluster.name=prepare_release -Erepositories.url.allowed_urls=http://snapshot.test* %s -Enode.pidfile=%s -Enode.portsfile=true' % (java_exe(), es_run_path, '-d', os.path.join(es_dir, 'es-smoke.pid'))) if not wait_for_node_startup(es_dir, header=headers): print("elasticsearch logs:") diff --git a/docs/reference/migration/migrate_7_4.asciidoc b/docs/reference/migration/migrate_7_4.asciidoc index 9a6a50cab18..f951c7d0556 100644 --- a/docs/reference/migration/migrate_7_4.asciidoc +++ b/docs/reference/migration/migrate_7_4.asciidoc @@ -119,6 +119,13 @@ be disabled by setting the system property [[breaking_74_settings_changes]] === Settings changes +[discrete] +[[deprecate-pidfile]] +==== `pidfile` setting is being replaced by `node.pidfile` + +To ensure that all settings are in a proper namespace, the `pidfile` setting is +deprecated, and will be removed in version 8.0.0. Instead, use `node.pidfile`. + [discrete] [[deprecate-processors]] ==== `processors` setting is being replaced by `node.processors` diff --git a/qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilSecurityTests.java b/qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilSecurityTests.java index 1c34e07529a..e01fa81e218 100644 --- a/qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilSecurityTests.java +++ b/qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilSecurityTests.java @@ -85,7 +85,7 @@ public class EvilSecurityTests extends ESTestCase { esHome.resolve("data2").toString()); settingsBuilder.put(Environment.PATH_SHARED_DATA_SETTING.getKey(), esHome.resolve("custom").toString()); settingsBuilder.put(Environment.PATH_LOGS_SETTING.getKey(), esHome.resolve("logs").toString()); - settingsBuilder.put(Environment.PIDFILE_SETTING.getKey(), esHome.resolve("test.pid").toString()); + settingsBuilder.put(Environment.NODE_PIDFILE_SETTING.getKey(), esHome.resolve("test.pid").toString()); Settings settings = settingsBuilder.build(); Path fakeTmpDir = createTempDir(); diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index e1ca9d7d2f9..5e719164a1c 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -258,7 +258,7 @@ final class Bootstrap { final Path configPath) { Settings.Builder builder = Settings.builder(); if (pidFile != null) { - builder.put(Environment.PIDFILE_SETTING.getKey(), pidFile); + builder.put(Environment.NODE_PIDFILE_SETTING.getKey(), pidFile); } builder.put(initialSettings); if (secureSettings != null) { diff --git a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java index ad59044e439..69f4f19dd51 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java @@ -402,6 +402,7 @@ public final class ClusterSettings extends AbstractScopedSettings { Environment.PATH_REPO_SETTING, Environment.PATH_SHARED_DATA_SETTING, Environment.PIDFILE_SETTING, + Environment.NODE_PIDFILE_SETTING, NodeEnvironment.NODE_ID_SEED_SETTING, DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING, DiscoveryModule.DISCOVERY_TYPE_SETTING, diff --git a/server/src/main/java/org/elasticsearch/env/Environment.java b/server/src/main/java/org/elasticsearch/env/Environment.java index da9f7d0915e..261406db2f7 100644 --- a/server/src/main/java/org/elasticsearch/env/Environment.java +++ b/server/src/main/java/org/elasticsearch/env/Environment.java @@ -60,7 +60,8 @@ public class Environment { public static final Setting> PATH_REPO_SETTING = Setting.listSetting("path.repo", Collections.emptyList(), Function.identity(), Property.NodeScope); public static final Setting PATH_SHARED_DATA_SETTING = Setting.simpleString("path.shared_data", Property.NodeScope); - public static final Setting PIDFILE_SETTING = Setting.simpleString("pidfile", Property.NodeScope); + public static final Setting PIDFILE_SETTING = Setting.simpleString("pidfile", Property.Deprecated, Property.NodeScope); + public static final Setting NODE_PIDFILE_SETTING = Setting.simpleString("node.pidfile", PIDFILE_SETTING, Property.NodeScope); private final Settings settings; @@ -154,8 +155,8 @@ public class Environment { logsFile = homeFile.resolve("logs"); } - if (PIDFILE_SETTING.exists(settings)) { - pidFile = PathUtils.get(PIDFILE_SETTING.get(settings)).toAbsolutePath().normalize(); + if (NODE_PIDFILE_SETTING.exists(settings) || PIDFILE_SETTING.exists(settings)) { + pidFile = PathUtils.get(NODE_PIDFILE_SETTING.get(settings)).toAbsolutePath().normalize(); } else { pidFile = null; } @@ -179,7 +180,10 @@ public class Environment { assert sharedDataFile != null; finalSettings.put(Environment.PATH_SHARED_DATA_SETTING.getKey(), sharedDataFile.toString()); } - if (PIDFILE_SETTING.exists(settings)) { + if (NODE_PIDFILE_SETTING.exists(settings)) { + assert pidFile != null; + finalSettings.put(Environment.NODE_PIDFILE_SETTING.getKey(), pidFile.toString()); + } else if (PIDFILE_SETTING.exists(settings)) { assert pidFile != null; finalSettings.put(Environment.PIDFILE_SETTING.getKey(), pidFile.toString()); } diff --git a/server/src/test/java/org/elasticsearch/env/EnvironmentTests.java b/server/src/test/java/org/elasticsearch/env/EnvironmentTests.java index 2ee82fca33e..ee9fc0b694e 100644 --- a/server/src/test/java/org/elasticsearch/env/EnvironmentTests.java +++ b/server/src/test/java/org/elasticsearch/env/EnvironmentTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.env; import org.elasticsearch.common.io.PathUtils; +import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESTestCase; @@ -174,13 +175,20 @@ public class EnvironmentTests extends ESTestCase { // test that environment paths are absolute and normalized public void testPathNormalization() throws IOException { + final Setting pidFileSetting; + if (randomBoolean()) { + pidFileSetting = Environment.NODE_PIDFILE_SETTING; + } else { + pidFileSetting = Environment.PIDFILE_SETTING; + } + final Settings settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), "home") .put(Environment.PATH_DATA_SETTING.getKey(), "./home/../home/data") .put(Environment.PATH_LOGS_SETTING.getKey(), "./home/../home/logs") .put(Environment.PATH_REPO_SETTING.getKey(), "./home/../home/repo") .put(Environment.PATH_SHARED_DATA_SETTING.getKey(), "./home/../home/shared_data") - .put(Environment.PIDFILE_SETTING.getKey(), "./home/../home/pidfile") + .put(pidFileSetting.getKey(), "./home/../home/pidfile") .build(); // the above paths will be treated as relative to the working directory @@ -205,6 +213,13 @@ public class EnvironmentTests extends ESTestCase { final String sharedDataPath = Environment.PATH_SHARED_DATA_SETTING.get(environment.settings()); assertPath(sharedDataPath, home.resolve("shared_data")); + + final String pidFile = pidFileSetting.get(environment.settings()); + assertPath(pidFile, home.resolve("pidfile")); + + if (pidFileSetting.isDeprecated()) { + assertSettingDeprecationsAndWarnings(new Setting[] { pidFileSetting }); + } } private void assertPath(final String actual, final Path expected) {