Skip to content

Commit

Permalink
Deprecate multiple path.data entries (elastic#71207)
Browse files Browse the repository at this point in the history
This commit adds a node level deprecation log message when multiple
data paths are specified.

relates elastic#71205
  • Loading branch information
rjernst committed Apr 2, 2021
1 parent 8d0149e commit b4b127d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 23 deletions.
7 changes: 7 additions & 0 deletions server/src/main/java/org/elasticsearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ protected Node(final Environment initialEnvironment,
Build.CURRENT.getQualifiedVersion());
}

if (initialEnvironment.dataFiles().length > 1) {
// NOTE: we use initialEnvironment here, but assertEquivalent below ensures the data paths do not change
deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "multiple-data-paths",
"Configuring multiple [path.data] paths is deprecated. Use RAID or other system level features for utilizing " +
"multiple disks. This feature will be removed in 8.0.");
}

if (logger.isDebugEnabled()) {
logger.debug("using config [{}], data [{}], logs [{}], plugins [{}]",
initialEnvironment.configFile(), Arrays.toString(initialEnvironment.dataFiles()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING;
import static org.elasticsearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING;
Expand Down Expand Up @@ -103,6 +104,13 @@ public final void startClusters() throws Exception {
configureAndConnectsToRemoteClusters();
}

@Override
public List<String> filteredWarnings() {
return Stream.concat(super.filteredWarnings().stream(),
Stream.of("Configuring multiple [path.data] paths is deprecated. Use RAID or other system level features for utilizing " +
"multiple disks. This feature will be removed in 8.0.")).collect(Collectors.toList());
}

@After
public void assertAfterTest() throws Exception {
for (InternalTestCluster cluster : clusters().values()) {
Expand Down
43 changes: 20 additions & 23 deletions test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,19 +411,11 @@ private void ensureNoWarnings() {
try {
final List<String> warnings = threadContext.getResponseHeaders().get("Warning");
if (warnings != null) {
List<String> filteredWarnings = new ArrayList<>(warnings);
if (enableJodaDeprecationWarningsCheck() == false) {
filteredWarnings = filterJodaDeprecationWarnings(filteredWarnings);
}
if (JvmInfo.jvmInfo().getBundledJdk() == false) {
// unit tests do not run with the bundled JDK, if there are warnings we need to filter the no-jdk deprecation warning
filteredWarnings = filteredWarnings
.stream()
.filter(k -> k.contains(
"no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release"
) == false)
.collect(Collectors.toList());
}
// unit tests do not run with the bundled JDK, if there are warnings we need to filter the no-jdk deprecation warning
final List<String> filteredWarnings = warnings
.stream()
.filter(k -> filteredWarnings().stream().anyMatch(s -> s.contains(k)))
.collect(Collectors.toList());
assertThat("unexpected warning headers", filteredWarnings, empty());
} else {
assertNull("unexpected warning headers", warnings);
Expand All @@ -433,6 +425,17 @@ private void ensureNoWarnings() {
}
}

protected List<String> filteredWarnings() {
List<String> filtered = new ArrayList<>();
if (enableJodaDeprecationWarningsCheck()) {
filtered.add(JodaDeprecationPatterns.USE_NEW_FORMAT_SPECIFIERS);
}
if (JvmInfo.jvmInfo().getBundledJdk() == false) {
filtered.add("no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release");
}
return filtered;
}

/**
* Convenience method to assert warnings for settings deprecations and general deprecation warnings.
*
Expand Down Expand Up @@ -490,12 +493,12 @@ protected final void assertWarnings(boolean stripXContentPosition, String... exp
throw new IllegalStateException("unable to check warning headers if the test is not set to do so");
}
try {
final List<String> actualWarnings = threadContext.getResponseHeaders().get("Warning");

final List<String> actualWarnings = threadContext.getResponseHeaders().get("Warning").stream()
.filter(k -> filteredWarnings().stream().anyMatch(s -> s.contains(k)))
.collect(Collectors.toList());
if ((expectedWarnings == null || expectedWarnings.length == 0)) {
assertNull("expected 0 warnings, actual: " + actualWarnings, actualWarnings);
} else if (actualWarnings != null && enableJodaDeprecationWarningsCheck() == false) {
List<String> filteredWarnings = filterJodaDeprecationWarnings(actualWarnings);
assertWarnings(stripXContentPosition, filteredWarnings, expectedWarnings);
} else {
assertWarnings(stripXContentPosition, actualWarnings, expectedWarnings);
}
Expand All @@ -504,12 +507,6 @@ protected final void assertWarnings(boolean stripXContentPosition, String... exp
}
}

private List<String> filterJodaDeprecationWarnings(List<String> actualWarnings) {
return actualWarnings.stream()
.filter(m -> m.contains(JodaDeprecationPatterns.USE_NEW_FORMAT_SPECIFIERS) == false)
.collect(Collectors.toList());
}

private void assertWarnings(boolean stripXContentPosition, List<String> actualWarnings, String[] expectedWarnings) {
assertNotNull("no warnings, expected: " + Arrays.asList(expectedWarnings), actualWarnings);
final Set<String> actualWarningValues =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFileExists;
Expand All @@ -60,6 +61,13 @@ private static Collection<Class<? extends Plugin>> mockPlugins() {
return Arrays.asList(getTestTransportPlugin(), MockHttpTransport.TestPlugin.class);
}

@Override
protected List<String> filteredWarnings() {
return Stream.concat(super.filteredWarnings().stream(),
Stream.of("Configuring multiple [path.data] paths is deprecated. Use RAID or other system level features for utilizing " +
"multiple disks. This feature will be removed in 8.0.")).collect(Collectors.toList());
}

public void testInitializiationIsConsistent() {
long clusterSeed = randomLong();
boolean masterNodes = randomBoolean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ public Collection<Class<? extends Plugin>> transportClientPlugins() {
};
}

@Override
public List<String> filteredWarnings() {
return Stream.concat(super.filteredWarnings().stream(),
Stream.of("Configuring multiple [path.data] paths is deprecated. Use RAID or other system level features for utilizing " +
"multiple disks. This feature will be removed in 8.0.")).collect(Collectors.toList());
}

@AfterClass
public static void stopClusters() throws IOException {
IOUtils.close(clusterGroup);
Expand Down

0 comments on commit b4b127d

Please sign in to comment.