Skip to content

Commit 599bf2d

Browse files
committed
Deprecate the pidfile setting (#45938)
This commit deprecates the pidfile setting in favor of node.pidfile.
1 parent 43ca652 commit 599bf2d

File tree

8 files changed

+36
-9
lines changed

8 files changed

+36
-9
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ class ClusterFormationTasks {
387387
Map esConfig = [
388388
'cluster.name' : node.clusterName,
389389
'node.name' : "node-" + node.nodeNum,
390-
'pidfile' : node.pidFile,
390+
(node.nodeVersion.onOrAfter('7.4.0') ? 'node.pidfile' : 'pidfile') : node.pidFile,
391391
'path.repo' : "${node.sharedDir}/repo",
392392
'path.shared_data' : "${node.sharedDir}/",
393393
// Define a node attribute so we can test that it exists

dev-tools/smoke_test_rc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def smoke_test_release(release, files, hash, plugins):
200200
headers = {}
201201
print(' Starting elasticsearch deamon from [%s]' % es_dir)
202202
try:
203-
run('%s; %s -Enode.name=smoke_tester -Ecluster.name=prepare_release -Erepositories.url.allowed_urls=http://snapshot.test* %s -Epidfile=%s -Enode.portsfile=true'
203+
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'
204204
% (java_exe(), es_run_path, '-d', os.path.join(es_dir, 'es-smoke.pid')))
205205
if not wait_for_node_startup(es_dir, header=headers):
206206
print("elasticsearch logs:")

docs/reference/migration/migrate_7_4.asciidoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ be disabled by setting the system property
119119
[[breaking_74_settings_changes]]
120120
=== Settings changes
121121

122+
[discrete]
123+
[[deprecate-pidfile]]
124+
==== `pidfile` setting is being replaced by `node.pidfile`
125+
126+
To ensure that all settings are in a proper namespace, the `pidfile` setting is
127+
deprecated, and will be removed in version 8.0.0. Instead, use `node.pidfile`.
128+
122129
[discrete]
123130
[[deprecate-processors]]
124131
==== `processors` setting is being replaced by `node.processors`

qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilSecurityTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void testEnvironmentPaths() throws Exception {
8585
esHome.resolve("data2").toString());
8686
settingsBuilder.put(Environment.PATH_SHARED_DATA_SETTING.getKey(), esHome.resolve("custom").toString());
8787
settingsBuilder.put(Environment.PATH_LOGS_SETTING.getKey(), esHome.resolve("logs").toString());
88-
settingsBuilder.put(Environment.PIDFILE_SETTING.getKey(), esHome.resolve("test.pid").toString());
88+
settingsBuilder.put(Environment.NODE_PIDFILE_SETTING.getKey(), esHome.resolve("test.pid").toString());
8989
Settings settings = settingsBuilder.build();
9090

9191
Path fakeTmpDir = createTempDir();

server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ private static Environment createEnvironment(
258258
final Path configPath) {
259259
Settings.Builder builder = Settings.builder();
260260
if (pidFile != null) {
261-
builder.put(Environment.PIDFILE_SETTING.getKey(), pidFile);
261+
builder.put(Environment.NODE_PIDFILE_SETTING.getKey(), pidFile);
262262
}
263263
builder.put(initialSettings);
264264
if (secureSettings != null) {

server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ public void apply(Settings value, Settings current, Settings previous) {
402402
Environment.PATH_REPO_SETTING,
403403
Environment.PATH_SHARED_DATA_SETTING,
404404
Environment.PIDFILE_SETTING,
405+
Environment.NODE_PIDFILE_SETTING,
405406
NodeEnvironment.NODE_ID_SEED_SETTING,
406407
DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING,
407408
DiscoveryModule.DISCOVERY_TYPE_SETTING,

server/src/main/java/org/elasticsearch/env/Environment.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public class Environment {
6060
public static final Setting<List<String>> PATH_REPO_SETTING =
6161
Setting.listSetting("path.repo", Collections.emptyList(), Function.identity(), Property.NodeScope);
6262
public static final Setting<String> PATH_SHARED_DATA_SETTING = Setting.simpleString("path.shared_data", Property.NodeScope);
63-
public static final Setting<String> PIDFILE_SETTING = Setting.simpleString("pidfile", Property.NodeScope);
63+
public static final Setting<String> PIDFILE_SETTING = Setting.simpleString("pidfile", Property.Deprecated, Property.NodeScope);
64+
public static final Setting<String> NODE_PIDFILE_SETTING = Setting.simpleString("node.pidfile", PIDFILE_SETTING, Property.NodeScope);
6465

6566
private final Settings settings;
6667

@@ -154,8 +155,8 @@ public Environment(final Settings settings, final Path configPath) {
154155
logsFile = homeFile.resolve("logs");
155156
}
156157

157-
if (PIDFILE_SETTING.exists(settings)) {
158-
pidFile = PathUtils.get(PIDFILE_SETTING.get(settings)).toAbsolutePath().normalize();
158+
if (NODE_PIDFILE_SETTING.exists(settings) || PIDFILE_SETTING.exists(settings)) {
159+
pidFile = PathUtils.get(NODE_PIDFILE_SETTING.get(settings)).toAbsolutePath().normalize();
159160
} else {
160161
pidFile = null;
161162
}
@@ -179,7 +180,10 @@ public Environment(final Settings settings, final Path configPath) {
179180
assert sharedDataFile != null;
180181
finalSettings.put(Environment.PATH_SHARED_DATA_SETTING.getKey(), sharedDataFile.toString());
181182
}
182-
if (PIDFILE_SETTING.exists(settings)) {
183+
if (NODE_PIDFILE_SETTING.exists(settings)) {
184+
assert pidFile != null;
185+
finalSettings.put(Environment.NODE_PIDFILE_SETTING.getKey(), pidFile.toString());
186+
} else if (PIDFILE_SETTING.exists(settings)) {
183187
assert pidFile != null;
184188
finalSettings.put(Environment.PIDFILE_SETTING.getKey(), pidFile.toString());
185189
}

server/src/test/java/org/elasticsearch/env/EnvironmentTests.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.elasticsearch.env;
2020

2121
import org.elasticsearch.common.io.PathUtils;
22+
import org.elasticsearch.common.settings.Setting;
2223
import org.elasticsearch.common.settings.Settings;
2324
import org.elasticsearch.test.ESTestCase;
2425

@@ -174,13 +175,20 @@ public void testTempPathValidationWhenRegularFile() throws IOException {
174175

175176
// test that environment paths are absolute and normalized
176177
public void testPathNormalization() throws IOException {
178+
final Setting<String> pidFileSetting;
179+
if (randomBoolean()) {
180+
pidFileSetting = Environment.NODE_PIDFILE_SETTING;
181+
} else {
182+
pidFileSetting = Environment.PIDFILE_SETTING;
183+
}
184+
177185
final Settings settings = Settings.builder()
178186
.put(Environment.PATH_HOME_SETTING.getKey(), "home")
179187
.put(Environment.PATH_DATA_SETTING.getKey(), "./home/../home/data")
180188
.put(Environment.PATH_LOGS_SETTING.getKey(), "./home/../home/logs")
181189
.put(Environment.PATH_REPO_SETTING.getKey(), "./home/../home/repo")
182190
.put(Environment.PATH_SHARED_DATA_SETTING.getKey(), "./home/../home/shared_data")
183-
.put(Environment.PIDFILE_SETTING.getKey(), "./home/../home/pidfile")
191+
.put(pidFileSetting.getKey(), "./home/../home/pidfile")
184192
.build();
185193

186194
// the above paths will be treated as relative to the working directory
@@ -205,6 +213,13 @@ public void testPathNormalization() throws IOException {
205213

206214
final String sharedDataPath = Environment.PATH_SHARED_DATA_SETTING.get(environment.settings());
207215
assertPath(sharedDataPath, home.resolve("shared_data"));
216+
217+
final String pidFile = pidFileSetting.get(environment.settings());
218+
assertPath(pidFile, home.resolve("pidfile"));
219+
220+
if (pidFileSetting.isDeprecated()) {
221+
assertSettingDeprecationsAndWarnings(new Setting<?>[] { pidFileSetting });
222+
}
208223
}
209224

210225
private void assertPath(final String actual, final Path expected) {

0 commit comments

Comments
 (0)