Skip to content

Commit d977e96

Browse files
committed
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 018ac3b commit d977e96

File tree

11 files changed

+82
-7
lines changed

11 files changed

+82
-7
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
@@ -1222,7 +1222,6 @@ private void createConfiguration() {
12221222
baseConfig.put("path.repo", confPathRepo.toAbsolutePath().toString());
12231223
baseConfig.put("path.data", confPathData.toAbsolutePath().toString());
12241224
baseConfig.put("path.logs", confPathLogs.toAbsolutePath().toString());
1225-
baseConfig.put("path.shared_data", workingDir.resolve("sharedData").toString());
12261225
baseConfig.put("node.attr.testattr", "test");
12271226
baseConfig.put("node.portsfile", "true");
12281227
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
@@ -211,5 +211,4 @@ private void assertIsAbsolute(final String path) {
211211
private void assertIsNormalized(final String path) {
212212
assertThat("path [" + path + "] is not normalized", PathUtils.get(path), equalTo(PathUtils.get(path).normalize()));
213213
}
214-
215214
}

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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ private DeprecationChecks() {
8383
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
8484
XPackSettings.VECTORS_ENABLED),
8585
NodeDeprecationChecks::checkMultipleDataPaths,
86-
NodeDeprecationChecks::checkBootstrapSystemCallFilterSetting
86+
NodeDeprecationChecks::checkBootstrapSystemCallFilterSetting,
87+
NodeDeprecationChecks::checkSharedDataPathSetting
8788
)
8889
).collect(Collectors.toList());
8990
}
@@ -95,7 +96,8 @@ private DeprecationChecks() {
9596
IndexDeprecationChecks::chainedMultiFieldsCheck,
9697
IndexDeprecationChecks::deprecatedDateTimeFormat,
9798
IndexDeprecationChecks::translogRetentionSettingCheck,
98-
IndexDeprecationChecks::fieldNamesDisabledCheck
99+
IndexDeprecationChecks::fieldNamesDisabledCheck,
100+
IndexDeprecationChecks::checkIndexDataPath
99101
));
100102

101103

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
@@ -399,4 +399,15 @@ static DeprecationIssue checkMultipleDataPaths(Settings nodeSettings, PluginsAnd
399399
return null;
400400
}
401401

402+
static DeprecationIssue checkSharedDataPathSetting(final Settings settings, final PluginsAndModules pluginsAndModules) {
403+
if (Environment.PATH_SHARED_DATA_SETTING.exists(settings)) {
404+
final String message = String.format(Locale.ROOT,
405+
"setting [%s] is deprecated and will be removed in a future version", Environment.PATH_SHARED_DATA_SETTING.getKey());
406+
final String url = "https://www.elastic.co/guide/en/elasticsearch/reference/7.13/" +
407+
"breaking-changes-7.13.html#deprecate-shared-data-path-setting";
408+
final String details = "Found shared data path configured. Discontinue use of this setting.";
409+
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details);
410+
}
411+
return null;
412+
}
402413
}

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
@@ -552,4 +552,20 @@ public void testNoMultipleDataPaths() {
552552
final DeprecationIssue issue = NodeDeprecationChecks.checkMultipleDataPaths(settings, null);
553553
assertThat(issue, nullValue());
554554
}
555+
556+
public void testSharedDataPathSetting() {
557+
Settings settings = Settings.builder()
558+
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
559+
.put(Environment.PATH_SHARED_DATA_SETTING.getKey(), createTempDir()).build();
560+
561+
DeprecationIssue issue = NodeDeprecationChecks.checkSharedDataPathSetting(settings, null);
562+
final String expectedUrl =
563+
"https://www.elastic.co/guide/en/elasticsearch/reference/7.13/breaking-changes-7.13.html#deprecate-shared-data-path-setting";
564+
assertThat(issue, equalTo(
565+
new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
566+
"setting [path.shared_data] is deprecated and will be removed in a future version",
567+
expectedUrl,
568+
"Found shared data path configured. Discontinue use of this setting."
569+
)));
570+
}
555571
}

0 commit comments

Comments
 (0)