Skip to content

Commit fdc0601

Browse files
authored
Deprecate shared and index data path settings (#73178) (#73198)
This commit adds deprecation warnings for use of the path.shared_data setting as well as the index setting index.data_path. relates #73168
1 parent b4ff4d0 commit fdc0601

File tree

11 files changed

+83
-8
lines changed

11 files changed

+83
-8
lines changed

buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,6 @@ private void createConfiguration() {
12211221
baseConfig.put("path.repo", confPathRepo.toAbsolutePath().toString());
12221222
baseConfig.put("path.data", confPathData.toAbsolutePath().toString());
12231223
baseConfig.put("path.logs", confPathLogs.toAbsolutePath().toString());
1224-
baseConfig.put("path.shared_data", workingDir.resolve("sharedData").toString());
12251224
baseConfig.put("node.attr.testattr", "test");
12261225
baseConfig.put("node.portsfile", "true");
12271226
baseConfig.put("http.port", httpPort);

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/node/Node.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,15 @@ protected Node(final Environment initialEnvironment,
325325
"version [{}] is a pre-release version of Elasticsearch and is not suitable for production",
326326
Build.CURRENT.getQualifiedVersion());
327327
}
328+
if (Environment.PATH_SHARED_DATA_SETTING.exists(tmpSettings)) {
329+
// NOTE: this must be done with an explicit check here because the deprecation property on a path setting will
330+
// cause ES to fail to start since logging is not yet initialized on first read of the setting
331+
deprecationLogger.deprecate(
332+
DeprecationCategory.SETTINGS,
333+
"shared-data-path",
334+
"setting [path.shared_data] is deprecated and will be removed in a future release"
335+
);
336+
}
328337

329338
if (initialEnvironment.dataFiles().length > 1) {
330339
// NOTE: we use initialEnvironment here, but assertEquivalent below ensures the data paths do not change

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,5 +260,4 @@ private void assertIsAbsolute(final String path) {
260260
private void assertIsNormalized(final String path) {
261261
assertThat("path [" + path + "] is not normalized", PathUtils.get(path), equalTo(PathUtils.get(path).normalize()));
262262
}
263-
264263
}

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

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

3333
import static org.hamcrest.CoreMatchers.equalTo;
34+
import static org.hamcrest.Matchers.is;
3435
import static org.hamcrest.core.StringContains.containsString;
3536
import static org.hamcrest.object.HasToString.hasToString;
3637

@@ -629,4 +630,14 @@ public void testUpdateTranslogRetentionSettingsWithSoftDeletesDisabled() {
629630
assertThat(indexSettings.getTranslogRetentionAge(), equalTo(ageSetting));
630631
assertThat(indexSettings.getTranslogRetentionSize(), equalTo(sizeSetting));
631632
}
633+
634+
public void testCustomDataPathDeprecated() {
635+
final Settings settings = Settings.builder()
636+
.put(IndexMetadata.INDEX_DATA_PATH_SETTING.getKey(), "my-custom-dir")
637+
.build();
638+
IndexMetadata metadata = newIndexMeta("test", settings);
639+
IndexSettings indexSettings = new IndexSettings(metadata, Settings.EMPTY);
640+
assertThat(indexSettings.hasCustomDataPath(), is(true));
641+
assertSettingDeprecationsAndWarnings(new Setting[] { IndexMetadata.INDEX_DATA_PATH_SETTING });
642+
}
632643
}

test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,8 @@ public Settings indexSettings() {
727727
if (numberOfReplicas >= 0) {
728728
builder.put(SETTING_NUMBER_OF_REPLICAS, numberOfReplicas).build();
729729
}
730-
// 30% of the time
731-
if (randomInt(9) < 3) {
730+
// 30% of the time, for non-external clusters
731+
if (cluster() instanceof ExternalTestCluster == false && randomInt(9) < 3) {
732732
final String dataPath = randomAlphaOfLength(10);
733733
logger.info("using custom data_path for index: [{}]", dataPath);
734734
builder.put(IndexMetadata.SETTING_DATA_PATH, dataPath);

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ private DeprecationChecks() {
8585
XPackSettings.VECTORS_ENABLED),
8686
NodeDeprecationChecks::checkMultipleDataPaths,
8787
NodeDeprecationChecks::checkDataPathsList,
88-
NodeDeprecationChecks::checkBootstrapSystemCallFilterSetting
88+
NodeDeprecationChecks::checkBootstrapSystemCallFilterSetting,
89+
NodeDeprecationChecks::checkSharedDataPathSetting
8990
)
9091
).collect(Collectors.toList());
9192
}
@@ -97,10 +98,10 @@ private DeprecationChecks() {
9798
IndexDeprecationChecks::chainedMultiFieldsCheck,
9899
IndexDeprecationChecks::deprecatedDateTimeFormat,
99100
IndexDeprecationChecks::translogRetentionSettingCheck,
100-
IndexDeprecationChecks::fieldNamesDisabledCheck
101+
IndexDeprecationChecks::fieldNamesDisabledCheck,
102+
IndexDeprecationChecks::checkIndexDataPath
101103
));
102104

103-
104105
/**
105106
* helper utility function to reduce repeat of running a specific {@link List} of checks.
106107
*
@@ -112,4 +113,5 @@ private DeprecationChecks() {
112113
static <T> List<DeprecationIssue> filterChecks(List<T> checks, Function<T, DeprecationIssue> mapper) {
113114
return checks.stream().map(mapper).filter(Objects::nonNull).collect(Collectors.toList());
114115
}
116+
115117
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Collections;
2121
import java.util.HashSet;
2222
import java.util.List;
23+
import java.util.Locale;
2324
import java.util.Map;
2425
import java.util.Set;
2526
import java.util.concurrent.atomic.AtomicInteger;
@@ -263,4 +264,16 @@ static DeprecationIssue translogRetentionSettingCheck(IndexMetadata indexMetadat
263264
}
264265
return null;
265266
}
267+
268+
static DeprecationIssue checkIndexDataPath(IndexMetadata indexMetadata) {
269+
if (IndexMetadata.INDEX_DATA_PATH_SETTING.exists(indexMetadata.getSettings())) {
270+
final String message = String.format(Locale.ROOT,
271+
"setting [%s] is deprecated and will be removed in a future version", IndexMetadata.INDEX_DATA_PATH_SETTING.getKey());
272+
final String url = "https://www.elastic.co/guide/en/elasticsearch/reference/7.13/" +
273+
"breaking-changes-7.13.html#deprecate-shared-data-path-setting";
274+
final String details = "Found index data path configured. Discontinue use of this setting.";
275+
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details);
276+
}
277+
return null;
278+
}
266279
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,4 +409,15 @@ static DeprecationIssue checkDataPathsList(Settings nodeSettings, PluginsAndModu
409409
return null;
410410
}
411411

412+
static DeprecationIssue checkSharedDataPathSetting(final Settings settings, final PluginsAndModules pluginsAndModules) {
413+
if (Environment.PATH_SHARED_DATA_SETTING.exists(settings)) {
414+
final String message = String.format(Locale.ROOT,
415+
"setting [%s] is deprecated and will be removed in a future version", Environment.PATH_SHARED_DATA_SETTING.getKey());
416+
final String url = "https://www.elastic.co/guide/en/elasticsearch/reference/7.13/" +
417+
"breaking-changes-7.13.html#deprecate-shared-data-path-setting";
418+
final String details = "Found shared data path configured. Discontinue use of this setting.";
419+
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details);
420+
}
421+
return null;
422+
}
412423
}

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
@@ -441,4 +441,19 @@ public void testFieldNamesEnabling() throws IOException {
441441
assertEquals("The index mapping contains a deprecated `enabled` setting for `_field_names` that should be removed moving foward.",
442442
issue.getDetails());
443443
}
444+
445+
public void testIndexDataPathSetting() {
446+
Settings.Builder settings = settings(Version.CURRENT);
447+
settings.put(IndexMetadata.INDEX_DATA_PATH_SETTING.getKey(), createTempDir());
448+
IndexMetadata indexMetadata = IndexMetadata.builder("test").settings(settings).numberOfShards(1).numberOfReplicas(0).build();
449+
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(indexMetadata));
450+
final String expectedUrl =
451+
"https://www.elastic.co/guide/en/elasticsearch/reference/7.13/breaking-changes-7.13.html#deprecate-shared-data-path-setting";
452+
assertThat(issues, contains(
453+
new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
454+
"setting [index.data_path] is deprecated and will be removed in a future version",
455+
expectedUrl,
456+
"Found index data path configured. Discontinue use of this setting."
457+
)));
458+
}
444459
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,4 +574,20 @@ public void testNoDataPathsListDefault() {
574574
final DeprecationIssue issue = NodeDeprecationChecks.checkDataPathsList(settings, null);
575575
assertThat(issue, nullValue());
576576
}
577+
578+
public void testSharedDataPathSetting() {
579+
Settings settings = Settings.builder()
580+
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
581+
.put(Environment.PATH_SHARED_DATA_SETTING.getKey(), createTempDir()).build();
582+
583+
DeprecationIssue issue = NodeDeprecationChecks.checkSharedDataPathSetting(settings, null);
584+
final String expectedUrl =
585+
"https://www.elastic.co/guide/en/elasticsearch/reference/7.13/breaking-changes-7.13.html#deprecate-shared-data-path-setting";
586+
assertThat(issue, equalTo(
587+
new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
588+
"setting [path.shared_data] is deprecated and will be removed in a future version",
589+
expectedUrl,
590+
"Found shared data path configured. Discontinue use of this setting."
591+
)));
592+
}
577593
}

0 commit comments

Comments
 (0)