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
This commit is contained in:
William Brafford 2020-09-17 14:17:27 -04:00 committed by GitHub
parent 5f643433c6
commit 5a0dca2491
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 25 additions and 45 deletions

View File

@ -93,7 +93,6 @@ testClusters.all {
setting 'xpack.security.authc.api_key.enabled', 'true' setting 'xpack.security.authc.api_key.enabled', 'true'
setting 'xpack.security.http.ssl.enabled', 'false' setting 'xpack.security.http.ssl.enabled', 'false'
setting 'xpack.security.transport.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 // 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.http.ssl.certificate_authorities', 'testnode.crt'
setting 'xpack.security.transport.ssl.truststore.path', 'testnode.jks' setting 'xpack.security.transport.ssl.truststore.path', 'testnode.jks'

View File

@ -56,7 +56,6 @@ testClusters.integTest {
systemProperty 'es.autoscaling_feature_flag_registered', 'true' systemProperty 'es.autoscaling_feature_flag_registered', 'true'
} }
setting 'xpack.autoscaling.enabled', 'true' setting 'xpack.autoscaling.enabled', 'true'
setting 'xpack.eql.enabled', 'true'
keystorePassword 's3cr3t' keystorePassword 's3cr3t'
} }

View File

@ -14,7 +14,6 @@ dependencies {
testClusters.all { testClusters.all {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
setting 'xpack.eql.enabled', 'true'
setting 'xpack.license.self_generated.type', 'basic' setting 'xpack.license.self_generated.type', 'basic'
setting 'xpack.monitoring.collection.enabled', 'true' setting 'xpack.monitoring.collection.enabled', 'true'
} }

View File

@ -6,7 +6,6 @@ dependencies {
testClusters.all { testClusters.all {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
setting 'xpack.eql.enabled', 'true'
setting 'xpack.license.self_generated.type', 'basic' setting 'xpack.license.self_generated.type', 'basic'
setting 'xpack.monitoring.collection.enabled', 'true' setting 'xpack.monitoring.collection.enabled', 'true'
setting 'xpack.security.enabled', 'true' setting 'xpack.security.enabled', 'true'

View File

@ -11,7 +11,6 @@ import org.elasticsearch.license.LicenseService;
import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.XPackSettings;
import org.elasticsearch.xpack.eql.plugin.EqlPlugin;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -28,7 +27,6 @@ public abstract class AbstractEqlIntegTestCase extends ESIntegTestCase {
settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false);
settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false);
settings.put(XPackSettings.MACHINE_LEARNING_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"); settings.put(LicenseService.SELF_GENERATED_LICENSE_TYPE.getKey(), "trial");
return settings.build(); return settings.build();
} }

View File

@ -10,7 +10,6 @@ import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.xpack.core.XPackFeatureSet; import org.elasticsearch.xpack.core.XPackFeatureSet;
import org.elasticsearch.xpack.core.XPackField; import org.elasticsearch.xpack.core.XPackField;
@ -34,8 +33,8 @@ public class EqlFeatureSet implements XPackFeatureSet {
private final Client client; private final Client client;
@Inject @Inject
public EqlFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState, Client client) { public EqlFeatureSet(@Nullable XPackLicenseState licenseState, Client client) {
this.enabled = EqlPlugin.isEnabled(settings); this.enabled = EqlPlugin.isEnabled();
this.licenseState = licenseState; this.licenseState = licenseState;
this.client = client; this.client = client;
} }

View File

@ -47,16 +47,14 @@ import java.util.function.Supplier;
public class EqlPlugin extends Plugin implements ActionPlugin { public class EqlPlugin extends Plugin implements ActionPlugin {
private final boolean enabled;
public static final Setting<Boolean> EQL_ENABLED_SETTING = Setting.boolSetting( public static final Setting<Boolean> EQL_ENABLED_SETTING = Setting.boolSetting(
"xpack.eql.enabled", "xpack.eql.enabled",
true, true,
Setting.Property.NodeScope Setting.Property.NodeScope,
Setting.Property.Deprecated
); );
public EqlPlugin(final Settings settings) { public EqlPlugin() {
this.enabled = EQL_ENABLED_SETTING.get(settings);
} }
@Override @Override
@ -93,14 +91,11 @@ public class EqlPlugin extends Plugin implements ActionPlugin {
@Override @Override
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() { public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
if (enabled) { return org.elasticsearch.common.collect.List.of(
return Arrays.asList( new ActionHandler<>(EqlSearchAction.INSTANCE, TransportEqlSearchAction.class),
new ActionHandler<>(EqlSearchAction.INSTANCE, TransportEqlSearchAction.class), new ActionHandler<>(EqlStatsAction.INSTANCE, TransportEqlStatsAction.class),
new ActionHandler<>(EqlStatsAction.INSTANCE, TransportEqlStatsAction.class), new ActionHandler<>(EqlAsyncGetResultAction.INSTANCE, TransportEqlAsyncGetResultAction.class)
new ActionHandler<>(EqlAsyncGetResultAction.INSTANCE, TransportEqlAsyncGetResultAction.class) );
);
}
return Collections.emptyList();
} }
boolean isSnapshot() { 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 // TODO: this needs to be used by all plugin methods - including getActions and createComponents
public static boolean isEnabled(Settings settings) { public static boolean isEnabled() {
return EQL_ENABLED_SETTING.get(settings); return true; // basic license level features are always enabled
} }
@Override @Override
@ -121,15 +116,12 @@ public class EqlPlugin extends Plugin implements ActionPlugin {
IndexNameExpressionResolver indexNameExpressionResolver, IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<DiscoveryNodes> nodesInCluster) { Supplier<DiscoveryNodes> nodesInCluster) {
if (enabled) { return Arrays.asList(
return Arrays.asList( new RestEqlSearchAction(),
new RestEqlSearchAction(), new RestEqlStatsAction(),
new RestEqlStatsAction(), new RestEqlGetAsyncResultAction(),
new RestEqlGetAsyncResultAction(), new RestEqlDeleteAsyncResultAction()
new RestEqlDeleteAsyncResultAction() );
);
}
return Collections.emptyList();
} }
// overridable by tests // overridable by tests

View File

@ -51,19 +51,15 @@ public class EqlFeatureSetTests extends ESTestCase {
} }
public void testAvailable() { public void testAvailable() {
EqlFeatureSet featureSet = new EqlFeatureSet(Settings.EMPTY, licenseState, client); EqlFeatureSet featureSet = new EqlFeatureSet(licenseState, client);
boolean available = randomBoolean(); boolean available = randomBoolean();
when(licenseState.isAllowed(XPackLicenseState.Feature.EQL)).thenReturn(available); when(licenseState.isAllowed(XPackLicenseState.Feature.EQL)).thenReturn(available);
assertThat(featureSet.available(), is(available)); assertThat(featureSet.available(), is(available));
} }
public void testEnabled() { public void testEnabled() {
boolean enabled = randomBoolean(); EqlFeatureSet featureSet = new EqlFeatureSet(licenseState, client);
Settings.Builder settings = Settings.builder(); assertThat(featureSet.enabled(), is(true));
settings.put("xpack.eql.enabled", enabled);
EqlFeatureSet featureSet = new EqlFeatureSet(settings.build(), licenseState, client);
assertThat(featureSet.enabled(), is(enabled));
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -94,7 +90,7 @@ public class EqlFeatureSetTests extends ESTestCase {
}).when(client).execute(eq(EqlStatsAction.INSTANCE), any(), any()); }).when(client).execute(eq(EqlStatsAction.INSTANCE), any(), any());
PlainActionFuture<EqlFeatureSet.Usage> future = new PlainActionFuture<>(); PlainActionFuture<EqlFeatureSet.Usage> 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(); EqlFeatureSetUsage eqlUsage = (EqlFeatureSetUsage) future.get();
long fooBarBaz = ObjectPath.eval("foo.bar.baz", eqlUsage.stats()); long fooBarBaz = ObjectPath.eval("foo.bar.baz", eqlUsage.stats());

View File

@ -19,7 +19,7 @@ public class LocalStateEQLXPackPlugin extends LocalStateCompositeXPackPlugin {
public LocalStateEQLXPackPlugin(final Settings settings, final Path configPath) { public LocalStateEQLXPackPlugin(final Settings settings, final Path configPath) {
super(settings, configPath); super(settings, configPath);
LocalStateEQLXPackPlugin thisVar = this; LocalStateEQLXPackPlugin thisVar = this;
plugins.add(new EqlPlugin(settings) { plugins.add(new EqlPlugin() {
@Override @Override
protected XPackLicenseState getLicenseState() { protected XPackLicenseState getLicenseState() {
return thisVar.getLicenseState(); return thisVar.getLicenseState();

View File

@ -6,14 +6,13 @@
package org.elasticsearch.xpack.eql.plugin; package org.elasticsearch.xpack.eql.plugin;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasItem;
public class EqlPluginTests extends ESTestCase { public class EqlPluginTests extends ESTestCase {
public void testEnabledSettingRegisteredInSnapshotBuilds() { public void testEnabledSettingRegisteredInSnapshotBuilds() {
final EqlPlugin plugin = new EqlPlugin(Settings.EMPTY) { final EqlPlugin plugin = new EqlPlugin() {
@Override @Override
protected boolean isSnapshot() { protected boolean isSnapshot() {
@ -25,7 +24,7 @@ public class EqlPluginTests extends ESTestCase {
} }
public void testEnabledSettingNotRegisteredInNonSnapshotBuilds() { public void testEnabledSettingNotRegisteredInNonSnapshotBuilds() {
final EqlPlugin plugin = new EqlPlugin(Settings.EMPTY) { final EqlPlugin plugin = new EqlPlugin() {
@Override @Override
protected boolean isSnapshot() { protected boolean isSnapshot() {