From 5a0dca24914eaa54ef7fdecd016dc1385c5212e8 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 17 Sep 2020 14:17:27 -0400 Subject: [PATCH] Deprecate xpack.eql.enabled setting and make it a no-op (#61375) (#62491) * Deprecate xpack.eql.enabled and make it a no-op * Remove uses of xpack.eql.enabled --- client/rest-high-level/build.gradle | 1 - docs/build.gradle | 1 - x-pack/plugin/eql/qa/rest/build.gradle | 1 - x-pack/plugin/eql/qa/security/build.gradle | 1 - .../eql/action/AbstractEqlIntegTestCase.java | 2 - .../xpack/eql/EqlFeatureSet.java | 5 +-- .../xpack/eql/plugin/EqlPlugin.java | 40 ++++++++----------- .../xpack/eql/EqlFeatureSetTests.java | 12 ++---- .../eql/action/LocalStateEQLXPackPlugin.java | 2 +- .../xpack/eql/plugin/EqlPluginTests.java | 5 +-- 10 files changed, 25 insertions(+), 45 deletions(-) diff --git a/client/rest-high-level/build.gradle b/client/rest-high-level/build.gradle index d73aab6e0e1..747d882258e 100644 --- a/client/rest-high-level/build.gradle +++ b/client/rest-high-level/build.gradle @@ -93,7 +93,6 @@ testClusters.all { setting 'xpack.security.authc.api_key.enabled', 'true' setting 'xpack.security.http.ssl.enabled', 'false' setting 'xpack.security.transport.ssl.enabled', 'false' - setting 'xpack.eql.enabled', 'true' // Truststore settings are not used since TLS is not enabled. Included for testing the get certificates API setting 'xpack.security.http.ssl.certificate_authorities', 'testnode.crt' setting 'xpack.security.transport.ssl.truststore.path', 'testnode.jks' diff --git a/docs/build.gradle b/docs/build.gradle index 9f1a967c44e..68078d5f5c5 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -56,7 +56,6 @@ testClusters.integTest { systemProperty 'es.autoscaling_feature_flag_registered', 'true' } setting 'xpack.autoscaling.enabled', 'true' - setting 'xpack.eql.enabled', 'true' keystorePassword 's3cr3t' } diff --git a/x-pack/plugin/eql/qa/rest/build.gradle b/x-pack/plugin/eql/qa/rest/build.gradle index 041015b6b65..779c7ccedf5 100644 --- a/x-pack/plugin/eql/qa/rest/build.gradle +++ b/x-pack/plugin/eql/qa/rest/build.gradle @@ -14,7 +14,6 @@ dependencies { testClusters.all { testDistribution = 'DEFAULT' - setting 'xpack.eql.enabled', 'true' setting 'xpack.license.self_generated.type', 'basic' setting 'xpack.monitoring.collection.enabled', 'true' } diff --git a/x-pack/plugin/eql/qa/security/build.gradle b/x-pack/plugin/eql/qa/security/build.gradle index d77dfda8479..f17c458b672 100644 --- a/x-pack/plugin/eql/qa/security/build.gradle +++ b/x-pack/plugin/eql/qa/security/build.gradle @@ -6,7 +6,6 @@ dependencies { testClusters.all { testDistribution = 'DEFAULT' - setting 'xpack.eql.enabled', 'true' setting 'xpack.license.self_generated.type', 'basic' setting 'xpack.monitoring.collection.enabled', 'true' setting 'xpack.security.enabled', 'true' diff --git a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java index 039d7e848a7..2802c49136d 100644 --- a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java +++ b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java @@ -11,7 +11,6 @@ import org.elasticsearch.license.LicenseService; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xpack.core.XPackSettings; -import org.elasticsearch.xpack.eql.plugin.EqlPlugin; import java.util.Collection; import java.util.Collections; @@ -28,7 +27,6 @@ public abstract class AbstractEqlIntegTestCase extends ESIntegTestCase { settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false); - settings.put(EqlPlugin.EQL_ENABLED_SETTING.getKey(), true); settings.put(LicenseService.SELF_GENERATED_LICENSE_TYPE.getKey(), "trial"); return settings.build(); } diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/EqlFeatureSet.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/EqlFeatureSet.java index ad00ce65a6d..981fe6c05bf 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/EqlFeatureSet.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/EqlFeatureSet.java @@ -10,7 +10,6 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.client.Client; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.xpack.core.XPackFeatureSet; import org.elasticsearch.xpack.core.XPackField; @@ -34,8 +33,8 @@ public class EqlFeatureSet implements XPackFeatureSet { private final Client client; @Inject - public EqlFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState, Client client) { - this.enabled = EqlPlugin.isEnabled(settings); + public EqlFeatureSet(@Nullable XPackLicenseState licenseState, Client client) { + this.enabled = EqlPlugin.isEnabled(); this.licenseState = licenseState; this.client = client; } diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlPlugin.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlPlugin.java index f9f96a59e09..a12c74e0775 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlPlugin.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlPlugin.java @@ -47,16 +47,14 @@ import java.util.function.Supplier; public class EqlPlugin extends Plugin implements ActionPlugin { - private final boolean enabled; - public static final Setting EQL_ENABLED_SETTING = Setting.boolSetting( "xpack.eql.enabled", true, - Setting.Property.NodeScope + Setting.Property.NodeScope, + Setting.Property.Deprecated ); - public EqlPlugin(final Settings settings) { - this.enabled = EQL_ENABLED_SETTING.get(settings); + public EqlPlugin() { } @Override @@ -93,14 +91,11 @@ public class EqlPlugin extends Plugin implements ActionPlugin { @Override public List> getActions() { - if (enabled) { - return Arrays.asList( - new ActionHandler<>(EqlSearchAction.INSTANCE, TransportEqlSearchAction.class), - new ActionHandler<>(EqlStatsAction.INSTANCE, TransportEqlStatsAction.class), - new ActionHandler<>(EqlAsyncGetResultAction.INSTANCE, TransportEqlAsyncGetResultAction.class) - ); - } - return Collections.emptyList(); + return org.elasticsearch.common.collect.List.of( + new ActionHandler<>(EqlSearchAction.INSTANCE, TransportEqlSearchAction.class), + new ActionHandler<>(EqlStatsAction.INSTANCE, TransportEqlStatsAction.class), + new ActionHandler<>(EqlAsyncGetResultAction.INSTANCE, TransportEqlAsyncGetResultAction.class) + ); } boolean isSnapshot() { @@ -108,8 +103,8 @@ public class EqlPlugin extends Plugin implements ActionPlugin { } // TODO: this needs to be used by all plugin methods - including getActions and createComponents - public static boolean isEnabled(Settings settings) { - return EQL_ENABLED_SETTING.get(settings); + public static boolean isEnabled() { + return true; // basic license level features are always enabled } @Override @@ -121,15 +116,12 @@ public class EqlPlugin extends Plugin implements ActionPlugin { IndexNameExpressionResolver indexNameExpressionResolver, Supplier nodesInCluster) { - if (enabled) { - return Arrays.asList( - new RestEqlSearchAction(), - new RestEqlStatsAction(), - new RestEqlGetAsyncResultAction(), - new RestEqlDeleteAsyncResultAction() - ); - } - return Collections.emptyList(); + return Arrays.asList( + new RestEqlSearchAction(), + new RestEqlStatsAction(), + new RestEqlGetAsyncResultAction(), + new RestEqlDeleteAsyncResultAction() + ); } // overridable by tests diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/EqlFeatureSetTests.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/EqlFeatureSetTests.java index f047aecfde6..8bf1ed55b84 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/EqlFeatureSetTests.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/EqlFeatureSetTests.java @@ -51,19 +51,15 @@ public class EqlFeatureSetTests extends ESTestCase { } public void testAvailable() { - EqlFeatureSet featureSet = new EqlFeatureSet(Settings.EMPTY, licenseState, client); + EqlFeatureSet featureSet = new EqlFeatureSet(licenseState, client); boolean available = randomBoolean(); when(licenseState.isAllowed(XPackLicenseState.Feature.EQL)).thenReturn(available); assertThat(featureSet.available(), is(available)); } public void testEnabled() { - boolean enabled = randomBoolean(); - Settings.Builder settings = Settings.builder(); - settings.put("xpack.eql.enabled", enabled); - - EqlFeatureSet featureSet = new EqlFeatureSet(settings.build(), licenseState, client); - assertThat(featureSet.enabled(), is(enabled)); + EqlFeatureSet featureSet = new EqlFeatureSet(licenseState, client); + assertThat(featureSet.enabled(), is(true)); } @SuppressWarnings("unchecked") @@ -94,7 +90,7 @@ public class EqlFeatureSetTests extends ESTestCase { }).when(client).execute(eq(EqlStatsAction.INSTANCE), any(), any()); PlainActionFuture future = new PlainActionFuture<>(); - new EqlFeatureSet(Settings.builder().put("xpack.eql.enabled", true).build(), licenseState, client).usage(future); + new EqlFeatureSet(licenseState, client).usage(future); EqlFeatureSetUsage eqlUsage = (EqlFeatureSetUsage) future.get(); long fooBarBaz = ObjectPath.eval("foo.bar.baz", eqlUsage.stats()); diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/LocalStateEQLXPackPlugin.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/LocalStateEQLXPackPlugin.java index 43f740e1bd7..0b9524bbbfe 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/LocalStateEQLXPackPlugin.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/LocalStateEQLXPackPlugin.java @@ -19,7 +19,7 @@ public class LocalStateEQLXPackPlugin extends LocalStateCompositeXPackPlugin { public LocalStateEQLXPackPlugin(final Settings settings, final Path configPath) { super(settings, configPath); LocalStateEQLXPackPlugin thisVar = this; - plugins.add(new EqlPlugin(settings) { + plugins.add(new EqlPlugin() { @Override protected XPackLicenseState getLicenseState() { return thisVar.getLicenseState(); diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/plugin/EqlPluginTests.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/plugin/EqlPluginTests.java index e2cfffe71a1..5e1b87347e3 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/plugin/EqlPluginTests.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/plugin/EqlPluginTests.java @@ -6,14 +6,13 @@ package org.elasticsearch.xpack.eql.plugin; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESTestCase; import static org.hamcrest.Matchers.hasItem; public class EqlPluginTests extends ESTestCase { public void testEnabledSettingRegisteredInSnapshotBuilds() { - final EqlPlugin plugin = new EqlPlugin(Settings.EMPTY) { + final EqlPlugin plugin = new EqlPlugin() { @Override protected boolean isSnapshot() { @@ -25,7 +24,7 @@ public class EqlPluginTests extends ESTestCase { } public void testEnabledSettingNotRegisteredInNonSnapshotBuilds() { - final EqlPlugin plugin = new EqlPlugin(Settings.EMPTY) { + final EqlPlugin plugin = new EqlPlugin() { @Override protected boolean isSnapshot() {