diff --git a/docs/reference/migration/migrate_8_0/settings.asciidoc b/docs/reference/migration/migrate_8_0/settings.asciidoc index 01d32bb209a68..5ac52665b31de 100644 --- a/docs/reference/migration/migrate_8_0/settings.asciidoc +++ b/docs/reference/migration/migrate_8_0/settings.asciidoc @@ -72,8 +72,15 @@ removed. 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` 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 @@ -83,20 +90,6 @@ If you have disabled ILM so that you can use another tool to manage Watcher indices, the newly introduced `xpack.watcher.use_ilm_index_management` setting may be set to false. -Additionally, the following settings have been deprecated without removing -their effects: - -* `xpack.enrich.enabled` -* `xpack.flattened.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, Rollup, SLM, SQL, Transforms, and Vectors. - [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 <>. 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 5982049a3c81f..2f20893149bc4 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); @@ -48,7 +51,12 @@ 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. + */ + @Deprecated(since = "7.8.0") public static final Setting TRANSFORM_ENABLED = Setting.boolSetting("xpack.transform.enabled", true, Property.NodeScope, Property.Deprecated); @@ -74,7 +82,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); @@ -86,7 +99,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); @@ -101,7 +119,10 @@ 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. */ + @Deprecated(since = "7.8.0") public static final Setting SNAPSHOT_LIFECYCLE_ENABLED = Setting.boolSetting("xpack.slm.enabled", true, Property.NodeScope, Property.Deprecated); @@ -129,15 +150,30 @@ 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); - /** 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); - /** 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); @@ -256,6 +292,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/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 62568fa957dfe..b5cac0d7d267d 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..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 @@ -20,29 +20,25 @@ public void testFlattenedIsRemovedInNextMajor() { @Override protected FlattenedFeatureSetUsage createTestInstance() { - return new FlattenedFeatureSetUsage(randomBoolean(), randomBoolean(), randomIntBetween(0, 1000)); + return new FlattenedFeatureSetUsage(randomBoolean(), randomIntBetween(0, 1000)); } @Override 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; } - 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/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 fb93c82950edf..44a1befe9e192 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 929c03ca134e8..f6f800d9629a6 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.isAllowed(XPackLicenseState.Feature.ENRICH); - listener.onResponse(new XPackUsageFeatureResponse(new EnrichFeatureSetUsage(available, enabled))); + listener.onResponse(new XPackUsageFeatureResponse(new EnrichFeatureSetUsage(available))); } } 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 6a3146b2b7b56..5628437167904 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.isAllowed(XPackLicenseState.Feature.MONITORING)).thenReturn(false); when(licenseState.isAllowed(XPackLicenseState.Feature.ENRICH)).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.isAllowed(XPackLicenseState.Feature.MONITORING)).thenReturn(randomBoolean()); when(licenseState.isAllowed(XPackLicenseState.Feature.ENRICH)).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.isAllowed(XPackLicenseState.Feature.MONITORING)).thenReturn(isMonitoringAllowed); - when(licenseState.isAllowed(XPackLicenseState.Feature.ENRICH)).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).isAllowed(XPackLicenseState.Feature.MONITORING); - } - 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.isAllowed(XPackLicenseState.Feature.MONITORING)).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).isAllowed(XPackLicenseState.Feature.MONITORING); } - 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.isAllowed(XPackLicenseState.Feature.MONITORING)).thenReturn(true); when(licenseState.isAllowed(XPackLicenseState.Feature.ENRICH)).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).isAllowed(XPackLicenseState.Feature.MONITORING); - 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/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 ff06bd114e9b4..055c97e498627 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 @@ -28,7 +28,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/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 27d84e08cca16..699155639e0ca 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 @@ -36,7 +36,6 @@ import org.elasticsearch.script.ScriptService; 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.ilm.AllocateAction; @@ -142,11 +141,9 @@ public class IndexLifecycle extends Plugin implements ActionPlugin { private final SetOnce snapshotRetentionService = new SetOnce<>(); private final SetOnce snapshotHistoryStore = new SetOnce<>(); private Settings settings; - private boolean slmEnabled; public IndexLifecycle(Settings settings) { this.settings = settings; - this.slmEnabled = XPackSettings.SNAPSHOT_LIFECYCLE_ENABLED.get(settings); } // overridable by tests @@ -187,20 +184,20 @@ public Collection createComponents(Client client, ClusterService cluster indexLifecycleInitialisationService.set(new IndexLifecycleService(settings, client, clusterService, threadPool, 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; } @@ -242,8 +239,9 @@ public List getRestHandlers(Settings settings, RestController restC IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver, Supplier nodesInCluster) { List handlers = new ArrayList<>(); - // add ILM rest handlers handlers.addAll(Arrays.asList( + + // add ILM rest handlers new RestPutLifecycleAction(), new RestGetLifecycleAction(), new RestDeleteLifecycleAction(), @@ -253,21 +251,19 @@ public List getRestHandlers(Settings settings, RestController restC new RestRetryAction(), new RestStopAction(), new RestStartILMAction(), - new RestGetStatusAction() + new RestGetStatusAction(), + + // add SLM rest headers + new RestPutSnapshotLifecycleAction(), + new RestDeleteSnapshotLifecycleAction(), + new RestGetSnapshotLifecycleAction(), + new RestExecuteSnapshotLifecycleAction(), + new RestGetSnapshotLifecycleStatsAction(), + new RestExecuteSnapshotRetentionAction(), + new RestStopSLMAction(), + new RestStartSLMAction(), + new RestGetSLMStatusAction() )); - if (slmEnabled) { - handlers.addAll(Arrays.asList( - new RestPutSnapshotLifecycleAction(), - new RestDeleteSnapshotLifecycleAction(), - new RestGetSnapshotLifecycleAction(), - new RestExecuteSnapshotLifecycleAction(), - new RestGetSnapshotLifecycleStatsAction(), - new RestExecuteSnapshotRetentionAction(), - new RestStopSLMAction(), - new RestStartSLMAction(), - new RestGetSLMStatusAction() - )); - } return handlers; } @@ -282,8 +278,8 @@ public List getRestHandlers(Settings settings, RestController restC actions.add(ilmInfoAction); actions.add(slmUsageAction); actions.add(slmInfoAction); - // add ILM actions actions.addAll(Arrays.asList( + // add ILM actions new ActionHandler<>(PutLifecycleAction.INSTANCE, TransportPutLifecycleAction.class), new ActionHandler<>(GetLifecycleAction.INSTANCE, TransportGetLifecycleAction.class), new ActionHandler<>(DeleteLifecycleAction.INSTANCE, TransportDeleteLifecycleAction.class), @@ -293,21 +289,19 @@ public List getRestHandlers(Settings settings, RestController restC new ActionHandler<>(RetryAction.INSTANCE, TransportRetryAction.class), new ActionHandler<>(StartILMAction.INSTANCE, TransportStartILMAction.class), new ActionHandler<>(StopILMAction.INSTANCE, TransportStopILMAction.class), - new ActionHandler<>(GetStatusAction.INSTANCE, TransportGetStatusAction.class) - )); - if (slmEnabled) { - actions.addAll(Arrays.asList( - new ActionHandler<>(PutSnapshotLifecycleAction.INSTANCE, TransportPutSnapshotLifecycleAction.class), - new ActionHandler<>(DeleteSnapshotLifecycleAction.INSTANCE, TransportDeleteSnapshotLifecycleAction.class), - new ActionHandler<>(GetSnapshotLifecycleAction.INSTANCE, TransportGetSnapshotLifecycleAction.class), - new ActionHandler<>(ExecuteSnapshotLifecycleAction.INSTANCE, TransportExecuteSnapshotLifecycleAction.class), - new ActionHandler<>(GetSnapshotLifecycleStatsAction.INSTANCE, TransportGetSnapshotLifecycleStatsAction.class), - new ActionHandler<>(ExecuteSnapshotRetentionAction.INSTANCE, TransportExecuteSnapshotRetentionAction.class), - new ActionHandler<>(StartSLMAction.INSTANCE, TransportStartSLMAction.class), - new ActionHandler<>(StopSLMAction.INSTANCE, TransportStopSLMAction.class), - new ActionHandler<>(GetSLMStatusAction.INSTANCE, TransportGetSLMStatusAction.class) + new ActionHandler<>(GetStatusAction.INSTANCE, TransportGetStatusAction.class), + + // add SLM actions + new ActionHandler<>(PutSnapshotLifecycleAction.INSTANCE, TransportPutSnapshotLifecycleAction.class), + new ActionHandler<>(DeleteSnapshotLifecycleAction.INSTANCE, TransportDeleteSnapshotLifecycleAction.class), + new ActionHandler<>(GetSnapshotLifecycleAction.INSTANCE, TransportGetSnapshotLifecycleAction.class), + new ActionHandler<>(ExecuteSnapshotLifecycleAction.INSTANCE, TransportExecuteSnapshotLifecycleAction.class), + new ActionHandler<>(GetSnapshotLifecycleStatsAction.INSTANCE, TransportGetSnapshotLifecycleStatsAction.class), + new ActionHandler<>(ExecuteSnapshotRetentionAction.INSTANCE, TransportExecuteSnapshotRetentionAction.class), + new ActionHandler<>(StartSLMAction.INSTANCE, TransportStartSLMAction.class), + new ActionHandler<>(StopSLMAction.INSTANCE, TransportStopSLMAction.class), + new ActionHandler<>(GetSLMStatusAction.INSTANCE, TransportGetSLMStatusAction.class) )); - } return actions; } 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 e90084bd5ea32..2ddd01a53cf0a 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,23 +8,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 SLMInfoTransportAction extends XPackInfoFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject public SLMInfoTransportAction(TransportService transportService, ActionFilters actionFilters, - Settings settings, XPackLicenseState licenseState) { + XPackLicenseState licenseState) { super(XPackInfoFeatureAction.SNAPSHOT_LIFECYCLE.name(), transportService, actionFilters); - this.enabled = XPackSettings.SNAPSHOT_LIFECYCLE_ENABLED.get(settings); this.licenseState = licenseState; } @@ -40,6 +36,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 2058e11d8a9b3..d07d8b85f5999 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,13 +12,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; @@ -26,16 +24,14 @@ import org.elasticsearch.xpack.core.slm.SnapshotLifecycleMetadata; public class SLMUsageTransportAction extends XPackUsageFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; @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.enabled = XPackSettings.SNAPSHOT_LIFECYCLE_ENABLED.get(settings); this.licenseState = licenseState; } @@ -44,8 +40,7 @@ protected void masterOperation(Task task, XPackUsageRequest request, ClusterStat ActionListener listener) { boolean available = licenseState.isAllowed(XPackLicenseState.Feature.ILM); final SnapshotLifecycleMetadata slmMeta = state.metadata().custom(SnapshotLifecycleMetadata.TYPE); - final SLMFeatureSetUsage usage = new SLMFeatureSetUsage(available, enabled, - 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/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 339b6570f1fb6..c8fc875609077 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 @@ -49,8 +49,6 @@ protected Settings nodeSettings() { settings.put(XPackSettings.WATCHER_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/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 2c2eb1d89c3db..3c130877a84c1 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,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 LogstashInfoTransportAction extends XPackInfoFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject - public LogstashInfoTransportAction( - TransportService transportService, - ActionFilters actionFilters, - Settings settings, - XPackLicenseState licenseState - ) { + public LogstashInfoTransportAction(TransportService transportService, ActionFilters actionFilters, XPackLicenseState licenseState) { super(XPackInfoFeatureAction.LOGSTASH.name(), transportService, actionFilters); - this.enabled = XPackSettings.LOGSTASH_ENABLED.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/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 338839edf0ef2..1ba17483e20d5 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,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,7 +23,6 @@ public class LogstashUsageTransportAction extends XPackUsageFeatureTransportAction { - private final Settings settings; private final XPackLicenseState licenseState; @Inject @@ -35,7 +32,6 @@ public LogstashUsageTransportAction( ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - Settings settings, XPackLicenseState licenseState ) { super( @@ -46,7 +42,6 @@ public LogstashUsageTransportAction( actionFilters, indexNameExpressionResolver ); - this.settings = settings; this.licenseState = licenseState; } @@ -58,7 +53,7 @@ protected void masterOperation( ActionListener listener ) { boolean available = licenseState.isAllowed(XPackLicenseState.Feature.LOGSTASH); - LogstashFeatureSetUsage usage = new LogstashFeatureSetUsage(available, XPackSettings.LOGSTASH_ENABLED.get(settings)); + LogstashFeatureSetUsage usage = new LogstashFeatureSetUsage(available); 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 d192e74356781..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 @@ -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; @@ -30,12 +28,11 @@ public void testEnabledSetting() throws Exception { LogstashInfoTransportAction featureSet = new LogstashInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), - settings, null ); - assertThat(featureSet.enabled(), is(enabled)); + 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(); @@ -43,9 +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)); - - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.LOGSTASH_ENABLED }); + assertThat(serializedUsage.enabled(), is(true)); } public void testEnabledDefault() throws Exception { @@ -53,7 +48,6 @@ public void testEnabledDefault() throws Exception { LogstashInfoTransportAction featureSet = new LogstashInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), - settings, null ); assertThat(featureSet.enabled(), is(true)); @@ -64,14 +58,13 @@ public void testAvailable() throws Exception { LogstashInfoTransportAction featureSet = new LogstashInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), - Settings.EMPTY, licenseState ); boolean available = randomBoolean(); when(licenseState.isAllowed(XPackLicenseState.Feature.LOGSTASH)).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(); @@ -83,17 +76,9 @@ 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.isAllowed(XPackLicenseState.Feature.LOGSTASH)).thenReturn(available); - return new LogstashUsageTransportAction( - mock(TransportService.class), - null, - null, - mock(ActionFilters.class), - null, - settings, - 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 a74f7c5a87799..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,31 +6,21 @@ 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; -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); - } + public FlattenedMapperPlugin() { } @Override public Map getMappers() { - if (enabled == false) { - return emptyMap(); - } return singletonMap(FlatObjectFieldMapper.CONTENT_TYPE, new FlatObjectFieldMapper.TypeParser()); } } 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 b6767719a4336..fcf7299904e06 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 @@ -116,7 +116,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 78eda5b4e7268..43baf6eac3118 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.isAllowed(XPackLicenseState.Feature.ENRICH); } 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 7ff25b8cf13c3..5887dfe794af1 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,24 +7,20 @@ 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 RollupInfoTransportAction extends XPackInfoFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject public RollupInfoTransportAction(TransportService transportService, ActionFilters actionFilters, - Settings settings, XPackLicenseState licenseState) { + XPackLicenseState licenseState) { super(XPackInfoFeatureAction.ROLLUP.name(), transportService, actionFilters); - this.enabled = XPackSettings.ROLLUP_ENABLED.get(settings); this.licenseState = licenseState; } @@ -40,7 +36,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 cf476f8b60d60..02d0170e6040b 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,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,16 +23,14 @@ public class RollupUsageTransportAction extends XPackUsageFeatureTransportAction { - private final Settings settings; private final XPackLicenseState licenseState; @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.settings = settings; this.licenseState = licenseState; } @@ -43,8 +39,7 @@ protected void masterOperation(Task task, XPackUsageRequest request, ClusterStat ActionListener listener) { boolean available = licenseState.isAllowed(XPackLicenseState.Feature.ROLLUP); // 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)); + RollupFeatureSetUsage usage = new RollupFeatureSetUsage(available); 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 f701609959bcf..69dc1fab5e9db 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,10 @@ 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; @@ -36,31 +33,21 @@ 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.isAllowed(XPackLicenseState.Feature.ROLLUP)).thenReturn(available); assertThat(featureSet.available(), is(available)); } - public void testEnabledSetting() { - 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 } ); - } - 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)); } 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/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' } 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/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 3d57a6ab40e5a..636a9fb694024 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,24 +7,20 @@ 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 SqlInfoTransportAction extends XPackInfoFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject public SqlInfoTransportAction(TransportService transportService, ActionFilters actionFilters, - Settings settings, XPackLicenseState licenseState) { + XPackLicenseState licenseState) { super(XPackInfoFeatureAction.SQL.name(), transportService, actionFilters); - this.enabled = XPackSettings.SQL_ENABLED.get(settings); this.licenseState = licenseState; } @@ -40,7 +36,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 7e59f3844434d..3cb5f54fde729 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,13 +12,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; @@ -28,23 +26,20 @@ 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; @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.enabled = XPackSettings.SQL_ENABLED.get(settings); this.licenseState = licenseState; this.client = client; } @@ -53,23 +48,18 @@ public SqlUsageTransportAction(TransportService transportService, ClusterService protected void masterOperation(Task task, XPackUsageRequest request, ClusterState state, ActionListener listener) { boolean available = licenseState.isAllowed(XPackLicenseState.Feature.SQL); - 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, 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 afb132e062f66..aac33aeda8a54 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 d76b97381cc01..162ff0d5c964e 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; @@ -59,33 +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.isAllowed(XPackLicenseState.Feature.SQL)).thenReturn(available); assertThat(featureSet.available(), is(available)); } - 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 } ); - } - } - @SuppressWarnings("unchecked") public void testUsageStats() throws Exception { doAnswer(mock -> { @@ -118,7 +95,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/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)); } } 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 11a2f0d7fccf5..a72ba93721119 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; @@ -25,7 +24,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 +37,6 @@ public class TransformInfoTransportAction extends XPackInfoFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; private static final Logger logger = LogManager.getLogger(TransformInfoTransportAction.class); @@ -65,11 +62,9 @@ public class TransformInfoTransportAction extends XPackInfoFeatureTransportActio public TransformInfoTransportAction( TransportService transportService, ActionFilters actionFilters, - Settings settings, XPackLicenseState licenseState ) { super(XPackInfoFeatureAction.TRANSFORM.name(), transportService, actionFilters); - this.enabled = XPackSettings.TRANSFORM_ENABLED.get(settings); this.licenseState = licenseState; } @@ -85,7 +80,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 09ce8ed72e086..e02233c33ac7e 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; @@ -26,7 +25,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 +47,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; @@ -60,7 +57,6 @@ public TransformUsageTransportAction( ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - Settings settings, XPackLicenseState licenseState, Client client ) { @@ -72,7 +68,6 @@ public TransformUsageTransportAction( actionFilters, indexNameExpressionResolver ); - this.enabled = XPackSettings.TRANSFORM_ENABLED.get(settings); this.licenseState = licenseState; this.client = client; } @@ -85,11 +80,6 @@ protected void masterOperation( ActionListener listener ) { boolean available = licenseState.isAllowed(XPackLicenseState.Feature.TRANSFORM); - 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 +96,7 @@ protected void masterOperation( } ActionListener totalStatsListener = ActionListener.wrap(statSummations -> { - var usage = new TransformFeatureSetUsage(available, enabled, transformsCountByState, statSummations); + var usage = new TransformFeatureSetUsage(available, transformsCountByState, statSummations); listener.onResponse(new XPackUsageFeatureResponse(usage)); }, listener::onFailure); @@ -119,7 +109,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, 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 a8957a051060d..1751e2f7334b8 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,18 @@ 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; @@ -55,7 +39,6 @@ public void testAvailable() { TransformInfoTransportAction featureSet = new TransformInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), - Settings.EMPTY, licenseState ); boolean available = randomBoolean(); @@ -63,25 +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(enabled)); - assertSettingDeprecationsAndWarnings(new Setting[] { XPackSettings.TRANSFORM_ENABLED } ); - } - public void testEnabledDefault() { TransformInfoTransportAction featureSet = new TransformInfoTransportAction( mock(TransportService.class), mock(ActionFilters.class), - Settings.EMPTY, licenseState ); assertTrue(featureSet.enabled()); @@ -130,37 +98,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.isAllowed(XPackLicenseState.Feature.TRANSFORM)).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() { 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..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,12 +8,10 @@ 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; 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,15 +23,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); - } + public Vectors() { } @Override public List> getActions() { @@ -44,9 +36,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 c522c3e4ec27f..065c7c3fc493a 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,24 +7,20 @@ 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 VectorsInfoTransportAction extends XPackInfoFeatureTransportAction { - private final boolean enabled; private final XPackLicenseState licenseState; @Inject public VectorsInfoTransportAction(TransportService transportService, ActionFilters actionFilters, - Settings settings, XPackLicenseState licenseState) { + XPackLicenseState licenseState) { super(XPackInfoFeatureAction.VECTORS.name(), transportService, actionFilters); - this.enabled = XPackSettings.VECTORS_ENABLED.get(settings); this.licenseState = licenseState; } @@ -40,7 +36,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 fb8461c5bd7bd..0b37042b9a621 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,13 +13,11 @@ 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; 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; @@ -31,16 +29,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) { + XPackLicenseState licenseState) { super(XPackUsageFeatureAction.VECTORS.name(), transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver); - this.settings = settings; this.licenseState = licenseState; } @@ -48,12 +44,11 @@ public VectorsUsageTransportAction(TransportService transportService, ClusterSer protected void masterOperation(Task task, XPackUsageRequest request, ClusterState state, ActionListener listener) { boolean vectorsAvailable = licenseState.isAllowed(XPackLicenseState.Feature.VECTORS); - 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 +76,7 @@ protected void masterOperation(Task task, XPackUsageRequest request, ClusterStat } } VectorsFeatureSetUsage usage = - new VectorsFeatureSetUsage(vectorsAvailable, vectorsEnabled, numDenseVectorFields, avgDenseVectorDims); + new VectorsFeatureSetUsage(vectorsAvailable, 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 5ac635ee45c2e..0d4154c8151dc 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,10 @@ 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; @@ -34,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.isAllowed(XPackLicenseState.Feature.VECTORS)).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(); @@ -52,37 +49,22 @@ public void testAvailable() throws Exception { assertThat(serializedUsage.available(), is(available)); } - public void testEnabled() 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; - } + public void testAlwaysEnabled() throws Exception { VectorsInfoTransportAction featureSet = new VectorsInfoTransportAction( -mock(TransportService.class), mock(ActionFilters.class), settings.build(), licenseState); - assertThat(featureSet.enabled(), is(enabled)); +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(); - 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)); } } 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 123503eb5dcc9..4cb18348ffdc1 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 { @@ -115,9 +121,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(); }