From 27719553c2167ed84c773633dcb1012967f22db0 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Wed, 15 Apr 2020 11:24:35 -0400 Subject: [PATCH 01/18] Make xpack.transform.enabled setting a no-op --- .../xpack/transform/Transform.java | 40 ++------------- .../TransformInfoTransportAction.java | 5 +- .../TransformUsageTransportAction.java | 12 +---- .../TransformInfoTransportActionTests.java | 49 ------------------- .../xpack/transform/TransformTests.java | 7 +-- 5 files changed, 9 insertions(+), 104 deletions(-) diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java index 8173c64e19fa2..1cc78d8f5b2dd 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java @@ -45,7 +45,6 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.core.XPackPlugin; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; import org.elasticsearch.xpack.core.scheduler.SchedulerEngine; @@ -118,8 +117,6 @@ import java.util.function.Supplier; import java.util.function.UnaryOperator; -import static java.util.Collections.emptyList; - public class Transform extends Plugin implements SystemIndexPlugin, PersistentTaskPlugin { public static final String NAME = "transform"; @@ -127,7 +124,6 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa private static final Logger logger = LogManager.getLogger(Transform.class); - private final boolean enabled; private final Settings settings; private final SetOnce transformServices = new SetOnce<>(); @@ -150,12 +146,11 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa public static final String TRANSFORM_ENABLED_NODE_ATTR = "transform.node"; /** - * Setting whether transform (the coordinator task) can run on this node and REST API's are available, - * respects xpack.transform.enabled (for the whole plugin) as fallback + * Setting whether transform (the coordinator task) can run on this node. */ public static final Setting TRANSFORM_ENABLED_NODE = Setting.boolSetting( "node.transform", - settings -> Boolean.toString(XPackSettings.TRANSFORM_ENABLED.get(settings) && DiscoveryNode.isDataNode(settings)), + settings -> Boolean.toString(DiscoveryNode.isDataNode(settings)), Property.NodeScope ); @@ -170,7 +165,6 @@ protected Setting roleSetting() { public Transform(Settings settings) { this.settings = settings; - this.enabled = XPackSettings.TRANSFORM_ENABLED.get(settings); } protected XPackLicenseState getLicenseState() { @@ -188,10 +182,6 @@ public List getRestHandlers( final Supplier nodesInCluster ) { - if (!enabled) { - return emptyList(); - } - return Arrays.asList( new RestPutTransformAction(), new RestStartTransformAction(), @@ -217,11 +207,6 @@ public List getRestHandlers( @Override public List> getActions() { - var usageAction = new ActionHandler<>(XPackUsageFeatureAction.TRANSFORM, TransformUsageTransportAction.class); - var infoAction = new ActionHandler<>(XPackInfoFeatureAction.TRANSFORM, TransformInfoTransportAction.class); - if (enabled == false) { - return Arrays.asList(usageAction, infoAction); - } return Arrays.asList( new ActionHandler<>(PutTransformAction.INSTANCE, TransportPutTransformAction.class), @@ -243,17 +228,14 @@ public List getRestHandlers( new ActionHandler<>(PreviewTransformActionDeprecated.INSTANCE, TransportPreviewTransformActionDeprecated.class), new ActionHandler<>(UpdateTransformActionDeprecated.INSTANCE, TransportUpdateTransformActionDeprecated.class), - usageAction, - infoAction + // usage and info + new ActionHandler<>(XPackUsageFeatureAction.TRANSFORM, TransformUsageTransportAction.class), + new ActionHandler<>(XPackInfoFeatureAction.TRANSFORM, TransformInfoTransportAction.class) ); } @Override public List> getExecutorBuilders(Settings settings) { - if (false == enabled) { - return emptyList(); - } - FixedExecutorBuilder indexing = new FixedExecutorBuilder( settings, TASK_THREAD_POOL_NAME, @@ -280,10 +262,6 @@ public Collection createComponents( IndexNameExpressionResolver expressionResolver, Supplier repositoriesServiceSupplier ) { - if (enabled == false) { - return emptyList(); - } - TransformConfigManager configManager = new IndexBasedTransformConfigManager(client, xContentRegistry); TransformAuditor auditor = new TransformAuditor(client, clusterService.getNodeName()); TransformCheckpointService checkpointService = new TransformCheckpointService( @@ -327,10 +305,6 @@ public List> getPersistentTasksExecutor( SettingsModule settingsModule, IndexNameExpressionResolver expressionResolver ) { - if (enabled == false) { - return emptyList(); - } - // the transform services should have been created assert transformServices.get() != null; @@ -361,10 +335,6 @@ public Settings additionalSettings() { ); } - if (enabled == false) { - return Settings.EMPTY; - } - Settings.Builder additionalSettings = Settings.builder(); additionalSettings.put(transformEnabledNodeAttribute, TRANSFORM_ENABLED_NODE.get(settings)); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformInfoTransportAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformInfoTransportAction.java index 847f37a5b9d4b..64f9a80cb23ee 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformInfoTransportAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformInfoTransportAction.java @@ -25,7 +25,6 @@ import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.ClientHelper; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; import org.elasticsearch.xpack.core.action.XPackInfoFeatureTransportAction; import org.elasticsearch.xpack.core.transform.TransformField; @@ -39,7 +38,6 @@ public class TransformInfoTransportAction extends XPackInfoFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; private static final Logger logger = LogManager.getLogger(TransformInfoTransportAction.class); @@ -69,7 +67,6 @@ public TransformInfoTransportAction( XPackLicenseState licenseState ) { super(XPackInfoFeatureAction.TRANSFORM.name(), transportService, actionFilters); - this.enabled = XPackSettings.TRANSFORM_ENABLED.get(settings); this.licenseState = licenseState; } @@ -85,7 +82,7 @@ public boolean available() { @Override public boolean enabled() { - return enabled; + return true; } static TransformIndexerStats parseSearchAggs(SearchResponse searchResponse) { diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java index f5d2b29263efd..83267ad0de9ab 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java @@ -26,7 +26,6 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.ClientHelper; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; import org.elasticsearch.xpack.core.action.XPackUsageFeatureTransportAction; @@ -49,7 +48,6 @@ public class TransformUsageTransportAction extends XPackUsageFeatureTransportAct private static final Logger logger = LogManager.getLogger(TransformUsageTransportAction.class); - private final boolean enabled; private final XPackLicenseState licenseState; private final Client client; @@ -72,7 +70,6 @@ public TransformUsageTransportAction( actionFilters, indexNameExpressionResolver ); - this.enabled = XPackSettings.TRANSFORM_ENABLED.get(settings); this.licenseState = licenseState; this.client = client; } @@ -85,11 +82,6 @@ protected void masterOperation( ActionListener listener ) { boolean available = licenseState.isTransformAllowed(); - if (enabled == false) { - var usage = new TransformFeatureSetUsage(available, enabled, Collections.emptyMap(), new TransformIndexerStats()); - listener.onResponse(new XPackUsageFeatureResponse(usage)); - return; - } PersistentTasksCustomMetadata taskMetadata = PersistentTasksCustomMetadata.getPersistentTasksCustomMetadata(state); Collection> transformTasks = taskMetadata == null @@ -106,7 +98,7 @@ protected void masterOperation( } ActionListener totalStatsListener = ActionListener.wrap(statSummations -> { - var usage = new TransformFeatureSetUsage(available, enabled, transformsCountByState, statSummations); + var usage = new TransformFeatureSetUsage(available, true, transformsCountByState, statSummations); listener.onResponse(new XPackUsageFeatureResponse(usage)); }, listener::onFailure); @@ -119,7 +111,7 @@ protected void masterOperation( } long totalTransforms = transformCountSuccess.getHits().getTotalHits().value; if (totalTransforms == 0) { - var usage = new TransformFeatureSetUsage(available, enabled, transformsCountByState, new TransformIndexerStats()); + var usage = new TransformFeatureSetUsage(available, true, transformsCountByState, new TransformIndexerStats()); listener.onResponse(new XPackUsageFeatureResponse(usage)); return; } diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformInfoTransportActionTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformInfoTransportActionTests.java index b2329207a79ea..364af168ab25b 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformInfoTransportActionTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformInfoTransportActionTests.java @@ -8,34 +8,19 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.PlainActionFuture; -import org.elasticsearch.client.Client; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregation; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.core.XPackFeatureSet; -import org.elasticsearch.xpack.core.XPackSettings; -import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; import org.elasticsearch.xpack.core.transform.transforms.TransformIndexerStats; import org.junit.Before; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutionException; import static org.elasticsearch.xpack.transform.TransformInfoTransportAction.PROVIDED_STATS; import static org.hamcrest.CoreMatchers.equalTo; @@ -74,7 +59,6 @@ public void testEnabledSetting() { licenseState ); assertThat(featureSet.enabled(), is(enabled)); - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.TRANSFORM_ENABLED } ); } public void testEnabledDefault() { @@ -130,37 +114,4 @@ private static Aggregation buildAgg(String name, double value) { when(agg.value()).thenReturn(value); return agg; } - - public void testUsageDisabled() throws IOException, InterruptedException, ExecutionException { - when(licenseState.isTransformAllowed()).thenReturn(true); - Settings.Builder settings = Settings.builder(); - settings.put("xpack.transform.enabled", false); - var usageAction = new TransformUsageTransportAction( - mock(TransportService.class), - null, - null, - mock(ActionFilters.class), - null, - settings.build(), - licenseState, - mock(Client.class) - ); - PlainActionFuture future = new PlainActionFuture<>(); - usageAction.masterOperation(null, null, mock(ClusterState.class), future); - XPackFeatureSet.Usage usage = future.get().getUsage(); - - assertFalse(usage.enabled()); - try (XContentBuilder builder = XContentFactory.jsonBuilder()) { - usage.toXContent(builder, ToXContent.EMPTY_PARAMS); - - XContentParser parser = createParser(builder); - Map usageAsMap = parser.map(); - assertTrue((boolean) XContentMapValues.extractValue("available", usageAsMap)); - assertFalse((boolean) XContentMapValues.extractValue("enabled", usageAsMap)); - // not enabled -> no transforms, no stats - assertEquals(null, XContentMapValues.extractValue("transforms", usageAsMap)); - assertEquals(null, XContentMapValues.extractValue("stats", usageAsMap)); - } - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.TRANSFORM_ENABLED } ); - } } diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformTests.java index 213e271c5a026..260370cdbcf49 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformTests.java @@ -6,11 +6,9 @@ package org.elasticsearch.xpack.transform; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.core.XPackSettings; import static org.hamcrest.Matchers.equalTo; import static org.mockito.Mockito.mock; @@ -35,12 +33,9 @@ public void testNodeAttributes() { Transform transform = createTransform(builder.build()); assertNotNull(transform.additionalSettings()); assertEquals( - transformPluginEnabled && transformEnabled, + transformEnabled, Boolean.parseBoolean(transform.additionalSettings().get("node.attr.transform.node")) ); - if (transformPluginEnabled == false) { - assertSettingDeprecationsAndWarnings(new Setting[]{XPackSettings.TRANSFORM_ENABLED}); - } } public void testNodeAttributesDirectlyGiven() { From 7fb31d97dc797ab26647903587b283c431554f30 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Wed, 15 Apr 2020 16:02:37 -0400 Subject: [PATCH 02/18] Make xpack.rollup.enabled a no-op --- .../xpack/core/XPackSettings.java | 6 ++++- .../elasticsearch/xpack/rollup/Rollup.java | 24 ++----------------- .../rollup/RollupInfoTransportAction.java | 4 +--- .../rollup/RollupUsageTransportAction.java | 4 +--- .../RollupInfoTransportActionTests.java | 5 ++-- 5 files changed, 11 insertions(+), 32 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java index 1e39bc4ce4be4..0b3033fc9fccc 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java @@ -48,7 +48,11 @@ private XPackSettings() { */ public static final Setting CCR_ENABLED_SETTING = Setting.boolSetting("xpack.ccr.enabled", true, Property.NodeScope); - /** Setting for enabling or disabling data frame. Defaults to true. */ + /** + * Setting for enabling or disabling data frame. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. + */ public static final Setting TRANSFORM_ENABLED = Setting.boolSetting("xpack.transform.enabled", true, Property.NodeScope, Property.Deprecated); diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java index 0d2e0757e7891..61a8f2d8ad439 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java @@ -33,7 +33,6 @@ import org.elasticsearch.threadpool.FixedExecutorBuilder; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; import org.elasticsearch.xpack.core.rollup.RollupField; @@ -95,11 +94,9 @@ public class Rollup extends Plugin implements ActionPlugin, PersistentTaskPlugin private final SetOnce schedulerEngine = new SetOnce<>(); private final Settings settings; - private final boolean enabled; public Rollup(Settings settings) { this.settings = settings; - this.enabled = XPackSettings.ROLLUP_ENABLED.get(settings); } @Override @@ -117,10 +114,6 @@ public List getRestHandlers(Settings settings, RestController restC IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver, Supplier nodesInCluster) { - if (!enabled) { - return emptyList(); - } - return Arrays.asList( new RestRollupSearchAction(), new RestPutRollupJobAction(), @@ -136,11 +129,6 @@ public List getRestHandlers(Settings settings, RestController restC @Override public List> getActions() { - var usageAction = new ActionHandler<>(XPackUsageFeatureAction.ROLLUP, RollupUsageTransportAction.class); - var infoAction = new ActionHandler<>(XPackInfoFeatureAction.ROLLUP, RollupInfoTransportAction.class); - if (enabled == false) { - return Arrays.asList(usageAction, infoAction); - } return Arrays.asList( new ActionHandler<>(RollupSearchAction.INSTANCE, TransportRollupSearchAction.class), new ActionHandler<>(PutRollupJobAction.INSTANCE, TransportPutRollupJobAction.class), @@ -150,16 +138,12 @@ public List getRestHandlers(Settings settings, RestController restC new ActionHandler<>(GetRollupJobsAction.INSTANCE, TransportGetRollupJobAction.class), new ActionHandler<>(GetRollupCapsAction.INSTANCE, TransportGetRollupCapsAction.class), new ActionHandler<>(GetRollupIndexCapsAction.INSTANCE, TransportGetRollupIndexCapsAction.class), - usageAction, - infoAction); + new ActionHandler<>(XPackUsageFeatureAction.ROLLUP, RollupUsageTransportAction.class), + new ActionHandler<>(XPackInfoFeatureAction.ROLLUP, RollupInfoTransportAction.class)); } @Override public List> getExecutorBuilders(Settings settings) { - if (false == enabled) { - return emptyList(); - } - FixedExecutorBuilder indexing = new FixedExecutorBuilder(settings, Rollup.TASK_THREAD_POOL_NAME, 4, 4, "xpack.rollup.task_thread_pool", false); @@ -172,10 +156,6 @@ public List> getPersistentTasksExecutor(ClusterServic Client client, SettingsModule settingsModule, IndexNameExpressionResolver expressionResolver) { - if (enabled == false) { - return emptyList(); - } - schedulerEngine.set(new SchedulerEngine(settings, getClock())); return Collections.singletonList(new RollupJobTask.RollupJobPersistentTasksExecutor(client, schedulerEngine.get(), threadPool)); } diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java index 93330872554cc..00fd2d1382e7b 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java @@ -17,14 +17,12 @@ public class RollupInfoTransportAction extends XPackInfoFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject public RollupInfoTransportAction(TransportService transportService, ActionFilters actionFilters, Settings settings, XPackLicenseState licenseState) { super(XPackInfoFeatureAction.ROLLUP.name(), transportService, actionFilters); - this.enabled = XPackSettings.ROLLUP_ENABLED.get(settings); this.licenseState = licenseState; } @@ -40,7 +38,7 @@ public boolean available() { @Override public boolean enabled() { - return enabled; + return true; } } diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java index 5253c05517e84..f85ed2d338b24 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java @@ -25,7 +25,6 @@ public class RollupUsageTransportAction extends XPackUsageFeatureTransportAction { - private final Settings settings; private final XPackLicenseState licenseState; @Inject @@ -34,7 +33,6 @@ public RollupUsageTransportAction(TransportService transportService, ClusterServ Settings settings, XPackLicenseState licenseState) { super(XPackUsageFeatureAction.ROLLUP.name(), transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver); - this.settings = settings; this.licenseState = licenseState; } @@ -44,7 +42,7 @@ protected void masterOperation(Task task, XPackUsageRequest request, ClusterStat boolean available = licenseState.isRollupAllowed(); // TODO expose the currently running rollup tasks on this node? Unclear the best way to do that RollupFeatureSetUsage usage = - new RollupFeatureSetUsage(available, XPackSettings.ROLLUP_ENABLED.get(settings)); + new RollupFeatureSetUsage(available, true); listener.onResponse(new XPackUsageFeatureResponse(usage)); } } diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java index 68e413951e0b5..5a0b15166ffc0 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java @@ -42,14 +42,13 @@ public void testAvailable() { assertThat(featureSet.available(), is(available)); } - public void testEnabledSetting() { + public void testEnabledSettingIsANoOp() { boolean enabled = randomBoolean(); Settings.Builder settings = Settings.builder(); settings.put("xpack.rollup.enabled", enabled); RollupInfoTransportAction featureSet = new RollupInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), settings.build(), licenseState); - assertThat(featureSet.enabled(), is(enabled)); - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.ROLLUP_ENABLED } ); + assertThat(featureSet.enabled(), is(true)); } public void testEnabledDefault() { From 8cdc5a6dcdf0d7cd1f83fb7d57e7609561e3a9e1 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Wed, 15 Apr 2020 16:07:27 -0400 Subject: [PATCH 03/18] Make xpack.logstash.enabled a no-op --- .../xpack/logstash/LogstashInfoTransportAction.java | 5 +---- .../xpack/logstash/LogstashUsageTransportAction.java | 4 +--- .../xpack/logstash/LogstashInfoTransportActionTests.java | 4 +--- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportAction.java b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportAction.java index 4aa77af2988f4..64e3d9a26572e 100644 --- a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportAction.java +++ b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportAction.java @@ -11,13 +11,11 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; import org.elasticsearch.xpack.core.action.XPackInfoFeatureTransportAction; public class LogstashInfoTransportAction extends XPackInfoFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject @@ -28,7 +26,6 @@ public LogstashInfoTransportAction( XPackLicenseState licenseState ) { super(XPackInfoFeatureAction.LOGSTASH.name(), transportService, actionFilters); - this.enabled = XPackSettings.LOGSTASH_ENABLED.get(settings); this.licenseState = licenseState; } @@ -44,7 +41,7 @@ public boolean available() { @Override public boolean enabled() { - return enabled; + return true; } } diff --git a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java index e03cc822ec746..4dc385392a6be 100644 --- a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java +++ b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java @@ -25,7 +25,6 @@ public class LogstashUsageTransportAction extends XPackUsageFeatureTransportAction { - private final Settings settings; private final XPackLicenseState licenseState; @Inject @@ -46,7 +45,6 @@ public LogstashUsageTransportAction( actionFilters, indexNameExpressionResolver ); - this.settings = settings; this.licenseState = licenseState; } @@ -58,7 +56,7 @@ protected void masterOperation( ActionListener listener ) { boolean available = licenseState.isLogstashAllowed(); - LogstashFeatureSetUsage usage = new LogstashFeatureSetUsage(available, XPackSettings.LOGSTASH_ENABLED.get(settings)); + LogstashFeatureSetUsage usage = new LogstashFeatureSetUsage(available, true); listener.onResponse(new XPackUsageFeatureResponse(usage)); } } diff --git a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java index e3872352b944d..e4cf27ee0f344 100644 --- a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java +++ b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java @@ -33,7 +33,7 @@ public void testEnabledSetting() throws Exception { settings, null ); - assertThat(featureSet.enabled(), is(enabled)); + assertThat(featureSet.enabled(), is(true)); LogstashUsageTransportAction usageAction = newUsageAction(settings, false); PlainActionFuture future = new PlainActionFuture<>(); @@ -44,8 +44,6 @@ public void testEnabledSetting() throws Exception { usage.writeTo(out); XPackFeatureSet.Usage serializedUsage = new LogstashFeatureSetUsage(out.bytes().streamInput()); assertThat(serializedUsage.enabled(), is(enabled)); - - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.LOGSTASH_ENABLED }); } public void testEnabledDefault() throws Exception { From 64aaccde3bc91ddbcb66c3a90e4432ef74a5302b Mon Sep 17 00:00:00 2001 From: William Brafford Date: Wed, 15 Apr 2020 16:30:39 -0400 Subject: [PATCH 04/18] Make xpack.slm.enabled a no-op --- .../xpack/core/XPackSettings.java | 2 ++ .../xpack/ilm/IndexLifecycle.java | 32 ++++++++----------- .../xpack/slm/SLMInfoTransportAction.java | 5 +-- .../xpack/slm/SLMUsageTransportAction.java | 5 +-- .../SnapshotLifecycleInitialisationTests.java | 2 -- .../AbstractWatcherIntegrationTestCase.java | 9 ++++-- 6 files changed, 24 insertions(+), 31 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java index 0b3033fc9fccc..3c80acd6a1313 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java @@ -97,6 +97,8 @@ private XPackSettings() { /** * Setting for enabling or disabling the snapshot lifecycle extension. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. */ public static final Setting SNAPSHOT_LIFECYCLE_ENABLED = Setting.boolSetting("xpack.slm.enabled", true, Property.NodeScope, Property.Deprecated); diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java index 0c88f768a7c9e..bf5d296a7c541 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycle.java @@ -143,12 +143,10 @@ public class IndexLifecycle extends Plugin implements ActionPlugin { private final SetOnce snapshotHistoryStore = new SetOnce<>(); private Settings settings; private boolean ilmEnabled; - private boolean slmEnabled; public IndexLifecycle(Settings settings) { this.settings = settings; this.ilmEnabled = XPackSettings.INDEX_LIFECYCLE_ENABLED.get(settings); - this.slmEnabled = XPackSettings.SNAPSHOT_LIFECYCLE_ENABLED.get(settings); } // overridable by tests @@ -191,20 +189,18 @@ public Collection createComponents(Client client, ClusterService cluster getClock(), System::currentTimeMillis, xContentRegistry, ilmHistoryStore.get())); components.add(indexLifecycleInitialisationService.get()); } - if (slmEnabled) { - // the template registry is a cluster state listener - @SuppressWarnings("unused") - SnapshotLifecycleTemplateRegistry templateRegistry = new SnapshotLifecycleTemplateRegistry(settings, clusterService, threadPool, - client, xContentRegistry); - snapshotHistoryStore.set(new SnapshotHistoryStore(settings, new OriginSettingClient(client, INDEX_LIFECYCLE_ORIGIN), - clusterService)); - snapshotLifecycleService.set(new SnapshotLifecycleService(settings, - () -> new SnapshotLifecycleTask(client, clusterService, snapshotHistoryStore.get()), clusterService, getClock())); - snapshotRetentionService.set(new SnapshotRetentionService(settings, - () -> new SnapshotRetentionTask(client, clusterService, System::nanoTime, snapshotHistoryStore.get(), threadPool), - clusterService, getClock())); - components.addAll(Arrays.asList(snapshotLifecycleService.get(), snapshotHistoryStore.get(), snapshotRetentionService.get())); - } + // the template registry is a cluster state listener + @SuppressWarnings("unused") + SnapshotLifecycleTemplateRegistry templateRegistry = new SnapshotLifecycleTemplateRegistry(settings, clusterService, threadPool, + client, xContentRegistry); + snapshotHistoryStore.set(new SnapshotHistoryStore(settings, new OriginSettingClient(client, INDEX_LIFECYCLE_ORIGIN), + clusterService)); + snapshotLifecycleService.set(new SnapshotLifecycleService(settings, + () -> new SnapshotLifecycleTask(client, clusterService, snapshotHistoryStore.get()), clusterService, getClock())); + snapshotRetentionService.set(new SnapshotRetentionService(settings, + () -> new SnapshotRetentionTask(client, clusterService, System::nanoTime, snapshotHistoryStore.get(), threadPool), + clusterService, getClock())); + components.addAll(Arrays.asList(snapshotLifecycleService.get(), snapshotHistoryStore.get(), snapshotRetentionService.get())); return components; } @@ -260,7 +256,7 @@ public List getRestHandlers(Settings settings, RestController restC new RestGetStatusAction() )); } - if (slmEnabled) { + if (true) { handlers.addAll(Arrays.asList( new RestPutSnapshotLifecycleAction(), new RestDeleteSnapshotLifecycleAction(), @@ -301,7 +297,7 @@ public List getRestHandlers(Settings settings, RestController restC new ActionHandler<>(GetStatusAction.INSTANCE, TransportGetStatusAction.class) )); } - if (slmEnabled) { + if (true) { actions.addAll(Arrays.asList( new ActionHandler<>(PutSnapshotLifecycleAction.INSTANCE, TransportPutSnapshotLifecycleAction.class), new ActionHandler<>(DeleteSnapshotLifecycleAction.INSTANCE, TransportDeleteSnapshotLifecycleAction.class), diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMInfoTransportAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMInfoTransportAction.java index 4e42967052544..146ac1354d963 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMInfoTransportAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMInfoTransportAction.java @@ -12,19 +12,16 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; import org.elasticsearch.xpack.core.action.XPackInfoFeatureTransportAction; public class SLMInfoTransportAction extends XPackInfoFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject public SLMInfoTransportAction(TransportService transportService, ActionFilters actionFilters, Settings settings, XPackLicenseState licenseState) { super(XPackInfoFeatureAction.SNAPSHOT_LIFECYCLE.name(), transportService, actionFilters); - this.enabled = XPackSettings.SNAPSHOT_LIFECYCLE_ENABLED.get(settings); this.licenseState = licenseState; } @@ -40,6 +37,6 @@ public boolean available() { @Override public boolean enabled() { - return enabled; + return true; } } diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java index 14e8a4feb270d..fca0329c2399d 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java @@ -18,7 +18,6 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; import org.elasticsearch.xpack.core.action.XPackUsageFeatureTransportAction; @@ -26,7 +25,6 @@ import org.elasticsearch.xpack.core.slm.SnapshotLifecycleMetadata; public class SLMUsageTransportAction extends XPackUsageFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject @@ -35,7 +33,6 @@ public SLMUsageTransportAction(TransportService transportService, ClusterService Settings settings, XPackLicenseState licenseState) { super(XPackUsageFeatureAction.SNAPSHOT_LIFECYCLE.name(), transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver); - this.enabled = XPackSettings.SNAPSHOT_LIFECYCLE_ENABLED.get(settings); this.licenseState = licenseState; } @@ -44,7 +41,7 @@ protected void masterOperation(Task task, XPackUsageRequest request, ClusterStat ActionListener listener) { boolean available = licenseState.isIndexLifecycleAllowed(); final SnapshotLifecycleMetadata slmMeta = state.metadata().custom(SnapshotLifecycleMetadata.TYPE); - final SLMFeatureSetUsage usage = new SLMFeatureSetUsage(available, enabled, + final SLMFeatureSetUsage usage = new SLMFeatureSetUsage(available, true, slmMeta == null ? null : slmMeta.getStats()); listener.onResponse(new XPackUsageFeatureResponse(usage)); } diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SnapshotLifecycleInitialisationTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SnapshotLifecycleInitialisationTests.java index 2b00d962bdce7..0de4a5ce41b3a 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SnapshotLifecycleInitialisationTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SnapshotLifecycleInitialisationTests.java @@ -51,8 +51,6 @@ protected Settings nodeSettings() { settings.put(XPackSettings.MONITORING_ENABLED.getKey(), false); settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); settings.put(Environment.PATH_REPO_SETTING.getKey(), repositoryLocation); - - settings.put(XPackSettings.SNAPSHOT_LIFECYCLE_ENABLED.getKey(), true); return settings.build(); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java index ab1c6e295fcbd..fa8875e942d0b 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -96,6 +96,12 @@ import static org.hamcrest.core.IsNot.not; import static org.mockito.Mockito.mock; +/** + * Base class for Watcher integration tests + * + * Note that SLM has been observed to cause timing issues during testsuite teardown: + * https://github.com/elastic/elasticsearch/issues/50302 + */ @ClusterScope(scope = SUITE, numClientNodes = 0, maxNumDataNodes = 3) public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase { @@ -116,9 +122,6 @@ protected Settings nodeSettings(int nodeOrdinal) { .put("xpack.watcher.execution.scroll.size", randomIntBetween(1, 100)) .put("xpack.watcher.watch.scroll.size", randomIntBetween(1, 100)) .put("indices.lifecycle.history_index_enabled", false) - // SLM can cause timing issues during testsuite teardown: https://github.com/elastic/elasticsearch/issues/50302 - // SLM is not required for tests extending from this base class and only add noise. - .put("xpack.slm.enabled", false) .build(); } From e4b67bddfa374ae2ce64ae4d2e2bbf76e6781a3b Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 16 Apr 2020 11:22:00 -0400 Subject: [PATCH 05/18] Deprecation annotations and javadoc --- .../elasticsearch/xpack/core/XPackSettings.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java index 3c80acd6a1313..fe745649550f7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java @@ -53,6 +53,7 @@ private XPackSettings() { *

* This setting is now a no-op: setting it to false is permitted, but does nothing. */ + @Deprecated(since = "7.8.0") public static final Setting TRANSFORM_ENABLED = Setting.boolSetting("xpack.transform.enabled", true, Property.NodeScope, Property.Deprecated); @@ -73,7 +74,12 @@ private XPackSettings() { public static final Setting MACHINE_LEARNING_ENABLED = Setting.boolSetting("xpack.ml.enabled", true, Setting.Property.NodeScope); - /** Setting for enabling or disabling rollup. Defaults to true. */ + /** + * Setting for enabling or disabling rollup. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. + */ + @Deprecated(since = "7.8.0") public static final Setting ROLLUP_ENABLED = Setting.boolSetting("xpack.rollup.enabled", true, Property.NodeScope, Property.Deprecated); @@ -85,7 +91,12 @@ private XPackSettings() { public static final Setting DLS_FLS_ENABLED = Setting.boolSetting("xpack.security.dls_fls.enabled", true, Setting.Property.NodeScope); - /** Setting for enabling or disabling Logstash extensions. Defaults to true. */ + /** + * Setting for enabling or disabling Logstash extensions. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. + */ + @Deprecated(since = "7.8.0") public static final Setting LOGSTASH_ENABLED = Setting.boolSetting("xpack.logstash.enabled", true, Setting.Property.NodeScope, Property.Deprecated); @@ -100,6 +111,7 @@ private XPackSettings() { *

* This setting is now a no-op: setting it to false is permitted, but does nothing. */ + @Deprecated(since = "7.8.0") public static final Setting SNAPSHOT_LIFECYCLE_ENABLED = Setting.boolSetting("xpack.slm.enabled", true, Property.NodeScope, Property.Deprecated); From 1be3458e1fd19657a84a8628869906fa452e855e Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 16 Apr 2020 11:55:18 -0400 Subject: [PATCH 06/18] Make xpack.sql.enabled a no-op and remove imports --- .../xpack/core/XPackSettings.java | 7 ++- .../eql/action/AbstractEqlIntegTestCase.java | 1 - .../LogstashUsageTransportAction.java | 1 - .../LogstashInfoTransportActionTests.java | 2 - .../rollup/RollupInfoTransportAction.java | 1 - .../rollup/RollupUsageTransportAction.java | 1 - .../RollupInfoTransportActionTests.java | 2 - .../xpack/sql/SqlInfoTransportAction.java | 9 ++-- .../xpack/sql/SqlUsageTransportAction.java | 33 ++++++-------- .../xpack/sql/plugin/SqlPlugin.java | 15 ------- .../sql/SqlInfoTransportActionTests.java | 10 +---- .../xpack/sql/action/SqlDisabledIT.java | 43 ------------------- .../xpack/sql/plugin/SqlPluginTests.java | 20 ++++----- 13 files changed, 31 insertions(+), 114 deletions(-) delete mode 100644 x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/action/SqlDisabledIT.java diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java index fe745649550f7..7a0fa24a8f22e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java @@ -139,7 +139,12 @@ private XPackSettings() { public static final Setting FIPS_MODE_ENABLED = Setting.boolSetting("xpack.security.fips_mode.enabled", false, Property.NodeScope); - /** Setting for enabling or disabling sql. Defaults to true. */ + /** + * Setting for enabling or disabling sql. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. + */ + @Deprecated(since = "7.8.0") public static final Setting SQL_ENABLED = Setting.boolSetting("xpack.sql.enabled", true, Property.NodeScope, Property.Deprecated); diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java index b6a2c28533b8e..8b9b1eadb91b8 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/AbstractEqlIntegTestCase.java @@ -29,7 +29,6 @@ protected Settings nodeSettings(int nodeOrdinal) { settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false); - settings.put(XPackSettings.SQL_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/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java index 4dc385392a6be..3b9d9fbe0de32 100644 --- a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java +++ b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java @@ -17,7 +17,6 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; import org.elasticsearch.xpack.core.action.XPackUsageFeatureTransportAction; diff --git a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java index e4cf27ee0f344..69923ead356d0 100644 --- a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java +++ b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java @@ -8,13 +8,11 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.io.stream.BytesStreamOutput; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackFeatureSet; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; import org.elasticsearch.xpack.core.logstash.LogstashFeatureSetUsage; diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java index 00fd2d1382e7b..dd4bb82e10069 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java @@ -11,7 +11,6 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; import org.elasticsearch.xpack.core.action.XPackInfoFeatureTransportAction; diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java index f85ed2d338b24..9bbd370e3bc91 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java @@ -17,7 +17,6 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; import org.elasticsearch.xpack.core.action.XPackUsageFeatureTransportAction; diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java index 5a0b15166ffc0..f6e6dc653c66e 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java @@ -8,13 +8,11 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.io.stream.BytesStreamOutput; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackFeatureSet; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; import org.elasticsearch.xpack.core.rollup.RollupFeatureSetUsage; import org.junit.Before; diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlInfoTransportAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlInfoTransportAction.java index 45a076f251273..23c103a5b98f3 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlInfoTransportAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlInfoTransportAction.java @@ -11,23 +11,20 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; import org.elasticsearch.xpack.core.action.XPackInfoFeatureTransportAction; public class SqlInfoTransportAction extends XPackInfoFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; - + @Inject public SqlInfoTransportAction(TransportService transportService, ActionFilters actionFilters, Settings settings, XPackLicenseState licenseState) { super(XPackInfoFeatureAction.SQL.name(), transportService, actionFilters); - this.enabled = XPackSettings.SQL_ENABLED.get(settings); this.licenseState = licenseState; } - + @Override public String name() { return XPackField.SQL; @@ -40,7 +37,7 @@ public boolean available() { @Override public boolean enabled() { - return enabled; + return true; } } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java index 3114f263eee29..9f5939846249f 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java @@ -18,7 +18,6 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; import org.elasticsearch.xpack.core.action.XPackUsageFeatureTransportAction; @@ -28,13 +27,11 @@ import org.elasticsearch.xpack.sql.plugin.SqlStatsRequest; import org.elasticsearch.xpack.sql.plugin.SqlStatsResponse; -import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; public class SqlUsageTransportAction extends XPackUsageFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; private final Client client; @@ -44,7 +41,6 @@ public SqlUsageTransportAction(TransportService transportService, ClusterService Settings settings, XPackLicenseState licenseState, Client client) { super(XPackUsageFeatureAction.SQL.name(), transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver); - this.enabled = XPackSettings.SQL_ENABLED.get(settings); this.licenseState = licenseState; this.client = client; } @@ -53,23 +49,18 @@ public SqlUsageTransportAction(TransportService transportService, ClusterService protected void masterOperation(Task task, XPackUsageRequest request, ClusterState state, ActionListener listener) { boolean available = licenseState.isSqlAllowed(); - if (enabled) { - SqlStatsRequest sqlRequest = new SqlStatsRequest(); - sqlRequest.includeStats(true); - sqlRequest.setParentTask(clusterService.localNode().getId(), task.getId()); - client.execute(SqlStatsAction.INSTANCE, sqlRequest, ActionListener.wrap(r -> { - List countersPerNode = r.getNodes() - .stream() - .map(SqlStatsResponse.NodeStatsResponse::getStats) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - Counters mergedCounters = Counters.merge(countersPerNode); - SqlFeatureSetUsage usage = new SqlFeatureSetUsage(available, enabled, mergedCounters.toNestedMap()); - listener.onResponse(new XPackUsageFeatureResponse(usage)); - }, listener::onFailure)); - } else { - SqlFeatureSetUsage usage = new SqlFeatureSetUsage(available, enabled, Collections.emptyMap()); + SqlStatsRequest sqlRequest = new SqlStatsRequest(); + sqlRequest.includeStats(true); + sqlRequest.setParentTask(clusterService.localNode().getId(), task.getId()); + client.execute(SqlStatsAction.INSTANCE, sqlRequest, ActionListener.wrap(r -> { + List countersPerNode = r.getNodes() + .stream() + .map(SqlStatsResponse.NodeStatsResponse::getStats) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + Counters mergedCounters = Counters.merge(countersPerNode); + SqlFeatureSetUsage usage = new SqlFeatureSetUsage(available, true, mergedCounters.toNestedMap()); listener.onResponse(new XPackUsageFeatureResponse(usage)); - } + }, listener::onFailure)); } } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java index 00fbb1ba9ab87..3572ab7607ecf 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java @@ -31,7 +31,6 @@ import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.core.XPackField; import org.elasticsearch.xpack.core.XPackPlugin; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; import org.elasticsearch.xpack.ql.index.IndexResolver; @@ -48,11 +47,8 @@ import java.util.List; import java.util.function.Supplier; -import static java.util.Collections.emptyList; - public class SqlPlugin extends Plugin implements ActionPlugin { - private final boolean enabled; private final SqlLicenseChecker sqlLicenseChecker = new SqlLicenseChecker( (mode) -> { XPackLicenseState licenseState = getLicenseState(); @@ -80,7 +76,6 @@ public class SqlPlugin extends Plugin implements ActionPlugin { ); public SqlPlugin(Settings settings) { - this.enabled = XPackSettings.SQL_ENABLED.get(settings); } // overridable by tests @@ -101,9 +96,6 @@ public Collection createComponents(Client client, ClusterService cluster * Create components used by the sql plugin. */ Collection createComponents(Client client, String clusterName, NamedWriteableRegistry namedWriteableRegistry) { - if (false == enabled) { - return emptyList(); - } IndexResolver indexResolver = new IndexResolver(client, clusterName, SqlDataTypeRegistry.INSTANCE); return Arrays.asList(sqlLicenseChecker, indexResolver, new PlanExecutor(client, indexResolver, namedWriteableRegistry)); } @@ -114,10 +106,6 @@ public List getRestHandlers(Settings settings, RestController restC SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver, Supplier nodesInCluster) { - if (false == enabled) { - return emptyList(); - } - return Arrays.asList(new RestSqlQueryAction(), new RestSqlTranslateAction(), new RestSqlClearCursorAction(), @@ -128,9 +116,6 @@ public List getRestHandlers(Settings settings, RestController restC public List> getActions() { var usageAction = new ActionHandler<>(XPackUsageFeatureAction.SQL, SqlUsageTransportAction.class); var infoAction = new ActionHandler<>(XPackInfoFeatureAction.SQL, SqlInfoTransportAction.class); - if (false == enabled) { - return Arrays.asList(usageAction, infoAction); - } return Arrays.asList(new ActionHandler<>(SqlQueryAction.INSTANCE, TransportSqlQueryAction.class), new ActionHandler<>(SqlTranslateAction.INSTANCE, TransportSqlTranslateAction.class), diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlInfoTransportActionTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlInfoTransportActionTests.java index 2419dfb188aee..d9a601c6a97f2 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlInfoTransportActionTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlInfoTransportActionTests.java @@ -13,7 +13,6 @@ import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.xcontent.ObjectPath; @@ -22,7 +21,6 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; import org.elasticsearch.xpack.core.sql.SqlFeatureSetUsage; import org.elasticsearch.xpack.core.watcher.common.stats.Counters; @@ -68,22 +66,16 @@ public void testAvailable() { public void testEnabled() { boolean enabled = randomBoolean(); Settings.Builder settings = Settings.builder(); - boolean isExplicitlySet = false; if (enabled) { if (randomBoolean()) { settings.put("xpack.sql.enabled", enabled); - isExplicitlySet = true; } } else { settings.put("xpack.sql.enabled", enabled); - isExplicitlySet = true; } SqlInfoTransportAction featureSet = new SqlInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), settings.build(), licenseState); - assertThat(featureSet.enabled(), is(enabled)); - if (isExplicitlySet) { - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.SQL_ENABLED } ); - } + assertThat(featureSet.enabled(), is(true)); } @SuppressWarnings("unchecked") diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/action/SqlDisabledIT.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/action/SqlDisabledIT.java deleted file mode 100644 index dcce3f5586453..0000000000000 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/action/SqlDisabledIT.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.action; - -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin; -import org.elasticsearch.xpack.core.XPackSettings; - -import java.util.Collection; -import java.util.Collections; - -import static org.hamcrest.CoreMatchers.either; -import static org.hamcrest.CoreMatchers.startsWith; - -public class SqlDisabledIT extends AbstractSqlIntegTestCase { - - @Override - protected Collection> nodePlugins() { - return Collections.singletonList(LocalStateCompositeXPackPlugin.class); - } - - @Override - protected Settings nodeSettings(int nodeOrdinal) { - return Settings.builder() - .put(super.nodeSettings(nodeOrdinal)) - .put(XPackSettings.SQL_ENABLED.getKey(), false) - .build(); - } - - public void testSqlAction() { - Throwable throwable = expectThrows(Throwable.class, - () -> new SqlQueryRequestBuilder(client(), SqlQueryAction.INSTANCE).query("SHOW tables").get()); - assertThat(throwable.getMessage(), - either(startsWith("no proxy found for action")) // disabled on client - .or(startsWith("failed to find action")) // disabled on proxy client - .or(startsWith("No handler for action [indices:data/read/sql]"))); // disabled on server - } -} - diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlPluginTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlPluginTests.java index a316e961847a0..e89129a87fd4a 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlPluginTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlPluginTests.java @@ -11,32 +11,30 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.IndexScopedSettings; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsFilter; import org.elasticsearch.rest.RestController; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.sql.session.Cursors; import java.util.Collections; -import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasSize; import static org.mockito.Mockito.mock; public class SqlPluginTests extends ESTestCase { - public void testSqlDisabled() { + public void testSqlDisabledIsNoOp() { Settings settings = Settings.builder().put("xpack.sql.enabled", false).build(); SqlPlugin plugin = new SqlPlugin(settings); assertThat(plugin.createComponents(mock(Client.class), "cluster", new NamedWriteableRegistry(Cursors.getNamedWriteables())), - empty()); - assertThat(plugin.getActions(), hasSize(2)); // usage action - assertThat(plugin.getRestHandlers(Settings.EMPTY, mock(RestController.class), - new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), - IndexScopedSettings.DEFAULT_SCOPED_SETTINGS, new SettingsFilter(Collections.emptyList()), - mock(IndexNameExpressionResolver.class), () -> mock(DiscoveryNodes.class)), empty()); - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.SQL_ENABLED } ); + hasSize(3)); + assertThat(plugin.getActions(), hasSize(6)); + assertThat( + plugin.getRestHandlers(Settings.EMPTY, mock(RestController.class), + new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), + IndexScopedSettings.DEFAULT_SCOPED_SETTINGS, new SettingsFilter(Collections.emptyList()), + mock(IndexNameExpressionResolver.class), () -> mock(DiscoveryNodes.class)), + hasSize(4)); } } From fa74c45954f727664aa135c07a10521b1aca280d Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 16 Apr 2020 11:58:15 -0400 Subject: [PATCH 07/18] Make xpack.flattened.enabled a no-op --- .../java/org/elasticsearch/xpack/core/XPackSettings.java | 7 ++++++- .../xpack/flattened/FlattenedMapperPlugin.java | 8 -------- x-pack/plugin/sql/qa/no-sql/build.gradle | 1 - 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java index 7a0fa24a8f22e..4d5137dcb1427 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java @@ -148,7 +148,12 @@ private XPackSettings() { public static final Setting SQL_ENABLED = Setting.boolSetting("xpack.sql.enabled", true, Property.NodeScope, Property.Deprecated); - /** Setting for enabling or disabling flattened fields. Defaults to true. */ + /** + * Setting for enabling or disabling flattened fields. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. + */ + @Deprecated(since = "7.8.0") public static final Setting FLATTENED_ENABLED = Setting.boolSetting("xpack.flattened.enabled", true, Property.NodeScope, Property.Deprecated); diff --git a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java index a74f7c5a87799..6dcd5da2d8017 100644 --- a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java +++ b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java @@ -10,27 +10,19 @@ import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.plugins.MapperPlugin; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.flattened.mapper.FlatObjectFieldMapper; import java.util.Map; -import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; public class FlattenedMapperPlugin extends Plugin implements MapperPlugin { - protected final boolean enabled; - public FlattenedMapperPlugin(Settings settings) { - this.enabled = XPackSettings.FLATTENED_ENABLED.get(settings); } @Override public Map getMappers() { - if (enabled == false) { - return emptyMap(); - } return singletonMap(FlatObjectFieldMapper.CONTENT_TYPE, new FlatObjectFieldMapper.TypeParser()); } } diff --git a/x-pack/plugin/sql/qa/no-sql/build.gradle b/x-pack/plugin/sql/qa/no-sql/build.gradle index d0f8a3007c4be..137ffed68ad52 100644 --- a/x-pack/plugin/sql/qa/no-sql/build.gradle +++ b/x-pack/plugin/sql/qa/no-sql/build.gradle @@ -1,5 +1,4 @@ testClusters.integTest { setting 'xpack.security.enabled', 'false' - setting 'xpack.sql.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' } From ddc7236a15f3789994ba2d3449dce1a9a3befae5 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 16 Apr 2020 12:03:42 -0400 Subject: [PATCH 08/18] Make xpack.vectors.enabled a no-op --- .../elasticsearch/xpack/core/XPackSettings.java | 7 ++++++- .../org/elasticsearch/xpack/vectors/Vectors.java | 9 --------- .../xpack/vectors/VectorsInfoTransportAction.java | 5 +---- .../xpack/vectors/VectorsUsageTransportAction.java | 5 ++--- .../vectors/VectorsInfoTransportActionTests.java | 14 ++++---------- 5 files changed, 13 insertions(+), 27 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java index 4d5137dcb1427..6f2f8030ab7f6 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java @@ -157,7 +157,12 @@ private XPackSettings() { public static final Setting FLATTENED_ENABLED = Setting.boolSetting("xpack.flattened.enabled", true, Property.NodeScope, Property.Deprecated); - /** Setting for enabling or disabling vectors. Defaults to true. */ + /** + * Setting for enabling or disabling vectors. Defaults to true. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. + */ + @Deprecated(since = "7.8.0") public static final Setting VECTORS_ENABLED = Setting.boolSetting("xpack.vectors.enabled", true, Property.NodeScope, Property.Deprecated); diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java index 6e714984077ca..39402c186cc03 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java @@ -13,7 +13,6 @@ import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.MapperPlugin; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; import org.elasticsearch.xpack.vectors.mapper.DenseVectorFieldMapper; @@ -25,14 +24,9 @@ import java.util.List; import java.util.Map; -import static java.util.Collections.emptyMap; - public class Vectors extends Plugin implements MapperPlugin, ActionPlugin { - protected final boolean enabled; - public Vectors(Settings settings) { - this.enabled = XPackSettings.VECTORS_ENABLED.get(settings); } @Override @@ -44,9 +38,6 @@ public Vectors(Settings settings) { @Override public Map getMappers() { - if (enabled == false) { - return emptyMap(); - } Map mappers = new LinkedHashMap<>(); mappers.put(DenseVectorFieldMapper.CONTENT_TYPE, new DenseVectorFieldMapper.TypeParser()); mappers.put(SparseVectorFieldMapper.CONTENT_TYPE, new SparseVectorFieldMapper.TypeParser()); diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportAction.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportAction.java index 7974b6ec246f3..5e22e04c5ba5f 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportAction.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportAction.java @@ -11,20 +11,17 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; import org.elasticsearch.xpack.core.action.XPackInfoFeatureTransportAction; public class VectorsInfoTransportAction extends XPackInfoFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject public VectorsInfoTransportAction(TransportService transportService, ActionFilters actionFilters, Settings settings, XPackLicenseState licenseState) { super(XPackInfoFeatureAction.VECTORS.name(), transportService, actionFilters); - this.enabled = XPackSettings.VECTORS_ENABLED.get(settings); this.licenseState = licenseState; } @@ -40,7 +37,7 @@ public boolean available() { @Override public boolean enabled() { - return enabled; + return true; } } diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java index aaa1ad48e6a15..67f39b87cefe1 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java @@ -48,12 +48,11 @@ public VectorsUsageTransportAction(TransportService transportService, ClusterSer protected void masterOperation(Task task, XPackUsageRequest request, ClusterState state, ActionListener listener) { boolean vectorsAvailable = licenseState.isVectorsAllowed(); - boolean vectorsEnabled = XPackSettings.VECTORS_ENABLED.get(settings); int numDenseVectorFields = 0; int numSparseVectorFields = 0; int avgDenseVectorDims = 0; - if (vectorsAvailable && vectorsEnabled && state != null) { + if (vectorsAvailable && state != null) { for (IndexMetadata indexMetadata : state.metadata()) { MappingMetadata mappingMetadata = indexMetadata.mapping(); if (mappingMetadata != null) { @@ -81,7 +80,7 @@ protected void masterOperation(Task task, XPackUsageRequest request, ClusterStat } } VectorsFeatureSetUsage usage = - new VectorsFeatureSetUsage(vectorsAvailable, vectorsEnabled, numDenseVectorFields, avgDenseVectorDims); + new VectorsFeatureSetUsage(vectorsAvailable, true, numDenseVectorFields, avgDenseVectorDims); listener.onResponse(new XPackUsageFeatureResponse(usage)); } } diff --git a/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportActionTests.java b/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportActionTests.java index af3a0c2b7e0a0..ae67acf9d195d 100644 --- a/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportActionTests.java +++ b/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportActionTests.java @@ -52,37 +52,31 @@ public void testAvailable() throws Exception { assertThat(serializedUsage.available(), is(available)); } - public void testEnabled() throws Exception { + public void testAlwaysEnabled() throws Exception { boolean enabled = randomBoolean(); - boolean isExplicitlySet = false; Settings.Builder settings = Settings.builder(); if (enabled) { if (randomBoolean()) { settings.put("xpack.vectors.enabled", enabled); - isExplicitlySet = true; } } else { settings.put("xpack.vectors.enabled", enabled); - isExplicitlySet = true; } VectorsInfoTransportAction featureSet = new VectorsInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), settings.build(), licenseState); - assertThat(featureSet.enabled(), is(enabled)); + assertThat(featureSet.enabled(), is(true)); VectorsUsageTransportAction usageAction = new VectorsUsageTransportAction(mock(TransportService.class), null, null, mock(ActionFilters.class), null, settings.build(), licenseState); PlainActionFuture future = new PlainActionFuture<>(); usageAction.masterOperation(null, null, null, future); XPackFeatureSet.Usage usage = future.get().getUsage(); - assertThat(usage.enabled(), is(enabled)); + assertThat(usage.enabled(), is(true)); BytesStreamOutput out = new BytesStreamOutput(); usage.writeTo(out); XPackFeatureSet.Usage serializedUsage = new VectorsFeatureSetUsage(out.bytes().streamInput()); - assertThat(serializedUsage.enabled(), is(enabled)); - if (isExplicitlySet) { - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.VECTORS_ENABLED} ); - } + assertThat(serializedUsage.enabled(), is(true)); } } From a1bd525821ed8f54a1f306c83b56354187884df6 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 16 Apr 2020 12:35:19 -0400 Subject: [PATCH 09/18] Remove or deprecate useless settings params --- .../xpack/slm/SLMInfoTransportAction.java | 2 +- .../xpack/slm/SLMUsageTransportAction.java | 2 +- .../logstash/LogstashInfoTransportAction.java | 1 - .../logstash/LogstashUsageTransportAction.java | 1 - .../LogstashInfoTransportActionTests.java | 16 ++++++---------- .../xpack/flattened/FlattenedMapperPlugin.java | 3 +-- .../xpack/rollup/RollupInfoTransportAction.java | 2 +- .../xpack/rollup/RollupUsageTransportAction.java | 2 +- .../rollup/RollupInfoTransportActionTests.java | 2 +- .../xpack/sql/SqlInfoTransportAction.java | 2 +- .../xpack/sql/SqlUsageTransportAction.java | 2 +- .../xpack/sql/SqlInfoTransportActionTests.java | 2 +- .../transform/TransformInfoTransportAction.java | 2 +- .../transform/TransformUsageTransportAction.java | 1 - .../org/elasticsearch/xpack/vectors/Vectors.java | 3 +-- .../vectors/VectorsInfoTransportAction.java | 2 +- .../vectors/VectorsUsageTransportAction.java | 4 +--- 17 files changed, 19 insertions(+), 30 deletions(-) diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMInfoTransportAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMInfoTransportAction.java index 146ac1354d963..16f9e608f7f7a 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMInfoTransportAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMInfoTransportAction.java @@ -20,7 +20,7 @@ public class SLMInfoTransportAction extends XPackInfoFeatureTransportAction { @Inject public SLMInfoTransportAction(TransportService transportService, ActionFilters actionFilters, - Settings settings, XPackLicenseState licenseState) { + XPackLicenseState licenseState) { super(XPackInfoFeatureAction.SNAPSHOT_LIFECYCLE.name(), transportService, actionFilters); this.licenseState = licenseState; } diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java index fca0329c2399d..dc635f228f19e 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java @@ -30,7 +30,7 @@ public class SLMUsageTransportAction extends XPackUsageFeatureTransportAction { @Inject public SLMUsageTransportAction(TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - Settings settings, XPackLicenseState licenseState) { + XPackLicenseState licenseState) { super(XPackUsageFeatureAction.SNAPSHOT_LIFECYCLE.name(), transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver); this.licenseState = licenseState; diff --git a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportAction.java b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportAction.java index 64e3d9a26572e..26b341a54c057 100644 --- a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportAction.java +++ b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportAction.java @@ -22,7 +22,6 @@ public class LogstashInfoTransportAction extends XPackInfoFeatureTransportAction public LogstashInfoTransportAction( TransportService transportService, ActionFilters actionFilters, - Settings settings, XPackLicenseState licenseState ) { super(XPackInfoFeatureAction.LOGSTASH.name(), transportService, actionFilters); diff --git a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java index 3b9d9fbe0de32..b4bbd2e846cf9 100644 --- a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java +++ b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java @@ -33,7 +33,6 @@ public LogstashUsageTransportAction( ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - Settings settings, XPackLicenseState licenseState ) { super( diff --git a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java index 69923ead356d0..c82f583826acf 100644 --- a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java +++ b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java @@ -28,12 +28,11 @@ public void testEnabledSetting() throws Exception { LogstashInfoTransportAction featureSet = new LogstashInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), - settings, - null + null ); assertThat(featureSet.enabled(), is(true)); - LogstashUsageTransportAction usageAction = newUsageAction(settings, false); + LogstashUsageTransportAction usageAction = newUsageAction(false); PlainActionFuture future = new PlainActionFuture<>(); usageAction.masterOperation(null, null, null, future); XPackFeatureSet.Usage usage = future.get().getUsage(); @@ -49,8 +48,7 @@ public void testEnabledDefault() throws Exception { LogstashInfoTransportAction featureSet = new LogstashInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), - settings, - null + null ); assertThat(featureSet.enabled(), is(true)); } @@ -60,14 +58,13 @@ public void testAvailable() throws Exception { LogstashInfoTransportAction featureSet = new LogstashInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), - Settings.EMPTY, - licenseState + licenseState ); boolean available = randomBoolean(); when(licenseState.isLogstashAllowed()).thenReturn(available); assertThat(featureSet.available(), is(available)); - var usageAction = newUsageAction(Settings.EMPTY, available); + var usageAction = newUsageAction(available); PlainActionFuture future = new PlainActionFuture<>(); usageAction.masterOperation(null, null, null, future); XPackFeatureSet.Usage usage = future.get().getUsage(); @@ -79,7 +76,7 @@ public void testAvailable() throws Exception { assertThat(serializedUsage.available(), is(available)); } - private LogstashUsageTransportAction newUsageAction(Settings settings, boolean available) { + private LogstashUsageTransportAction newUsageAction(boolean available) { XPackLicenseState licenseState = mock(XPackLicenseState.class); when(licenseState.isLogstashAllowed()).thenReturn(available); return new LogstashUsageTransportAction( @@ -88,7 +85,6 @@ private LogstashUsageTransportAction newUsageAction(Settings settings, boolean a null, mock(ActionFilters.class), null, - settings, licenseState ); } diff --git a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java index 6dcd5da2d8017..50e7ab33e134f 100644 --- a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java +++ b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java @@ -18,8 +18,7 @@ public class FlattenedMapperPlugin extends Plugin implements MapperPlugin { - public FlattenedMapperPlugin(Settings settings) { - } + public FlattenedMapperPlugin() { } @Override public Map getMappers() { diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java index dd4bb82e10069..0d5aff01e7ae6 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java @@ -20,7 +20,7 @@ public class RollupInfoTransportAction extends XPackInfoFeatureTransportAction { @Inject public RollupInfoTransportAction(TransportService transportService, ActionFilters actionFilters, - Settings settings, XPackLicenseState licenseState) { + @Deprecated Settings settings, XPackLicenseState licenseState) { super(XPackInfoFeatureAction.ROLLUP.name(), transportService, actionFilters); this.licenseState = licenseState; } diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java index 9bbd370e3bc91..29d49fd257f81 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java @@ -29,7 +29,7 @@ public class RollupUsageTransportAction extends XPackUsageFeatureTransportAction @Inject public RollupUsageTransportAction(TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - Settings settings, XPackLicenseState licenseState) { + XPackLicenseState licenseState) { super(XPackUsageFeatureAction.ROLLUP.name(), transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver); this.licenseState = licenseState; diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java index f6e6dc653c66e..8e927ceff45c5 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java @@ -57,7 +57,7 @@ public void testEnabledDefault() { public void testUsage() throws ExecutionException, InterruptedException, IOException { var usageAction = new RollupUsageTransportAction(mock(TransportService.class), null, null, - mock(ActionFilters.class), null, Settings.EMPTY, licenseState); + mock(ActionFilters.class), null, licenseState); PlainActionFuture future = new PlainActionFuture<>(); usageAction.masterOperation(null, null, null, future); XPackFeatureSet.Usage rollupUsage = future.get().getUsage(); diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlInfoTransportAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlInfoTransportAction.java index 23c103a5b98f3..3f40be1e98031 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlInfoTransportAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlInfoTransportAction.java @@ -20,7 +20,7 @@ public class SqlInfoTransportAction extends XPackInfoFeatureTransportAction { @Inject public SqlInfoTransportAction(TransportService transportService, ActionFilters actionFilters, - Settings settings, XPackLicenseState licenseState) { + @Deprecated Settings settings, XPackLicenseState licenseState) { super(XPackInfoFeatureAction.SQL.name(), transportService, actionFilters); this.licenseState = licenseState; } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java index 9f5939846249f..e7211de7cc500 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java @@ -38,7 +38,7 @@ public class SqlUsageTransportAction extends XPackUsageFeatureTransportAction { @Inject public SqlUsageTransportAction(TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - Settings settings, XPackLicenseState licenseState, Client client) { + XPackLicenseState licenseState, Client client) { super(XPackUsageFeatureAction.SQL.name(), transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver); this.licenseState = licenseState; diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlInfoTransportActionTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlInfoTransportActionTests.java index d9a601c6a97f2..86bbed70ddbef 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlInfoTransportActionTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlInfoTransportActionTests.java @@ -110,7 +110,7 @@ public void testUsageStats() throws Exception { when(clusterService.localNode()).thenReturn(mockNode); var usageAction = new SqlUsageTransportAction(mock(TransportService.class), clusterService, null, - mock(ActionFilters.class), null, Settings.EMPTY, licenseState, client); + mock(ActionFilters.class), null, licenseState, client); PlainActionFuture future = new PlainActionFuture<>(); usageAction.masterOperation(mock(Task.class), null, null, future); SqlFeatureSetUsage sqlUsage = (SqlFeatureSetUsage) future.get().getUsage(); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformInfoTransportAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformInfoTransportAction.java index 64f9a80cb23ee..918f2e6b09189 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformInfoTransportAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformInfoTransportAction.java @@ -63,7 +63,7 @@ public class TransformInfoTransportAction extends XPackInfoFeatureTransportActio public TransformInfoTransportAction( TransportService transportService, ActionFilters actionFilters, - Settings settings, + @Deprecated Settings settings, XPackLicenseState licenseState ) { super(XPackInfoFeatureAction.TRANSFORM.name(), transportService, actionFilters); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java index 83267ad0de9ab..889c8260e2db2 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java @@ -58,7 +58,6 @@ public TransformUsageTransportAction( ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - Settings settings, XPackLicenseState licenseState, Client client ) { diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java index 39402c186cc03..baf3adb1c48c7 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java @@ -26,8 +26,7 @@ public class Vectors extends Plugin implements MapperPlugin, ActionPlugin { - public Vectors(Settings settings) { - } + public Vectors() { } @Override public List> getActions() { diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportAction.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportAction.java index 5e22e04c5ba5f..f9698836f140d 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportAction.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportAction.java @@ -20,7 +20,7 @@ public class VectorsInfoTransportAction extends XPackInfoFeatureTransportAction @Inject public VectorsInfoTransportAction(TransportService transportService, ActionFilters actionFilters, - Settings settings, XPackLicenseState licenseState) { + @Deprecated Settings settings, XPackLicenseState licenseState) { super(XPackInfoFeatureAction.VECTORS.name(), transportService, actionFilters); this.licenseState = licenseState; } diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java index 67f39b87cefe1..c33d943086b5f 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java @@ -31,16 +31,14 @@ public class VectorsUsageTransportAction extends XPackUsageFeatureTransportAction { - private final Settings settings; private final XPackLicenseState licenseState; @Inject public VectorsUsageTransportAction(TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - Settings settings, XPackLicenseState licenseState) { + @Deprecated Settings settings, XPackLicenseState licenseState) { super(XPackUsageFeatureAction.VECTORS.name(), transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver); - this.settings = settings; this.licenseState = licenseState; } From ffce6a1a822bb19f1540281b5e03b443954f995b Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 16 Apr 2020 13:01:22 -0400 Subject: [PATCH 10/18] Unused imports and spotless --- .../xpack/slm/SLMInfoTransportAction.java | 1 - .../xpack/slm/SLMUsageTransportAction.java | 1 - .../logstash/LogstashInfoTransportAction.java | 7 +------ .../logstash/LogstashUsageTransportAction.java | 1 - .../LogstashInfoTransportActionTests.java | 15 ++++----------- .../xpack/flattened/FlattenedMapperPlugin.java | 1 - .../xpack/rollup/RollupUsageTransportAction.java | 1 - .../xpack/sql/SqlUsageTransportAction.java | 1 - .../transform/TransformUsageTransportAction.java | 1 - .../org/elasticsearch/xpack/vectors/Vectors.java | 1 - .../vectors/VectorsUsageTransportAction.java | 1 - .../vectors/VectorsInfoTransportActionTests.java | 2 -- 12 files changed, 5 insertions(+), 28 deletions(-) diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMInfoTransportAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMInfoTransportAction.java index 16f9e608f7f7a..5281d3eb0f0f2 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMInfoTransportAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMInfoTransportAction.java @@ -8,7 +8,6 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackField; diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java index dc635f228f19e..602ee23f2b297 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java @@ -12,7 +12,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.protocol.xpack.XPackUsageRequest; import org.elasticsearch.tasks.Task; diff --git a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportAction.java b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportAction.java index 26b341a54c057..035590dc7795b 100644 --- a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportAction.java +++ b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportAction.java @@ -7,7 +7,6 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackField; @@ -19,11 +18,7 @@ public class LogstashInfoTransportAction extends XPackInfoFeatureTransportAction private final XPackLicenseState licenseState; @Inject - public LogstashInfoTransportAction( - TransportService transportService, - ActionFilters actionFilters, - XPackLicenseState licenseState - ) { + public LogstashInfoTransportAction(TransportService transportService, ActionFilters actionFilters, XPackLicenseState licenseState) { super(XPackInfoFeatureAction.LOGSTASH.name(), transportService, actionFilters); this.licenseState = licenseState; } diff --git a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java index b4bbd2e846cf9..aaac27a06bd97 100644 --- a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java +++ b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java @@ -11,7 +11,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.protocol.xpack.XPackUsageRequest; import org.elasticsearch.tasks.Task; diff --git a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java index c82f583826acf..1d88cc8a991d0 100644 --- a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java +++ b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java @@ -28,7 +28,7 @@ public void testEnabledSetting() throws Exception { LogstashInfoTransportAction featureSet = new LogstashInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), - null + null ); assertThat(featureSet.enabled(), is(true)); @@ -48,7 +48,7 @@ public void testEnabledDefault() throws Exception { LogstashInfoTransportAction featureSet = new LogstashInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), - null + null ); assertThat(featureSet.enabled(), is(true)); } @@ -58,7 +58,7 @@ public void testAvailable() throws Exception { LogstashInfoTransportAction featureSet = new LogstashInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), - licenseState + licenseState ); boolean available = randomBoolean(); when(licenseState.isLogstashAllowed()).thenReturn(available); @@ -79,13 +79,6 @@ public void testAvailable() throws Exception { private LogstashUsageTransportAction newUsageAction(boolean available) { XPackLicenseState licenseState = mock(XPackLicenseState.class); when(licenseState.isLogstashAllowed()).thenReturn(available); - return new LogstashUsageTransportAction( - mock(TransportService.class), - null, - null, - mock(ActionFilters.class), - null, - licenseState - ); + return new LogstashUsageTransportAction(mock(TransportService.class), null, null, mock(ActionFilters.class), null, licenseState); } } diff --git a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java index 50e7ab33e134f..2a5fccd425c46 100644 --- a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java +++ b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/FlattenedMapperPlugin.java @@ -6,7 +6,6 @@ package org.elasticsearch.xpack.flattened; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.plugins.MapperPlugin; import org.elasticsearch.plugins.Plugin; diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java index 29d49fd257f81..c08e15c6d0c7d 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java @@ -11,7 +11,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.protocol.xpack.XPackUsageRequest; import org.elasticsearch.tasks.Task; diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java index e7211de7cc500..2109d254db147 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java @@ -12,7 +12,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.protocol.xpack.XPackUsageRequest; import org.elasticsearch.tasks.Task; diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java index 889c8260e2db2..cf1fb3ed52076 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java @@ -17,7 +17,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.persistent.PersistentTasksCustomMetadata; diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java index baf3adb1c48c7..cb2890dac246d 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/Vectors.java @@ -8,7 +8,6 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.MapperPlugin; diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java index c33d943086b5f..b6bbeaa41c999 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java @@ -19,7 +19,6 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; import org.elasticsearch.xpack.core.action.XPackUsageFeatureTransportAction; diff --git a/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportActionTests.java b/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportActionTests.java index ae67acf9d195d..7b12b36e92883 100644 --- a/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportActionTests.java +++ b/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportActionTests.java @@ -8,13 +8,11 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.io.stream.BytesStreamOutput; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackFeatureSet; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; import org.elasticsearch.xpack.core.vectors.VectorsFeatureSetUsage; import org.junit.Before; From 7c1cf20bff99532e440cdb26cb06b561c434a55a Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 16 Apr 2020 15:32:12 -0400 Subject: [PATCH 11/18] Fixes for tests --- .../xpack/logstash/LogstashInfoTransportActionTests.java | 2 +- .../elasticsearch/xpack/sql/qa/jdbc/JdbcNoSqlTestCase.java | 7 ++++--- .../xpack/transform/TransformInfoTransportActionTests.java | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java index 1d88cc8a991d0..c3bae91391d85 100644 --- a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java +++ b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java @@ -40,7 +40,7 @@ public void testEnabledSetting() throws Exception { BytesStreamOutput out = new BytesStreamOutput(); usage.writeTo(out); XPackFeatureSet.Usage serializedUsage = new LogstashFeatureSetUsage(out.bytes().streamInput()); - assertThat(serializedUsage.enabled(), is(enabled)); + assertThat(serializedUsage.enabled(), is(true)); } public void testEnabledDefault() throws Exception { diff --git a/x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/JdbcNoSqlTestCase.java b/x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/JdbcNoSqlTestCase.java index 1b4e37dbc2b8c..7fbe2dd8b0519 100644 --- a/x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/JdbcNoSqlTestCase.java +++ b/x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/JdbcNoSqlTestCase.java @@ -9,13 +9,14 @@ import java.sql.Connection; import java.sql.SQLException; +import static org.hamcrest.Matchers.startsWith; + public class JdbcNoSqlTestCase extends JdbcIntegrationTestCase { - + public void testJdbcExceptionMessage() throws SQLException { try (Connection c = esJdbc()) { SQLException e = expectThrows(SQLException.class, () -> c.prepareStatement("SELECT * FROM bla").executeQuery()); - assertTrue(e.getMessage().startsWith("X-Pack/SQL does not seem to be available on the Elasticsearch" - + " node using the access path")); + assertThat(e.getMessage(), startsWith("Found 1 problem\nline 1:15: Unknown index [bla]")); } } } diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformInfoTransportActionTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformInfoTransportActionTests.java index 364af168ab25b..a43e3b3ec8e40 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformInfoTransportActionTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformInfoTransportActionTests.java @@ -58,7 +58,7 @@ public void testEnabledSetting() { settings.build(), licenseState ); - assertThat(featureSet.enabled(), is(enabled)); + assertThat(featureSet.enabled(), is(true)); } public void testEnabledDefault() { From 1909e4e10b6e926c549371f53785c49bd6e9abd4 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Fri, 17 Apr 2020 11:45:33 -0400 Subject: [PATCH 12/18] Remove unneeded settings objects used in tests --- .../rollup/RollupInfoTransportAction.java | 3 +-- .../rollup/RollupInfoTransportActionTests.java | 14 ++------------ .../xpack/sql/SqlInfoTransportAction.java | 3 +-- .../xpack/sql/SqlInfoTransportActionTests.java | 17 +---------------- .../TransformInfoTransportAction.java | 2 -- .../TransformInfoTransportActionTests.java | 16 ---------------- .../vectors/VectorsInfoTransportAction.java | 3 +-- .../vectors/VectorsUsageTransportAction.java | 3 +-- .../VectorsInfoTransportActionTests.java | 18 ++++-------------- 9 files changed, 11 insertions(+), 68 deletions(-) diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java index 0d5aff01e7ae6..2b86faf15380c 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupInfoTransportAction.java @@ -7,7 +7,6 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackField; @@ -20,7 +19,7 @@ public class RollupInfoTransportAction extends XPackInfoFeatureTransportAction { @Inject public RollupInfoTransportAction(TransportService transportService, ActionFilters actionFilters, - @Deprecated Settings settings, XPackLicenseState licenseState) { + XPackLicenseState licenseState) { super(XPackInfoFeatureAction.ROLLUP.name(), transportService, actionFilters); this.licenseState = licenseState; } diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java index 8e927ceff45c5..38f3ed393f640 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupInfoTransportActionTests.java @@ -8,7 +8,6 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.io.stream.BytesStreamOutput; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.TransportService; @@ -34,24 +33,15 @@ public void init() { public void testAvailable() { RollupInfoTransportAction featureSet = new RollupInfoTransportAction( - mock(TransportService.class), mock(ActionFilters.class), Settings.EMPTY, licenseState); + mock(TransportService.class), mock(ActionFilters.class), licenseState); boolean available = randomBoolean(); when(licenseState.isRollupAllowed()).thenReturn(available); assertThat(featureSet.available(), is(available)); } - public void testEnabledSettingIsANoOp() { - boolean enabled = randomBoolean(); - Settings.Builder settings = Settings.builder(); - settings.put("xpack.rollup.enabled", enabled); - RollupInfoTransportAction featureSet = new RollupInfoTransportAction( - mock(TransportService.class), mock(ActionFilters.class), settings.build(), licenseState); - assertThat(featureSet.enabled(), is(true)); - } - public void testEnabledDefault() { RollupInfoTransportAction featureSet = new RollupInfoTransportAction( - mock(TransportService.class), mock(ActionFilters.class), Settings.EMPTY, licenseState); + mock(TransportService.class), mock(ActionFilters.class), licenseState); assertThat(featureSet.enabled(), is(true)); } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlInfoTransportAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlInfoTransportAction.java index 3f40be1e98031..fe6f06fd7fa20 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlInfoTransportAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlInfoTransportAction.java @@ -7,7 +7,6 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackField; @@ -20,7 +19,7 @@ public class SqlInfoTransportAction extends XPackInfoFeatureTransportAction { @Inject public SqlInfoTransportAction(TransportService transportService, ActionFilters actionFilters, - @Deprecated Settings settings, XPackLicenseState licenseState) { + XPackLicenseState licenseState) { super(XPackInfoFeatureAction.SQL.name(), transportService, actionFilters); this.licenseState = licenseState; } diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlInfoTransportActionTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlInfoTransportActionTests.java index 86bbed70ddbef..6c764e988c84d 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlInfoTransportActionTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/SqlInfoTransportActionTests.java @@ -57,27 +57,12 @@ public void init() throws Exception { public void testAvailable() { SqlInfoTransportAction featureSet = new SqlInfoTransportAction( - mock(TransportService.class), mock(ActionFilters.class), Settings.EMPTY, licenseState); + mock(TransportService.class), mock(ActionFilters.class), licenseState); boolean available = randomBoolean(); when(licenseState.isSqlAllowed()).thenReturn(available); assertThat(featureSet.available(), is(available)); } - public void testEnabled() { - boolean enabled = randomBoolean(); - Settings.Builder settings = Settings.builder(); - if (enabled) { - if (randomBoolean()) { - settings.put("xpack.sql.enabled", enabled); - } - } else { - settings.put("xpack.sql.enabled", enabled); - } - SqlInfoTransportAction featureSet = new SqlInfoTransportAction( - mock(TransportService.class), mock(ActionFilters.class), settings.build(), licenseState); - assertThat(featureSet.enabled(), is(true)); - } - @SuppressWarnings("unchecked") public void testUsageStats() throws Exception { doAnswer(mock -> { diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformInfoTransportAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformInfoTransportAction.java index 918f2e6b09189..358ebc40cfe73 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformInfoTransportAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformInfoTransportAction.java @@ -15,7 +15,6 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.license.XPackLicenseState; @@ -63,7 +62,6 @@ public class TransformInfoTransportAction extends XPackInfoFeatureTransportActio public TransformInfoTransportAction( TransportService transportService, ActionFilters actionFilters, - @Deprecated Settings settings, XPackLicenseState licenseState ) { super(XPackInfoFeatureAction.TRANSFORM.name(), transportService, actionFilters); diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformInfoTransportActionTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformInfoTransportActionTests.java index a43e3b3ec8e40..7e7e1ee9cd574 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformInfoTransportActionTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformInfoTransportActionTests.java @@ -8,7 +8,6 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.Aggregations; @@ -40,7 +39,6 @@ public void testAvailable() { TransformInfoTransportAction featureSet = new TransformInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), - Settings.EMPTY, licenseState ); boolean available = randomBoolean(); @@ -48,24 +46,10 @@ public void testAvailable() { assertThat(featureSet.available(), is(available)); } - public void testEnabledSetting() { - boolean enabled = randomBoolean(); - Settings.Builder settings = Settings.builder(); - settings.put("xpack.transform.enabled", enabled); - TransformInfoTransportAction featureSet = new TransformInfoTransportAction( - mock(TransportService.class), - mock(ActionFilters.class), - settings.build(), - licenseState - ); - assertThat(featureSet.enabled(), is(true)); - } - public void testEnabledDefault() { TransformInfoTransportAction featureSet = new TransformInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), - Settings.EMPTY, licenseState ); assertTrue(featureSet.enabled()); diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportAction.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportAction.java index f9698836f140d..a670644ed3d3a 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportAction.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportAction.java @@ -7,7 +7,6 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackField; @@ -20,7 +19,7 @@ public class VectorsInfoTransportAction extends XPackInfoFeatureTransportAction @Inject public VectorsInfoTransportAction(TransportService transportService, ActionFilters actionFilters, - @Deprecated Settings settings, XPackLicenseState licenseState) { + XPackLicenseState licenseState) { super(XPackInfoFeatureAction.VECTORS.name(), transportService, actionFilters); this.licenseState = licenseState; } diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java index b6bbeaa41c999..0f759c114791b 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java @@ -13,7 +13,6 @@ import org.elasticsearch.cluster.metadata.MappingMetadata; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.protocol.xpack.XPackUsageRequest; import org.elasticsearch.tasks.Task; @@ -35,7 +34,7 @@ public class VectorsUsageTransportAction extends XPackUsageFeatureTransportActio @Inject public VectorsUsageTransportAction(TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - @Deprecated Settings settings, XPackLicenseState licenseState) { + XPackLicenseState licenseState) { super(XPackUsageFeatureAction.VECTORS.name(), transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver); this.licenseState = licenseState; diff --git a/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportActionTests.java b/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportActionTests.java index 7b12b36e92883..bb0cf8cf32ad3 100644 --- a/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportActionTests.java +++ b/x-pack/plugin/vectors/src/test/java/org/elasticsearch/xpack/vectors/VectorsInfoTransportActionTests.java @@ -8,7 +8,6 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.io.stream.BytesStreamOutput; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.TransportService; @@ -32,13 +31,13 @@ public void init() { public void testAvailable() throws Exception { VectorsInfoTransportAction featureSet = new VectorsInfoTransportAction( - mock(TransportService.class), mock(ActionFilters.class), Settings.EMPTY, licenseState); + mock(TransportService.class), mock(ActionFilters.class), licenseState); boolean available = randomBoolean(); when(licenseState.isVectorsAllowed()).thenReturn(available); assertThat(featureSet.available(), is(available)); var usageAction = new VectorsUsageTransportAction(mock(TransportService.class), null, null, - mock(ActionFilters.class), null, Settings.EMPTY, licenseState); + mock(ActionFilters.class), null, licenseState); PlainActionFuture future = new PlainActionFuture<>(); usageAction.masterOperation(null, null, null, future); XPackFeatureSet.Usage usage = future.get().getUsage(); @@ -51,21 +50,12 @@ public void testAvailable() throws Exception { } public void testAlwaysEnabled() throws Exception { - boolean enabled = randomBoolean(); - Settings.Builder settings = Settings.builder(); - if (enabled) { - if (randomBoolean()) { - settings.put("xpack.vectors.enabled", enabled); - } - } else { - settings.put("xpack.vectors.enabled", enabled); - } VectorsInfoTransportAction featureSet = new VectorsInfoTransportAction( -mock(TransportService.class), mock(ActionFilters.class), settings.build(), licenseState); +mock(TransportService.class), mock(ActionFilters.class), licenseState); assertThat(featureSet.enabled(), is(true)); VectorsUsageTransportAction usageAction = new VectorsUsageTransportAction(mock(TransportService.class), - null, null, mock(ActionFilters.class), null, settings.build(), licenseState); + null, null, mock(ActionFilters.class), null, licenseState); PlainActionFuture future = new PlainActionFuture<>(); usageAction.masterOperation(null, null, null, future); XPackFeatureSet.Usage usage = future.get().getUsage(); From 3062456208ae493acaef674014bbff1703449742 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Fri, 17 Apr 2020 14:43:19 -0400 Subject: [PATCH 13/18] Remove enrich enabled setting --- .../xpack/core/XPackSettings.java | 1 + .../xpack/enrich/EnrichPlugin.java | 20 ------ .../action/EnrichInfoTransportAction.java | 13 +--- .../action/EnrichUsageTransportAction.java | 7 +- .../xpack/enrich/EnrichDisabledIT.java | 44 ------------ .../enrich/EnrichStatsCollectorTests.java | 69 ++----------------- .../xpack/monitoring/Monitoring.java | 2 +- .../enrich/EnrichStatsCollector.java | 13 +--- 8 files changed, 15 insertions(+), 154 deletions(-) delete mode 100644 x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichDisabledIT.java diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java index 6f2f8030ab7f6..aafb42b9f6987 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java @@ -272,6 +272,7 @@ public static List> getAllSettings() { settings.add(TRANSFORM_ENABLED); settings.add(FLATTENED_ENABLED); settings.add(VECTORS_ENABLED); + settings.add(ENRICH_ENABLED_SETTING); return Collections.unmodifiableList(settings); } diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java index 836847f06d7bd..239681a6cd0c0 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java @@ -67,7 +67,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Supplier; -import static org.elasticsearch.xpack.core.XPackSettings.ENRICH_ENABLED_SETTING; import static org.elasticsearch.xpack.core.enrich.EnrichPolicy.ENRICH_INDEX_PATTERN; public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlugin { @@ -125,19 +124,13 @@ public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlu }, val -> Setting.parseInt(val, 1, Integer.MAX_VALUE, QUEUE_CAPACITY_SETTING_NAME), Setting.Property.NodeScope); private final Settings settings; - private final Boolean enabled; public EnrichPlugin(final Settings settings) { this.settings = settings; - this.enabled = ENRICH_ENABLED_SETTING.get(settings); } @Override public Map getProcessors(Processor.Parameters parameters) { - if (enabled == false) { - return Map.of(); - } - EnrichProcessorFactory factory = new EnrichProcessorFactory(parameters.client, parameters.scriptService); parameters.ingestService.addIngestClusterStateListener(factory); return Map.of(EnrichProcessorFactory.TYPE, factory); @@ -148,10 +141,6 @@ protected XPackLicenseState getLicenseState() { } public List> getActions() { - if (enabled == false) { - return List.of(new ActionHandler<>(XPackInfoFeatureAction.ENRICH, EnrichInfoTransportAction.class)); - } - return List.of( new ActionHandler<>(XPackInfoFeatureAction.ENRICH, EnrichInfoTransportAction.class), new ActionHandler<>(XPackUsageFeatureAction.ENRICH, EnrichUsageTransportAction.class), @@ -175,10 +164,6 @@ public List getRestHandlers( IndexNameExpressionResolver indexNameExpressionResolver, Supplier nodesInCluster ) { - if (enabled == false) { - return List.of(); - } - return List.of( new RestGetEnrichPolicyAction(), new RestDeleteEnrichPolicyAction(), @@ -202,10 +187,6 @@ public Collection createComponents( IndexNameExpressionResolver expressionResolver, Supplier repositoriesServiceSupplier ) { - if (enabled == false) { - return List.of(); - } - EnrichPolicyLocks enrichPolicyLocks = new EnrichPolicyLocks(); EnrichPolicyMaintenanceService enrichPolicyMaintenanceService = new EnrichPolicyMaintenanceService( settings, @@ -239,7 +220,6 @@ public List getNamedXContent() { @Override public List> getSettings() { return List.of( - ENRICH_ENABLED_SETTING, ENRICH_FETCH_SIZE_SETTING, ENRICH_MAX_CONCURRENT_POLICY_EXECUTIONS, ENRICH_CLEANUP_PERIOD, diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichInfoTransportAction.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichInfoTransportAction.java index fc75ec4be9c7e..154fc6d6e52c5 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichInfoTransportAction.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichInfoTransportAction.java @@ -7,28 +7,19 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; import org.elasticsearch.xpack.core.action.XPackInfoFeatureTransportAction; public class EnrichInfoTransportAction extends XPackInfoFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject - public EnrichInfoTransportAction( - TransportService transportService, - ActionFilters actionFilters, - Settings settings, - XPackLicenseState licenseState - ) { + public EnrichInfoTransportAction(TransportService transportService, ActionFilters actionFilters, XPackLicenseState licenseState) { super(XPackInfoFeatureAction.ENRICH.name(), transportService, actionFilters); - this.enabled = XPackSettings.ENRICH_ENABLED_SETTING.get(settings); this.licenseState = licenseState; } @@ -44,7 +35,7 @@ public boolean available() { @Override public boolean enabled() { - return enabled; + return true; } } diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichUsageTransportAction.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichUsageTransportAction.java index 2b91e4ba7446d..842f5a5e88bea 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichUsageTransportAction.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichUsageTransportAction.java @@ -11,13 +11,11 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.protocol.xpack.XPackUsageRequest; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; import org.elasticsearch.xpack.core.action.XPackUsageFeatureTransportAction; @@ -25,11 +23,9 @@ public class EnrichUsageTransportAction extends XPackUsageFeatureTransportAction { private final XPackLicenseState licenseState; - private final boolean enabled; @Inject public EnrichUsageTransportAction( - Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, @@ -46,7 +42,6 @@ public EnrichUsageTransportAction( indexNameExpressionResolver ); this.licenseState = licenseState; - this.enabled = XPackSettings.ENRICH_ENABLED_SETTING.get(settings); } @Override @@ -57,6 +52,6 @@ protected void masterOperation( ActionListener listener ) { boolean available = licenseState.isEnrichAllowed(); - listener.onResponse(new XPackUsageFeatureResponse(new EnrichFeatureSetUsage(available, enabled))); + listener.onResponse(new XPackUsageFeatureResponse(new EnrichFeatureSetUsage(available, true))); } } diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichDisabledIT.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichDisabledIT.java deleted file mode 100644 index 7725d97c8bab6..0000000000000 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichDisabledIT.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.enrich; - -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.protocol.xpack.XPackInfoRequest; -import org.elasticsearch.protocol.xpack.XPackInfoResponse; -import org.elasticsearch.test.ESSingleNodeTestCase; -import org.elasticsearch.xpack.core.XPackField; -import org.elasticsearch.xpack.core.XPackSettings; -import org.elasticsearch.xpack.core.action.XPackInfoAction; - -import java.util.Collection; -import java.util.EnumSet; -import java.util.List; - -import static org.hamcrest.Matchers.is; - -public class EnrichDisabledIT extends ESSingleNodeTestCase { - - public void testEnrichAvailableButNotEnabled() { - ensureGreen(); - - XPackInfoRequest infoRequest = new XPackInfoRequest(); - infoRequest.setCategories(EnumSet.of(XPackInfoRequest.Category.FEATURES)); - XPackInfoResponse infoResponse = client().execute(XPackInfoAction.INSTANCE, infoRequest).actionGet(); - assertThat(infoResponse.getFeatureSetsInfo().getFeatureSets().get(XPackField.ENRICH).available(), is(true)); - assertThat(infoResponse.getFeatureSetsInfo().getFeatureSets().get(XPackField.ENRICH).enabled(), is(false)); - } - - @Override - protected Settings nodeSettings() { - return Settings.builder().put(XPackSettings.ENRICH_ENABLED_SETTING.getKey(), false).build(); - } - - @Override - protected Collection> getPlugins() { - return List.of(LocalStateEnrich.class); - } -} diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java index 3e7e9935f9f85..b4080338dfe75 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java @@ -8,12 +8,10 @@ import org.elasticsearch.action.ActionFuture; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.license.XPackLicenseState; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.enrich.action.EnrichStatsAction; import org.elasticsearch.xpack.core.enrich.action.EnrichStatsAction.Response.CoordinatorStats; import org.elasticsearch.xpack.core.enrich.action.EnrichStatsAction.Response.ExecutingPolicy; @@ -40,7 +38,6 @@ public class EnrichStatsCollectorTests extends BaseCollectorTestCase { public void testShouldCollectReturnsFalseIfMonitoringNotAllowed() { - final Settings settings = randomFrom(enrichEnabledSettings(), enrichDisabledSettings()); final boolean enrichAllowed = randomBoolean(); final boolean isElectedMaster = randomBoolean(); whenLocalNodeElectedMaster(isElectedMaster); @@ -49,7 +46,7 @@ public void testShouldCollectReturnsFalseIfMonitoringNotAllowed() { when(licenseState.isMonitoringAllowed()).thenReturn(false); when(licenseState.isEnrichAllowed()).thenReturn(enrichAllowed); - final EnrichStatsCollector collector = createCollector(settings, clusterService, licenseState, client); + final EnrichStatsCollector collector = createCollector(clusterService, licenseState, client); assertThat(collector.shouldCollect(isElectedMaster), is(false)); if (isElectedMaster) { @@ -58,47 +55,17 @@ public void testShouldCollectReturnsFalseIfMonitoringNotAllowed() { } public void testShouldCollectReturnsFalseIfNotMaster() { - // regardless of enrich being enabled - final Settings settings = randomFrom(enrichEnabledSettings(), enrichDisabledSettings()); - when(licenseState.isMonitoringAllowed()).thenReturn(randomBoolean()); when(licenseState.isEnrichAllowed()).thenReturn(randomBoolean()); // this controls the blockage final boolean isElectedMaster = false; - final EnrichStatsCollector collector = createCollector(settings, clusterService, licenseState, client); + final EnrichStatsCollector collector = createCollector(clusterService, licenseState, client); assertThat(collector.shouldCollect(isElectedMaster), is(false)); } - public void testShouldCollectReturnsFalseIfEnrichIsDisabled() { - // this is controls the blockage - final Settings settings = enrichDisabledSettings(); - - boolean isMonitoringAllowed = randomBoolean(); - when(licenseState.isMonitoringAllowed()).thenReturn(isMonitoringAllowed); - when(licenseState.isEnrichAllowed()).thenReturn(randomBoolean()); - - final boolean isElectedMaster = randomBoolean(); - whenLocalNodeElectedMaster(isElectedMaster); - - final EnrichStatsCollector collector = createCollector(settings, clusterService, licenseState, client); - - assertThat(collector.shouldCollect(isElectedMaster), is(false)); - - if (isElectedMaster) { - verify(licenseState).isMonitoringAllowed(); - } - if (isElectedMaster && isMonitoringAllowed) { - // The enrich setting is only checked if the node is master and monitoring is allowed, - // so in other cases we won't have a deprecation warning. - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.ENRICH_ENABLED_SETTING }); - } - } - public void testShouldCollectReturnsFalseIfEnrichIsNotAllowed() { - final Settings settings = randomFrom(enrichEnabledSettings(), enrichDisabledSettings()); - boolean isMonitoringAllowed = randomBoolean(); when(licenseState.isMonitoringAllowed()).thenReturn(isMonitoringAllowed); // this is controls the blockage @@ -106,33 +73,25 @@ public void testShouldCollectReturnsFalseIfEnrichIsNotAllowed() { final boolean isElectedMaster = randomBoolean(); whenLocalNodeElectedMaster(isElectedMaster); - final EnrichStatsCollector collector = createCollector(settings, clusterService, licenseState, client); + final EnrichStatsCollector collector = createCollector(clusterService, licenseState, client); assertThat(collector.shouldCollect(isElectedMaster), is(false)); if (isElectedMaster) { verify(licenseState).isMonitoringAllowed(); } - if (isElectedMaster && isMonitoringAllowed && settings.get(XPackSettings.ENRICH_ENABLED_SETTING.getKey()) != null) { - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.ENRICH_ENABLED_SETTING }); - } } public void testShouldCollectReturnsTrue() { - final Settings settings = enrichEnabledSettings(); - when(licenseState.isMonitoringAllowed()).thenReturn(true); when(licenseState.isEnrichAllowed()).thenReturn(true); final boolean isElectedMaster = true; - final EnrichStatsCollector collector = createCollector(settings, clusterService, licenseState, client); + final EnrichStatsCollector collector = createCollector(clusterService, licenseState, client); assertThat(collector.shouldCollect(isElectedMaster), is(true)); verify(licenseState).isMonitoringAllowed(); - if (settings.get(XPackSettings.ENRICH_ENABLED_SETTING.getKey()) != null) { - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.ENRICH_ENABLED_SETTING }); - } } public void testDoCollect() throws Exception { @@ -172,7 +131,7 @@ public void testDoCollect() throws Exception { when(client.execute(eq(EnrichStatsAction.INSTANCE), any(EnrichStatsAction.Request.class))).thenReturn(future); when(future.actionGet(timeout)).thenReturn(response); - final EnrichStatsCollector collector = new EnrichStatsCollector(clusterService, licenseState, client, threadContext, settings); + final EnrichStatsCollector collector = new EnrichStatsCollector(clusterService, licenseState, client, threadContext); assertEquals(timeout, collector.getCollectionTimeout()); final long interval = randomNonNegativeLong(); @@ -211,22 +170,8 @@ public void testDoCollect() throws Exception { } } - private EnrichStatsCollector createCollector( - Settings settings, - ClusterService clusterService, - XPackLicenseState licenseState, - Client client - ) { - return new EnrichStatsCollector(clusterService, licenseState, client, settings); - } - - private Settings enrichEnabledSettings() { - // since it's the default, we want to ensure we test both with/without it - return randomBoolean() ? Settings.EMPTY : Settings.builder().put(XPackSettings.ENRICH_ENABLED_SETTING.getKey(), true).build(); - } - - private Settings enrichDisabledSettings() { - return Settings.builder().put(XPackSettings.ENRICH_ENABLED_SETTING.getKey(), false).build(); + private EnrichStatsCollector createCollector(ClusterService clusterService, XPackLicenseState licenseState, Client client) { + return new EnrichStatsCollector(clusterService, licenseState, client); } } diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java index 8b6fef3a574fa..327cc9556e63e 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java @@ -128,7 +128,7 @@ public Collection createComponents(Client client, ClusterService cluster collectors.add(new IndexRecoveryCollector(clusterService, getLicenseState(), client)); collectors.add(new JobStatsCollector(settings, clusterService, getLicenseState(), client)); collectors.add(new StatsCollector(settings, clusterService, getLicenseState(), client)); - collectors.add(new EnrichStatsCollector(clusterService, getLicenseState(), client, settings)); + collectors.add(new EnrichStatsCollector(clusterService, getLicenseState(), client)); final MonitoringService monitoringService = new MonitoringService(settings, clusterService, threadPool, collectors, exporters); diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollector.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollector.java index c2162c289dffe..8bb015481c2c2 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollector.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollector.java @@ -9,11 +9,9 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.license.XPackLicenseState; -import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.enrich.action.EnrichStatsAction; import org.elasticsearch.xpack.core.monitoring.exporter.MonitoringDoc; import org.elasticsearch.xpack.monitoring.collector.Collector; @@ -29,24 +27,20 @@ public final class EnrichStatsCollector extends Collector { public static final Setting STATS_TIMEOUT = collectionTimeoutSetting("enrich.stats.timeout"); private final Client client; - private final Settings settings; private final ThreadContext threadContext; public EnrichStatsCollector(ClusterService clusterService, XPackLicenseState licenseState, - Client client, - Settings settings) { - this(clusterService, licenseState, client, client.threadPool().getThreadContext(), settings); + Client client) { + this(clusterService, licenseState, client, client.threadPool().getThreadContext()); } EnrichStatsCollector(ClusterService clusterService, XPackLicenseState licenseState, Client client, - ThreadContext threadContext, - Settings settings) { + ThreadContext threadContext) { super(EnrichCoordinatorDoc.TYPE, clusterService, STATS_TIMEOUT, licenseState); this.client = client; - this.settings = settings; this.threadContext = threadContext; } @@ -54,7 +48,6 @@ public EnrichStatsCollector(ClusterService clusterService, protected boolean shouldCollect(final boolean isElectedMaster) { return isElectedMaster && super.shouldCollect(isElectedMaster) - && XPackSettings.ENRICH_ENABLED_SETTING.get(settings) && licenseState.isEnrichAllowed(); } From 7e1e4e94ab87af1cd8672a76dab69ed6bdc528f1 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Fri, 17 Apr 2020 14:44:34 -0400 Subject: [PATCH 14/18] Javadoc and deprecation annotation --- .../main/java/org/elasticsearch/xpack/core/XPackSettings.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java index aafb42b9f6987..693718d4de39f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java @@ -39,7 +39,10 @@ private XPackSettings() { /** * Setting for controlling whether or not enrich is enabled. + *

+ * This setting is now a no-op: setting it to false is permitted, but does nothing. */ + @Deprecated(since = "7.8.0") public static final Setting ENRICH_ENABLED_SETTING = Setting.boolSetting("xpack.enrich.enabled", true, Property.NodeScope, Property.Deprecated); From 999f2e7e6f8f089c3e1d9cc7c11cb0e3d26d52ff Mon Sep 17 00:00:00 2001 From: William Brafford Date: Fri, 17 Apr 2020 15:36:59 -0400 Subject: [PATCH 15/18] Basic license features are always enabled --- .../xpack/core/enrich/EnrichFeatureSetUsage.java | 4 ++-- .../xpack/core/flattened/FlattenedFeatureSetUsage.java | 4 ++-- .../xpack/core/logstash/LogstashFeatureSetUsage.java | 4 ++-- .../xpack/core/rollup/RollupFeatureSetUsage.java | 4 ++-- .../elasticsearch/xpack/core/slm/SLMFeatureSetUsage.java | 4 ++-- .../elasticsearch/xpack/core/sql/SqlFeatureSetUsage.java | 4 ++-- .../xpack/core/transform/TransformFeatureSetUsage.java | 4 ++-- .../xpack/core/vectors/VectorsFeatureSetUsage.java | 4 ++-- .../xpack/core/flattened/FlattenedFeatureSetUsageTests.java | 4 ++-- .../xpack/core/transform/TransformFeatureSetUsageTests.java | 3 +-- .../xpack/core/vectors/VectorsFeatureSetUsageTests.java | 6 +++--- .../xpack/enrich/action/EnrichUsageTransportAction.java | 2 +- .../elasticsearch/xpack/slm/SLMUsageTransportAction.java | 3 +-- .../xpack/logstash/LogstashUsageTransportAction.java | 2 +- .../xpack/rollup/RollupUsageTransportAction.java | 3 +-- .../elasticsearch/xpack/sql/SqlUsageTransportAction.java | 2 +- .../xpack/transform/TransformUsageTransportAction.java | 4 ++-- .../xpack/vectors/VectorsUsageTransportAction.java | 2 +- 18 files changed, 30 insertions(+), 33 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/EnrichFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/EnrichFeatureSetUsage.java index c38901e057aaf..86d9c49854e0b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/EnrichFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/EnrichFeatureSetUsage.java @@ -15,8 +15,8 @@ public class EnrichFeatureSetUsage extends XPackFeatureSet.Usage { - public EnrichFeatureSetUsage(boolean available, boolean enabled) { - super(XPackField.ENRICH, available, enabled); + public EnrichFeatureSetUsage(boolean available) { + super(XPackField.ENRICH, available, true); } public EnrichFeatureSetUsage(StreamInput input) throws IOException { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsage.java index 9c000faa2cb0b..088ea839df54a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsage.java @@ -28,8 +28,8 @@ public FlattenedFeatureSetUsage(StreamInput input) throws IOException { this.fieldCount = input.getVersion().onOrAfter(Version.V_7_6_0) ? input.readInt() : 0; } - public FlattenedFeatureSetUsage(boolean available, boolean enabled, int fieldCount) { - super(XPackField.FLATTENED, available, enabled); + public FlattenedFeatureSetUsage(boolean available, int fieldCount) { + super(XPackField.FLATTENED, available, true); this.fieldCount = fieldCount; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/logstash/LogstashFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/logstash/LogstashFeatureSetUsage.java index 53eab3334e529..057af00929a49 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/logstash/LogstashFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/logstash/LogstashFeatureSetUsage.java @@ -18,8 +18,8 @@ public LogstashFeatureSetUsage(StreamInput in) throws IOException { super(in); } - public LogstashFeatureSetUsage(boolean available, boolean enabled) { - super(XPackField.LOGSTASH, available, enabled); + public LogstashFeatureSetUsage(boolean available) { + super(XPackField.LOGSTASH, available, true); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupFeatureSetUsage.java index 3dfcc0d4e8c6d..dbe9d8b30d84a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupFeatureSetUsage.java @@ -18,8 +18,8 @@ public RollupFeatureSetUsage(StreamInput input) throws IOException { super(input); } - public RollupFeatureSetUsage(boolean available, boolean enabled) { - super(XPackField.ROLLUP, available, enabled); + public RollupFeatureSetUsage(boolean available) { + super(XPackField.ROLLUP, available, true); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/SLMFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/SLMFeatureSetUsage.java index 42048086cea34..b0cf3059207e4 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/SLMFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/SLMFeatureSetUsage.java @@ -33,8 +33,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(this.slmStats); } - public SLMFeatureSetUsage(boolean available, boolean enabled, @Nullable SnapshotLifecycleStats slmStats) { - super(XPackField.SNAPSHOT_LIFECYCLE, available, enabled); + public SLMFeatureSetUsage(boolean available, @Nullable SnapshotLifecycleStats slmStats) { + super(XPackField.SNAPSHOT_LIFECYCLE, available, true); this.slmStats = slmStats; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/sql/SqlFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/sql/SqlFeatureSetUsage.java index c1a04232cc17b..7f0c1821be8c6 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/sql/SqlFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/sql/SqlFeatureSetUsage.java @@ -25,8 +25,8 @@ public SqlFeatureSetUsage(StreamInput in) throws IOException { stats = in.readMap(); } - public SqlFeatureSetUsage(boolean available, boolean enabled, Map stats) { - super(XPackField.SQL, available, enabled); + public SqlFeatureSetUsage(boolean available, Map stats) { + super(XPackField.SQL, available, true); this.stats = stats; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsage.java index 81ed1f2ba3948..a334c76049ca2 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsage.java @@ -31,9 +31,9 @@ public TransformFeatureSetUsage(StreamInput in) throws IOException { this.accumulatedStats = new TransformIndexerStats(in); } - public TransformFeatureSetUsage(boolean available, boolean enabled, Map transformCountByState, + public TransformFeatureSetUsage(boolean available, Map transformCountByState, TransformIndexerStats accumulatedStats) { - super(XPackField.TRANSFORM, available, enabled); + super(XPackField.TRANSFORM, available, true); this.transformCountByState = Objects.requireNonNull(transformCountByState); this.accumulatedStats = Objects.requireNonNull(accumulatedStats); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/vectors/VectorsFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/vectors/VectorsFeatureSetUsage.java index a5eb5409f21af..6a752e6369364 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/vectors/VectorsFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/vectors/VectorsFeatureSetUsage.java @@ -47,8 +47,8 @@ public Version getMinimalSupportedVersion() { return Version.V_7_3_0; } - public VectorsFeatureSetUsage(boolean available, boolean enabled, int numDenseVectorFields, int avgDenseVectorDims) { - super(XPackField.VECTORS, available, enabled); + public VectorsFeatureSetUsage(boolean available, int numDenseVectorFields, int avgDenseVectorDims) { + super(XPackField.VECTORS, available, true); this.numDenseVectorFields = numDenseVectorFields; this.avgDenseVectorDims = avgDenseVectorDims; } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsageTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsageTests.java index fade04a32ba92..e2e910556b14c 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsageTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsageTests.java @@ -20,7 +20,7 @@ public void testFlattenedIsRemovedInNextMajor() { @Override protected FlattenedFeatureSetUsage createTestInstance() { - return new FlattenedFeatureSetUsage(randomBoolean(), randomBoolean(), randomIntBetween(0, 1000)); + return new FlattenedFeatureSetUsage(randomBoolean(), randomIntBetween(0, 1000)); } @Override @@ -42,7 +42,7 @@ protected FlattenedFeatureSetUsage mutateInstance(FlattenedFeatureSetUsage insta break; } - return new FlattenedFeatureSetUsage(available, enabled, fieldCount); + return new FlattenedFeatureSetUsage(available, fieldCount); } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsageTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsageTests.java index 5cf462f50baa0..057c7d973aa01 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsageTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/TransformFeatureSetUsageTests.java @@ -24,8 +24,7 @@ protected TransformFeatureSetUsage createTestInstance() { transformCountByState.put(randomFrom(IndexerState.values()).toString(), randomLong()); } - return new TransformFeatureSetUsage(randomBoolean(), randomBoolean(), transformCountByState, - TransformIndexerStatsTests.randomStats()); + return new TransformFeatureSetUsage(randomBoolean(), transformCountByState, TransformIndexerStatsTests.randomStats()); } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/vectors/VectorsFeatureSetUsageTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/vectors/VectorsFeatureSetUsageTests.java index 8033f932836c3..f2116af67b633 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/vectors/VectorsFeatureSetUsageTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/vectors/VectorsFeatureSetUsageTests.java @@ -17,9 +17,9 @@ protected VectorsFeatureSetUsage createTestInstance() { boolean available = randomBoolean(); boolean enabled = randomBoolean(); if (available && enabled) { - return new VectorsFeatureSetUsage(available, enabled, randomIntBetween(0, 100000), randomIntBetween(0, 1024)); + return new VectorsFeatureSetUsage(available, randomIntBetween(0, 100000), randomIntBetween(0, 1024)); } else { - return new VectorsFeatureSetUsage(available, enabled, 0, 0); + return new VectorsFeatureSetUsage(available, 0, 0); } } @@ -36,7 +36,7 @@ protected VectorsFeatureSetUsage mutateInstance(VectorsFeatureSetUsage instance) } numDenseVectorFields = randomValueOtherThan(numDenseVectorFields, () -> randomIntBetween(0, 100000)); avgDenseVectorDims = randomValueOtherThan(avgDenseVectorDims, () -> randomIntBetween(0, 1024)); - return new VectorsFeatureSetUsage(available, enabled, numDenseVectorFields, avgDenseVectorDims); + return new VectorsFeatureSetUsage(available, numDenseVectorFields, avgDenseVectorDims); } @Override diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichUsageTransportAction.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichUsageTransportAction.java index 842f5a5e88bea..e7e20c905009f 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichUsageTransportAction.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichUsageTransportAction.java @@ -52,6 +52,6 @@ protected void masterOperation( ActionListener listener ) { boolean available = licenseState.isEnrichAllowed(); - listener.onResponse(new XPackUsageFeatureResponse(new EnrichFeatureSetUsage(available, true))); + listener.onResponse(new XPackUsageFeatureResponse(new EnrichFeatureSetUsage(available))); } } diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java index 602ee23f2b297..bbdf9f9d14139 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/slm/SLMUsageTransportAction.java @@ -40,8 +40,7 @@ protected void masterOperation(Task task, XPackUsageRequest request, ClusterStat ActionListener listener) { boolean available = licenseState.isIndexLifecycleAllowed(); final SnapshotLifecycleMetadata slmMeta = state.metadata().custom(SnapshotLifecycleMetadata.TYPE); - final SLMFeatureSetUsage usage = new SLMFeatureSetUsage(available, true, - slmMeta == null ? null : slmMeta.getStats()); + final SLMFeatureSetUsage usage = new SLMFeatureSetUsage(available, slmMeta == null ? null : slmMeta.getStats()); listener.onResponse(new XPackUsageFeatureResponse(usage)); } } diff --git a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java index aaac27a06bd97..4bdb95a84be15 100644 --- a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java +++ b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashUsageTransportAction.java @@ -53,7 +53,7 @@ protected void masterOperation( ActionListener listener ) { boolean available = licenseState.isLogstashAllowed(); - LogstashFeatureSetUsage usage = new LogstashFeatureSetUsage(available, true); + LogstashFeatureSetUsage usage = new LogstashFeatureSetUsage(available); listener.onResponse(new XPackUsageFeatureResponse(usage)); } } diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java index c08e15c6d0c7d..b754b1c85253e 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/RollupUsageTransportAction.java @@ -39,8 +39,7 @@ protected void masterOperation(Task task, XPackUsageRequest request, ClusterStat ActionListener listener) { boolean available = licenseState.isRollupAllowed(); // TODO expose the currently running rollup tasks on this node? Unclear the best way to do that - RollupFeatureSetUsage usage = - new RollupFeatureSetUsage(available, true); + RollupFeatureSetUsage usage = new RollupFeatureSetUsage(available); listener.onResponse(new XPackUsageFeatureResponse(usage)); } } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java index 2109d254db147..ae0775be1effc 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/SqlUsageTransportAction.java @@ -58,7 +58,7 @@ protected void masterOperation(Task task, XPackUsageRequest request, ClusterStat .filter(Objects::nonNull) .collect(Collectors.toList()); Counters mergedCounters = Counters.merge(countersPerNode); - SqlFeatureSetUsage usage = new SqlFeatureSetUsage(available, true, mergedCounters.toNestedMap()); + SqlFeatureSetUsage usage = new SqlFeatureSetUsage(available, mergedCounters.toNestedMap()); listener.onResponse(new XPackUsageFeatureResponse(usage)); }, listener::onFailure)); } diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java index cf1fb3ed52076..380ab78fc81eb 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformUsageTransportAction.java @@ -96,7 +96,7 @@ protected void masterOperation( } ActionListener totalStatsListener = ActionListener.wrap(statSummations -> { - var usage = new TransformFeatureSetUsage(available, true, transformsCountByState, statSummations); + var usage = new TransformFeatureSetUsage(available, transformsCountByState, statSummations); listener.onResponse(new XPackUsageFeatureResponse(usage)); }, listener::onFailure); @@ -109,7 +109,7 @@ protected void masterOperation( } long totalTransforms = transformCountSuccess.getHits().getTotalHits().value; if (totalTransforms == 0) { - var usage = new TransformFeatureSetUsage(available, true, transformsCountByState, new TransformIndexerStats()); + var usage = new TransformFeatureSetUsage(available, transformsCountByState, new TransformIndexerStats()); listener.onResponse(new XPackUsageFeatureResponse(usage)); return; } diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java index 0f759c114791b..65f94aa99a900 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/VectorsUsageTransportAction.java @@ -76,7 +76,7 @@ protected void masterOperation(Task task, XPackUsageRequest request, ClusterStat } } VectorsFeatureSetUsage usage = - new VectorsFeatureSetUsage(vectorsAvailable, true, numDenseVectorFields, avgDenseVectorDims); + new VectorsFeatureSetUsage(vectorsAvailable, numDenseVectorFields, avgDenseVectorDims); listener.onResponse(new XPackUsageFeatureResponse(usage)); } } From c83b6431b35ef79f96ef23032c7250537e1288c3 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Fri, 17 Apr 2020 16:51:21 -0400 Subject: [PATCH 16/18] Remove enabled from mutation test --- .../xpack/core/flattened/FlattenedFeatureSetUsageTests.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsageTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsageTests.java index e2e910556b14c..5f3a631897151 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsageTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/flattened/FlattenedFeatureSetUsageTests.java @@ -27,17 +27,13 @@ protected FlattenedFeatureSetUsage createTestInstance() { protected FlattenedFeatureSetUsage mutateInstance(FlattenedFeatureSetUsage instance) throws IOException { boolean available = instance.available(); - boolean enabled = instance.enabled(); int fieldCount = instance.fieldCount(); - switch (between(0, 2)) { + switch (between(0, 1)) { case 0: available = !available; break; case 1: - enabled = !enabled; - break; - case 2: fieldCount = randomValueOtherThan(instance.fieldCount(), () -> randomIntBetween(0, 1000)); break; } From b0e1578cba1051f25e432f8fb48198723b508c64 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 23 Apr 2020 17:44:58 -0400 Subject: [PATCH 17/18] Docs for no-op deprecated settings --- .../migration/migrate_8_0/settings.asciidoc | 19 ++++++++--- docs/reference/modules/node.asciidoc | 9 ++---- docs/reference/settings/sql-settings.asciidoc | 5 ++- .../settings/transform-settings.asciidoc | 32 ++++++------------- docs/reference/transform/setup.asciidoc | 13 ++++---- 5 files changed, 34 insertions(+), 44 deletions(-) diff --git a/docs/reference/migration/migrate_8_0/settings.asciidoc b/docs/reference/migration/migrate_8_0/settings.asciidoc index 0da51b2bf2c3b..2601c8ec3f3fc 100644 --- a/docs/reference/migration/migrate_8_0/settings.asciidoc +++ b/docs/reference/migration/migrate_8_0/settings.asciidoc @@ -63,20 +63,29 @@ removed. [float] ==== Option to disable basic license features is deprecated -In Elasticsearch 7.8.0, the following settings have been deprecated: +In Elasticsearch 7.8.0, the following settings no longer have any effect, and +have been deprecated: * `xpack.enrich.enabled` * `xpack.flattened.enabled` -* `xpack.ilm.enabled` -* `xpack.monitoring.enabled` * `xpack.rollup.enabled` * `xpack.slm.enabled` * `xpack.sql.enabled` * `xpack.transform.enabled` * `xpack.vectors.enabled` -In future releases, it will not be possible to disable the APIs for Enrichment, -Flattened mappings, ILM, Monitoring, Rollup, SLM, SQL, Transforms, and Vectors. +Previously, these settings could be set to `false` in order to disable the +feature's APIs in a cluster. As of 7.8.0, these basic license features are +always enabled for the {default-dist}. + +Additionally, the following settings have been deprecated without removing +their effects: + +* `xpack.ilm.enabled` +* `xpack.monitoring.enabled` + +In future releases, it will not be possible to disable the APIs for ILM +and Monitoring. [float] ==== The `prefer_v2_templates` parameter now defaults to `true` diff --git a/docs/reference/modules/node.asciidoc b/docs/reference/modules/node.asciidoc index f5b021e05210f..51683e5caf81b 100644 --- a/docs/reference/modules/node.asciidoc +++ b/docs/reference/modules/node.asciidoc @@ -404,12 +404,9 @@ node.remote_cluster_client: false <8> {transform-cap} nodes run {transforms} and handle {transform} API requests. -If you want to use {transforms} in your cluster, you must not have -`xpack.transform.enabled` set to `false` on any master-eligible or data -nodes. To use {transforms} in clients (including {kib}), do not disable this -setting on any coordinating nodes. You must also have `node.transform` set to -`true` on at least one node. This is the default behavior. If you have the -{oss-dist}, do not use these settings. For more information, see +If you want to use {transforms} in your cluster, you must have `node.transform` +set to `true` on at least one node. This is the default behavior. If you have +the {oss-dist}, do not use these settings. For more information, see <>. To create a dedicated {transform} node in the {default-dist}, set: diff --git a/docs/reference/settings/sql-settings.asciidoc b/docs/reference/settings/sql-settings.asciidoc index 76358dd814f6d..ac5ef9434c7a9 100644 --- a/docs/reference/settings/sql-settings.asciidoc +++ b/docs/reference/settings/sql-settings.asciidoc @@ -5,12 +5,11 @@ SQL access settings ++++ -SQL Access is enabled by default. You can configure -these SQL Access settings in the `elasticsearch.yml` file. +SQL Access is always enabled. [float] [[general-sql-settings]] ==== General SQL Access Settings `xpack.sql.enabled`:: deprecated:[7.8.0,Basic License features should always be enabled] + -Set to `false` to disable SQL Access on the node. +This deprecated setting no longer has any effect. diff --git a/docs/reference/settings/transform-settings.asciidoc b/docs/reference/settings/transform-settings.asciidoc index fb6202c6c09ba..ff8b26da435ed 100644 --- a/docs/reference/settings/transform-settings.asciidoc +++ b/docs/reference/settings/transform-settings.asciidoc @@ -21,34 +21,20 @@ file. ==== General {transforms} settings `node.transform`:: -Set to `true` to identify the node as a _transform node_. If either `node.data` -or `xpack.transform.enabled` is `false` for the node, the default value is -`false`. Otherwise, the default value is `true`. +Set to `true` to identify the node as a _transform node_. If `node.data` +is `false` for the node, the default value is `false`. Otherwise, the default +value is `true`. + -If set to `false` in `elasticsearch.yml`, the node cannot run transforms. If set to -`true` but `xpack.transform.enabled` is set to `false`, the `node.transform` setting is -ignored and the node cannot run transforms. If you want to run transforms, there must be at -least one transform node in your cluster. + +If set to `false` in `elasticsearch.yml`, the node cannot run transforms. If +you want to run transforms, there must be at least one transform node in your +cluster. + + -IMPORTANT: It is advised to use the `node.transform` setting to constrain the execution -of transforms to certain nodes instead of using `xpack.transform.enabled`. On dedicated -coordinating nodes or dedicated master nodes, disable the node.transform role. +IMPORTANT: On dedicated coordinating nodes or dedicated master nodes, disable +the node.transform role. `xpack.transform.enabled`:: deprecated:[7.8.0,Basic License features should always be enabled] + -Set to `true` (default) to enable {transforms} on the node. -+ -If set to `false` in `elasticsearch.yml`, the {transform} APIs are disabled on -the node. Therefore the node cannot start or administrate {transforms} or -receive transport (internal) communication requests related to {transform} APIs. -If the node is a coordinating node, {transform} requests from clients (including -{kib}) also fail. -+ -IMPORTANT: If you want to use {transform} features in your cluster, it is -recommended that you set `xpack.transform.enabled` to `true` on all nodes. This -is the default behavior. At a minimum, it must be enabled on all master-eligible -nodes and all data nodes. If you want to use {transforms} in clients or {kib}, -it must also be enabled on all coordinating nodes. +This deprecated setting no longer has any effect. `xpack.transform.num_transform_failure_retries` (<>):: The number of times that a {transform} retries when it experiences a diff --git a/docs/reference/transform/setup.asciidoc b/docs/reference/transform/setup.asciidoc index dae8297e7d18e..5b8cc77874d10 100644 --- a/docs/reference/transform/setup.asciidoc +++ b/docs/reference/transform/setup.asciidoc @@ -16,9 +16,8 @@ To use the {transforms}, you must have the ==== {transform-cap} nodes To use {transforms}, there must be at least one node in your cluster with -`xpack.transform.enabled` and `node.transform` set to `true`. By default, all -nodes are {transform} nodes unless you explicitly change these settings or set -`node.data` to `false`. +`node.transform` set to `true`. By default, all nodes are {transform} nodes +unless you explicitly change these settings or set `node.data` to `false`. If you want to control which nodes run {transforms}, set `node.transform` to `false` on some nodes. @@ -35,14 +34,14 @@ which users can manage or view {transforms}. To _view_ the configuration and status of {transforms}, you must have: -* `transform_user` built-in role or `monitor_transform` +* `transform_user` built-in role or `monitor_transform` cluster privileges To _manage_ {transforms}, you must have: -* `transform_admin` built-in role or `manage_transform` +* `transform_admin` built-in role or `manage_transform` cluster privileges * `read` and `view_index_metadata` index privileges on source indices * `read`, `create_index`, and `index` index privileges on destination indices - -For more information, see <> and <>. \ No newline at end of file + +For more information, see <> and <>. From a906c1f6e90ea106a9bd5202a774979b2ab275d0 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 30 Apr 2020 14:52:44 -0400 Subject: [PATCH 18/18] Apply spotless --- .../xpack/logstash/LogstashInfoTransportActionTests.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java index 6941dd85a92b7..64fef0069cdd9 100644 --- a/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java +++ b/x-pack/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashInfoTransportActionTests.java @@ -79,13 +79,6 @@ public void testAvailable() throws Exception { private LogstashUsageTransportAction newUsageAction(boolean available) { XPackLicenseState licenseState = mock(XPackLicenseState.class); when(licenseState.isAllowed(XPackLicenseState.Feature.LOGSTASH)).thenReturn(available); - return new LogstashUsageTransportAction( - mock(TransportService.class), - null, - null, - mock(ActionFilters.class), - null, - licenseState - ); + return new LogstashUsageTransportAction(mock(TransportService.class), null, null, mock(ActionFilters.class), null, licenseState); } }