Skip to content

Commit 93dfbe9

Browse files
committed
Deprecate shared and index data path settings
This commit adds deprecation warnings for use of the path.shared_data setting as well as the index setting index.data_path. relates elastic#73168
1 parent 4268c76 commit 93dfbe9

File tree

10 files changed

+114
-6
lines changed

10 files changed

+114
-6
lines changed

docs/reference/migration/migrate_8_0/settings.asciidoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,18 @@ was deprecated in Elasticsearch 7.13.0, and is removed as of Elasticsearch
242242
Discontinue use of the removed setting. Specifying this setting in Elasticsearch
243243
configuration will result in an error on startup.
244244
====
245+
246+
[[shared-data-path-setting]]
247+
.Shared data path and per index data path settings deprecated
248+
[%collapsible]
249+
====
250+
*Details* +
251+
Elasticsearch uses the shared data path as the base path of per index data
252+
paths. This feature was previously used with shared replicas. Starting in
253+
7.13.0, these settings are deprecated. Starting in 8.0 only existing
254+
indices created in 7.x will be capable of using the shared data path and
255+
per index data path settings.
256+
257+
*Impact* +
258+
Discontinue use of the deprecated settings.
259+
====

server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public static APIBlock readFrom(StreamInput input) throws IOException {
282282
public static final String SETTING_HISTORY_UUID = "index.history.uuid";
283283
public static final String SETTING_DATA_PATH = "index.data_path";
284284
public static final Setting<String> INDEX_DATA_PATH_SETTING =
285-
new Setting<>(SETTING_DATA_PATH, "", Function.identity(), Property.IndexScope);
285+
new Setting<>(SETTING_DATA_PATH, "", Function.identity(), Property.IndexScope, Property.Deprecated);
286286
public static final String INDEX_UUID_NA_VALUE = "_na_";
287287

288288
public static final String INDEX_ROUTING_REQUIRE_GROUP_PREFIX = "index.routing.allocation.require";

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public class Environment {
4646
new Setting<>("path.logs", "", Function.identity(), Property.NodeScope);
4747
public static final Setting<List<String>> PATH_REPO_SETTING =
4848
Setting.listSetting("path.repo", Collections.emptyList(), Function.identity(), Property.NodeScope);
49-
public static final Setting<String> PATH_SHARED_DATA_SETTING = Setting.simpleString("path.shared_data", Property.NodeScope);
49+
public static final Setting<String> PATH_SHARED_DATA_SETTING = Setting.simpleString("path.shared_data",
50+
Property.NodeScope, Property.Deprecated);
5051
public static final Setting<String> NODE_PIDFILE_SETTING = Setting.simpleString("node.pidfile", Property.NodeScope);
5152

5253
private final Settings settings;

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package org.elasticsearch.env;
99

1010
import org.elasticsearch.common.io.PathUtils;
11+
import org.elasticsearch.common.settings.Setting;
1112
import org.elasticsearch.common.settings.Settings;
1213
import org.elasticsearch.test.ESTestCase;
1314

@@ -17,6 +18,7 @@
1718
import java.nio.file.Path;
1819
import java.util.List;
1920

21+
import static org.elasticsearch.common.inject.matcher.Matchers.not;
2022
import static org.hamcrest.CoreMatchers.endsWith;
2123
import static org.hamcrest.CoreMatchers.notNullValue;
2224
import static org.hamcrest.CoreMatchers.nullValue;
@@ -191,6 +193,15 @@ public void testSingleDataPathListCheck() {
191193
}
192194
}
193195

196+
public void testSharedDataPathDeprecation() {
197+
final Settings settings = Settings.builder()
198+
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
199+
.put(Environment.PATH_SHARED_DATA_SETTING.getKey(), createTempDir()).build();
200+
Environment env = new Environment(settings, null);
201+
assertThat(env.sharedDataFile(), notNullValue());
202+
assertSettingDeprecationsAndWarnings(new Setting[] { Environment.PATH_SHARED_DATA_SETTING });
203+
}
204+
194205
private void assertPath(final String actual, final Path expected) {
195206
assertIsAbsolute(actual);
196207
assertIsNormalized(actual);
@@ -204,5 +215,4 @@ private void assertIsAbsolute(final String path) {
204215
private void assertIsNormalized(final String path) {
205216
assertThat("path [" + path + "] is not normalized", PathUtils.get(path), equalTo(PathUtils.get(path).normalize()));
206217
}
207-
208218
}

server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.function.Function;
3131

3232
import static org.hamcrest.CoreMatchers.equalTo;
33+
import static org.hamcrest.Matchers.is;
3334
import static org.hamcrest.core.StringContains.containsString;
3435
import static org.hamcrest.object.HasToString.hasToString;
3536

@@ -534,4 +535,14 @@ public void testSoftDeletesDefaultSetting() {
534535
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, createdVersion).build();
535536
assertTrue(IndexSettings.INDEX_SOFT_DELETES_SETTING.get(settings));
536537
}
538+
539+
public void testCustomDataPathDeprecated() {
540+
final Settings settings = Settings.builder()
541+
.put(IndexMetadata.INDEX_DATA_PATH_SETTING.getKey(), "my-custom-dir")
542+
.build();
543+
IndexMetadata metadata = newIndexMeta("test", settings);
544+
IndexSettings indexSettings = new IndexSettings(metadata, Settings.EMPTY);
545+
assertThat(indexSettings.hasCustomDataPath(), is(true));
546+
assertSettingDeprecationsAndWarnings(new Setting[] { IndexMetadata.INDEX_DATA_PATH_SETTING });
547+
}
537548
}

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@ private DeprecationChecks() {
3232
static List<Function<ClusterState, DeprecationIssue>> CLUSTER_SETTINGS_CHECKS =
3333
Collections.emptyList();
3434

35-
static List<BiFunction<Settings, PluginsAndModules, DeprecationIssue>> NODE_SETTINGS_CHECKS = List.of();
35+
static List<BiFunction<Settings, PluginsAndModules, DeprecationIssue>> NODE_SETTINGS_CHECKS = List.of(
36+
NodeDeprecationChecks::checkSharedDataPathSetting
37+
);
3638

37-
static List<Function<IndexMetadata, DeprecationIssue>> INDEX_SETTINGS_CHECKS =
38-
List.of(IndexDeprecationChecks::oldIndicesCheck, IndexDeprecationChecks::translogRetentionSettingCheck);
39+
static List<Function<IndexMetadata, DeprecationIssue>> INDEX_SETTINGS_CHECKS = List.of(
40+
IndexDeprecationChecks::oldIndicesCheck,
41+
IndexDeprecationChecks::translogRetentionSettingCheck,
42+
IndexDeprecationChecks::checkIndexDataPath
43+
);
3944

4045
/**
4146
* helper utility function to reduce repeat of running a specific {@link List} of checks.
@@ -48,4 +53,5 @@ private DeprecationChecks() {
4853
static <T> List<DeprecationIssue> filterChecks(List<T> checks, Function<T, DeprecationIssue> mapper) {
4954
return checks.stream().map(mapper).filter(Objects::nonNull).collect(Collectors.toList());
5055
}
56+
5157
}

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
import org.elasticsearch.Version;
1111
import org.elasticsearch.cluster.metadata.IndexMetadata;
1212
import org.elasticsearch.cluster.metadata.MappingMetadata;
13+
import org.elasticsearch.env.Environment;
1314
import org.elasticsearch.index.IndexSettings;
1415
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
1516

17+
import java.util.Locale;
1618
import java.util.Map;
1719
import java.util.function.BiConsumer;
1820

@@ -55,4 +57,16 @@ static DeprecationIssue translogRetentionSettingCheck(IndexMetadata indexMetadat
5557
}
5658
return null;
5759
}
60+
61+
static DeprecationIssue checkIndexDataPath(IndexMetadata indexMetadata) {
62+
if (IndexMetadata.INDEX_DATA_PATH_SETTING.exists(indexMetadata.getSettings())) {
63+
final String message = String.format(Locale.ROOT,
64+
"setting [%s] is deprecated and will be removed in a future version", IndexMetadata.INDEX_DATA_PATH_SETTING.getKey());
65+
final String url =
66+
"https://www.elastic.co/guide/en/elasticsearch/reference/7.13/breaking-changes-7.13.html#deprecate-shared-data-path-setting";
67+
final String details = "Found index data path configured. Discontinue use of this setting.";
68+
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details);
69+
}
70+
return null;
71+
}
5872
}

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
package org.elasticsearch.xpack.deprecation;
99

1010
import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules;
11+
import org.elasticsearch.bootstrap.BootstrapSettings;
1112
import org.elasticsearch.common.settings.Setting;
1213
import org.elasticsearch.common.settings.Settings;
14+
import org.elasticsearch.env.Environment;
1315
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
1416

1517
import java.util.Locale;
@@ -113,4 +115,15 @@ static DeprecationIssue checkRemovedSetting(final Settings settings, final Setti
113115
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details);
114116
}
115117

118+
static DeprecationIssue checkSharedDataPathSetting(final Settings settings, final PluginsAndModules pluginsAndModules) {
119+
if (Environment.PATH_SHARED_DATA_SETTING.exists(settings)) {
120+
final String message = String.format(Locale.ROOT,
121+
"setting [%s] is deprecated and will be removed in a future version", Environment.PATH_SHARED_DATA_SETTING.getKey());
122+
final String url =
123+
"https://www.elastic.co/guide/en/elasticsearch/reference/7.13/breaking-changes-7.13.html#deprecate-shared-data-path-setting";
124+
final String details = "Found shared data path configured. Discontinue use of this setting.";
125+
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details);
126+
}
127+
return null;
128+
}
116129
}

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,19 @@ public void testDefaultTranslogRetentionSettings() {
6464
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(indexMetadata));
6565
assertThat(issues, empty());
6666
}
67+
68+
public void testIndexDataPathSetting() {
69+
Settings.Builder settings = settings(Version.CURRENT);
70+
settings.put(IndexMetadata.INDEX_DATA_PATH_SETTING.getKey(), createTempDir());
71+
IndexMetadata indexMetadata = IndexMetadata.builder("test").settings(settings).numberOfShards(1).numberOfReplicas(0).build();
72+
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(indexMetadata));
73+
final String expectedUrl =
74+
"https://www.elastic.co/guide/en/elasticsearch/reference/7.13/breaking-changes-7.13.html#deprecate-shared-data-path-setting";
75+
assertThat(issues, contains(
76+
new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
77+
"setting [index.data_path] is deprecated and will be removed in a future version",
78+
expectedUrl,
79+
"Found index data path configured. Discontinue use of this setting."
80+
)));
81+
}
6782
}

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@
77

88
package org.elasticsearch.xpack.deprecation;
99

10+
import org.elasticsearch.Version;
11+
import org.elasticsearch.cluster.metadata.IndexMetadata;
1012
import org.elasticsearch.common.settings.Setting;
1113
import org.elasticsearch.common.settings.Settings;
14+
import org.elasticsearch.env.Environment;
1215
import org.elasticsearch.test.ESTestCase;
1316
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
1417

18+
import java.util.List;
19+
20+
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.INDEX_SETTINGS_CHECKS;
21+
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.NODE_SETTINGS_CHECKS;
1522
import static org.hamcrest.Matchers.equalTo;
1623
import static org.hamcrest.Matchers.not;
1724
import static org.hamcrest.Matchers.nullValue;
25+
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
1826

1927
public class NodeDeprecationChecksTests extends ESTestCase {
2028

@@ -42,4 +50,19 @@ public void testRemovedSetting() {
4250
assertThat(issue.getUrl(), equalTo("https://removed-setting.example.com"));
4351
}
4452

53+
public void testSharedDataPathSetting() {
54+
Settings settings = Settings.builder()
55+
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
56+
.put(Environment.PATH_SHARED_DATA_SETTING.getKey(), createTempDir()).build();
57+
58+
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(NODE_SETTINGS_CHECKS, c -> c.apply(settings, null));
59+
final String expectedUrl =
60+
"https://www.elastic.co/guide/en/elasticsearch/reference/7.13/breaking-changes-7.13.html#deprecate-shared-data-path-setting";
61+
assertThat(issues, contains(
62+
new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
63+
"setting [path.shared_data] is deprecated and will be removed in a future version",
64+
expectedUrl,
65+
"Found shared data path configured. Discontinue use of this setting."
66+
)));
67+
}
4568
}

0 commit comments

Comments
 (0)