diff --git a/docs/reference/migration/migrate_7_8.asciidoc b/docs/reference/migration/migrate_7_8.asciidoc
index ec79eac7659fb..bf5bdc9e535e1 100644
--- a/docs/reference/migration/migrate_7_8.asciidoc
+++ b/docs/reference/migration/migrate_7_8.asciidoc
@@ -94,26 +94,30 @@ setting.
[[deprecate-basic-license-feature-enabled]]
-.Several {xpack} settings no longer have any effect and are deprecated.
+.Several {xpack} settings no longer have any effect and are deprecated.
[%collapsible]
====
*Details* +
-Basic {xpack} license features are always enabled for the {default-dist}
-and the following settings no longer have any effect:
+Basic {xpack} license features are always enabled for the {default-dist}
+and the following settings no longer have any effect:
* `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, they could be set to `false` to disable the feature's APIs in a cluster.
+The ILM and SLM settings have been deprecated, but still have the effect of disabling
+their respective APIs:
+
+* `xpack.ilm.enabled`
+* `xpack.slm.enabled`
+
*Impact* +
To avoid deprecation warnings, discontinue use of these settings.
If you have disabled ILM so that you can use another tool to manage Watcher
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 57539e273661d..4cb5336342f78 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
@@ -118,8 +118,6 @@ private XPackSettings() {
/**
* Setting for enabling or disabling the index 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 INDEX_LIFECYCLE_ENABLED = Setting.boolSetting("xpack.ilm.enabled", true,
@@ -127,8 +125,6 @@ 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,
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsage.java
index 6ea43825a301b..c651c93e8278d 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsage.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsage.java
@@ -49,12 +49,12 @@ public void writeTo(StreamOutput out) throws IOException {
}
}
- public IndexLifecycleFeatureSetUsage(boolean available) {
- this(available, null);
+ public IndexLifecycleFeatureSetUsage(boolean available, boolean enabled) {
+ this(available, enabled, null);
}
- public IndexLifecycleFeatureSetUsage(boolean available, List policyStats) {
- super(XPackField.INDEX_LIFECYCLE, available, true);
+ public IndexLifecycleFeatureSetUsage(boolean available, boolean enabled, List policyStats) {
+ super(XPackField.INDEX_LIFECYCLE, available, enabled);
this.policyStats = policyStats;
}
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 b0cf3059207e4..42048086cea34 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, @Nullable SnapshotLifecycleStats slmStats) {
- super(XPackField.SNAPSHOT_LIFECYCLE, available, true);
+ public SLMFeatureSetUsage(boolean available, boolean enabled, @Nullable SnapshotLifecycleStats slmStats) {
+ super(XPackField.SNAPSHOT_LIFECYCLE, available, enabled);
this.slmStats = slmStats;
}
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistry.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistry.java
index 33ad3aca2e80f..c568efcb8f8ea 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistry.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistry.java
@@ -26,6 +26,7 @@
import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.core.XPackClient;
+import org.elasticsearch.xpack.core.XPackSettings;
import org.elasticsearch.xpack.core.ilm.IndexLifecycleMetadata;
import org.elasticsearch.xpack.core.ilm.LifecyclePolicy;
import org.elasticsearch.xpack.core.ilm.action.PutLifecycleAction;
@@ -202,26 +203,29 @@ public void onFailure(Exception e) {
}
private void addIndexLifecyclePoliciesIfMissing(ClusterState state) {
+ boolean ilmSupported = XPackSettings.INDEX_LIFECYCLE_ENABLED.get(settings);
- Optional maybeMeta = Optional.ofNullable(state.metadata().custom(IndexLifecycleMetadata.TYPE));
- List policies = getPolicyConfigs().stream()
- .map(policyConfig -> policyConfig.load(xContentRegistry))
- .collect(Collectors.toList());
+ if (ilmSupported) {
+ Optional maybeMeta = Optional.ofNullable(state.metadata().custom(IndexLifecycleMetadata.TYPE));
+ List policies = getPolicyConfigs().stream()
+ .map(policyConfig -> policyConfig.load(xContentRegistry))
+ .collect(Collectors.toList());
- for (LifecyclePolicy policy : policies) {
- final AtomicBoolean creationCheck = policyCreationsInProgress.computeIfAbsent(policy.getName(),
- key -> new AtomicBoolean(false));
- if (creationCheck.compareAndSet(false, true)) {
- final boolean policyNeedsToBeCreated = maybeMeta
- .flatMap(ilmMeta -> Optional.ofNullable(ilmMeta.getPolicies().get(policy.getName())))
- .isPresent() == false;
- if (policyNeedsToBeCreated) {
- logger.debug("adding lifecycle policy [{}] for [{}], because it doesn't exist", policy.getName(), getOrigin());
- putPolicy(policy, creationCheck);
- } else {
- logger.trace("not adding lifecycle policy [{}] for [{}], because it already exists",
- policy.getName(), getOrigin());
- creationCheck.set(false);
+ for (LifecyclePolicy policy : policies) {
+ final AtomicBoolean creationCheck = policyCreationsInProgress.computeIfAbsent(policy.getName(),
+ key -> new AtomicBoolean(false));
+ if (creationCheck.compareAndSet(false, true)) {
+ final boolean policyNeedsToBeCreated = maybeMeta
+ .flatMap(ilmMeta -> Optional.ofNullable(ilmMeta.getPolicies().get(policy.getName())))
+ .isPresent() == false;
+ if (policyNeedsToBeCreated) {
+ logger.debug("adding lifecycle policy [{}] for [{}], because it doesn't exist", policy.getName(), getOrigin());
+ putPolicy(policy, creationCheck);
+ } else {
+ logger.trace("not adding lifecycle policy [{}] for [{}], because it already exists",
+ policy.getName(), getOrigin());
+ creationCheck.set(false);
+ }
}
}
}
diff --git a/x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/anomalydetection/state_index_template.json b/x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/anomalydetection/state_index_template.json
index 64635b658e3b2..e3cd7f51dc43a 100644
--- a/x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/anomalydetection/state_index_template.json
+++ b/x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/anomalydetection/state_index_template.json
@@ -8,9 +8,8 @@
"index" : {
"auto_expand_replicas" : "0-1",
"hidden": true
- },
- "index.lifecycle.name": "${xpack.ml.index.lifecycle.name}",
- "index.lifecycle.rollover_alias": "${xpack.ml.index.lifecycle.rollover_alias}"
+ }
+ ${xpack.ml.index.lifecycle.settings}
},
"mappings" : {
"_doc": {
diff --git a/x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/stats_index_template.json b/x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/stats_index_template.json
index b7df779b7a60b..223d1a79bad75 100644
--- a/x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/stats_index_template.json
+++ b/x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/stats_index_template.json
@@ -9,9 +9,8 @@
"number_of_shards" : "1",
"auto_expand_replicas" : "0-1",
"hidden": true
- },
- "index.lifecycle.name": "${xpack.ml.index.lifecycle.name}",
- "index.lifecycle.rollover_alias": "${xpack.ml.index.lifecycle.rollover_alias}"
+ }
+ ${xpack.ml.index.lifecycle.settings}
},
"mappings" : ${xpack.ml.stats.mappings},
"aliases" : {}
diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsageTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsageTests.java
index 0c99137481e7d..659cb4ed8cdb6 100644
--- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsageTests.java
+++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsageTests.java
@@ -28,18 +28,22 @@ protected IndexLifecycleFeatureSetUsage createTestInstance() {
policyStats.add(PolicyStatsTests.createRandomInstance());
}
}
- return new IndexLifecycleFeatureSetUsage(available, policyStats);
+ return new IndexLifecycleFeatureSetUsage(available, enabled, policyStats);
}
@Override
protected IndexLifecycleFeatureSetUsage mutateInstance(IndexLifecycleFeatureSetUsage instance) throws IOException {
boolean available = instance.available();
+ boolean enabled = instance.enabled();
List policyStats = instance.getPolicyStats();
- switch (between(0, 1)) {
+ switch (between(0, 2)) {
case 0:
available = available == false;
break;
case 1:
+ enabled = enabled == false;
+ break;
+ case 2:
if (policyStats == null) {
policyStats = new ArrayList<>();
policyStats.add(PolicyStatsTests.createRandomInstance());
@@ -53,7 +57,7 @@ protected IndexLifecycleFeatureSetUsage mutateInstance(IndexLifecycleFeatureSetU
default:
throw new AssertionError("Illegal randomisation branch");
}
- return new IndexLifecycleFeatureSetUsage(available, policyStats);
+ return new IndexLifecycleFeatureSetUsage(available, enabled, policyStats);
}
@Override
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 7e624d5f9d101..ce2b58ec5488b 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
@@ -38,6 +38,7 @@
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.ilm.AllocateAction;
import org.elasticsearch.xpack.core.ilm.DeleteAction;
import org.elasticsearch.xpack.core.ilm.ForceMergeAction;
@@ -140,10 +141,14 @@ public class IndexLifecycle extends Plugin implements ActionPlugin {
private final SetOnce snapshotRetentionService = new SetOnce<>();
private final SetOnce snapshotHistoryStore = new SetOnce<>();
private Settings settings;
+ private boolean ilmEnabled;
+ private boolean slmEnabled;
private boolean transportClientMode;
public IndexLifecycle(Settings settings) {
this.settings = settings;
+ this.ilmEnabled = XPackSettings.INDEX_LIFECYCLE_ENABLED.get(settings);
+ this.slmEnabled = XPackSettings.SNAPSHOT_LIFECYCLE_ENABLED.get(settings);
this.transportClientMode = XPackPlugin.transportClientMode(settings);
}
@@ -192,29 +197,31 @@ public Collection