From b4b127d312111847ae42968c5b1a7d6cf81427ee Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 2 Apr 2021 14:55:36 -0700 Subject: [PATCH] Deprecate multiple path.data entries (#71207) This commit adds a node level deprecation log message when multiple data paths are specified. relates #71205 --- .../java/org/elasticsearch/node/Node.java | 7 +++ .../test/AbstractMultiClustersTestCase.java | 8 ++++ .../org/elasticsearch/test/ESTestCase.java | 43 +++++++++---------- .../test/test/InternalTestClusterTests.java | 8 ++++ .../elasticsearch/xpack/CcrIntegTestCase.java | 7 +++ 5 files changed, 50 insertions(+), 23 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index 4081fdbf20ade..a529a7bac4018 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -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()), diff --git a/test/framework/src/main/java/org/elasticsearch/test/AbstractMultiClustersTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/AbstractMultiClustersTestCase.java index 59a452b3e147e..d3d2ddae3ac8f 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/AbstractMultiClustersTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/AbstractMultiClustersTestCase.java @@ -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; @@ -103,6 +104,13 @@ public final void startClusters() throws Exception { configureAndConnectsToRemoteClusters(); } + @Override + public List 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()) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index f0badad0c983c..67d5f01d54721 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -411,19 +411,11 @@ private void ensureNoWarnings() { try { final List warnings = threadContext.getResponseHeaders().get("Warning"); if (warnings != null) { - List 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 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); @@ -433,6 +425,17 @@ private void ensureNoWarnings() { } } + protected List filteredWarnings() { + List 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. * @@ -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 actualWarnings = threadContext.getResponseHeaders().get("Warning"); + + final List 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 filteredWarnings = filterJodaDeprecationWarnings(actualWarnings); - assertWarnings(stripXContentPosition, filteredWarnings, expectedWarnings); } else { assertWarnings(stripXContentPosition, actualWarnings, expectedWarnings); } @@ -504,12 +507,6 @@ protected final void assertWarnings(boolean stripXContentPosition, String... exp } } - private List filterJodaDeprecationWarnings(List actualWarnings) { - return actualWarnings.stream() - .filter(m -> m.contains(JodaDeprecationPatterns.USE_NEW_FORMAT_SPECIFIERS) == false) - .collect(Collectors.toList()); - } - private void assertWarnings(boolean stripXContentPosition, List actualWarnings, String[] expectedWarnings) { assertNotNull("no warnings, expected: " + Arrays.asList(expectedWarnings), actualWarnings); final Set actualWarningValues = diff --git a/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java b/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java index 76ab494f9bbf9..1574fcd426f5c 100644 --- a/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java +++ b/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java @@ -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; @@ -60,6 +61,13 @@ private static Collection> mockPlugins() { return Arrays.asList(getTestTransportPlugin(), MockHttpTransport.TestPlugin.class); } + @Override + protected List 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(); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java index 328b2bab9e372..089de79d2107f 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java @@ -320,6 +320,13 @@ public Collection> transportClientPlugins() { }; } + @Override + public List 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);