From ea2d9b13f0e84723eca81cd4c68449458867ce10 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Fri, 7 Dec 2018 09:06:42 -0700 Subject: [PATCH] Deprecation check for File Discovery plugin (#36190) Adds a deprecation warning that the file discovery plugin is no longer needed and that the path it uses has changed. --- .../xpack/deprecation/DeprecationChecks.java | 3 ++- .../xpack/deprecation/NodeDeprecationChecks.java | 16 ++++++++++++++++ .../deprecation/NodeDeprecationChecksTests.java | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java index 6dbbee49589a4..96334d158c182 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java @@ -39,7 +39,8 @@ private DeprecationChecks() { static List, List, DeprecationIssue>> NODE_SETTINGS_CHECKS = Collections.unmodifiableList(Arrays.asList( NodeDeprecationChecks::azureRepositoryChanges, - NodeDeprecationChecks::gcsRepositoryChanges + NodeDeprecationChecks::gcsRepositoryChanges, + NodeDeprecationChecks::fileDiscoveryPluginRemoved )); static List> INDEX_SETTINGS_CHECKS = diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java index d379869f0d472..898b65185cb82 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java @@ -49,4 +49,20 @@ static DeprecationIssue gcsRepositoryChanges(List nodeInfos, List nodeInfos, List nodeStats) { + List nodesFound = nodeInfos.stream() + .filter(nodeInfo -> + nodeInfo.getPlugins().getPluginInfos().stream() + .anyMatch(pluginInfo -> "discovery-file".equals(pluginInfo.getName())) + ).map(nodeInfo -> nodeInfo.getNode().getName()).collect(Collectors.toList()); + if (nodesFound.size() > 0) { + return new DeprecationIssue(DeprecationIssue.Level.WARNING, + "File-based discovery is no longer a plugin and uses a different path", + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_70_cluster_changes.html" + + "#_file_based_discovery_plugin", + "nodes with discovery-file installed: " + nodesFound); + } + return null; + } } diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java index 050d4aaf89ddb..277021a2e9cf5 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java @@ -88,4 +88,19 @@ public void testGCSPluginCheck() { "nodes with repository-gcs installed: [node_check]"); assertSettingsAndIssue("foo", "bar", expected); } + + public void testFileDiscoveryPluginCheck() { + Version esVersion = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, Version.CURRENT); + PluginInfo deprecatedPlugin = new PluginInfo( + "discovery-file", "dummy plugin description", "dummy_plugin_version", esVersion, + "javaVersion", "DummyPluginName", Collections.emptyList(), false); + pluginsAndModules = new PluginsAndModules(Collections.singletonList(deprecatedPlugin), Collections.emptyList()); + + DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING, + "File-based discovery is no longer a plugin and uses a different path", + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_70_cluster_changes.html" + + "#_file_based_discovery_plugin", + "nodes with discovery-file installed: [node_check]"); + assertSettingsAndIssue("foo", "bar", expected); + } }