Skip to content

Commit 252a871

Browse files
Restore xpack.ilm.enabled and xpack.slm.enabled settings (elastic#57383)
In elastic#55592 and elastic#55416, we deprecated the settings for enabling and disabling basic license features and turned those settings into no-ops. Since doing so, we've had feedback that this change may not give users enough time to cleanly switch from non-ILM index management tools to ILM. If two index managers operate simultaneously, results could be strange and difficult to reconstruct. We don't know of any cases where SLM will cause a problem, but we are restoring that setting as well, to be on the safe side. This PR is not a strict commit reversion. First, we are keeping the new xpack.watcher.use_ilm_index_management setting, introduced when xpack.ilm.enabled was made a no-op, so that users can begin migrating to using it. Second, the SLM setting was modified in the same commit as a group of other settings, so I have taken just the changes relating to SLM.
1 parent bf3a347 commit 252a871

File tree

17 files changed

+292
-149
lines changed

17 files changed

+292
-149
lines changed

docs/reference/migration/migrate_7_8.asciidoc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,30 @@ setting.
9494

9595
[[deprecate-basic-license-feature-enabled]]
9696

97-
.Several {xpack} settings no longer have any effect and are deprecated.
97+
.Several {xpack} settings no longer have any effect and are deprecated.
9898

9999
[%collapsible]
100100
====
101101
*Details* +
102-
Basic {xpack} license features are always enabled for the {default-dist}
103-
and the following settings no longer have any effect:
102+
Basic {xpack} license features are always enabled for the {default-dist}
103+
and the following settings no longer have any effect:
104104
105105
* `xpack.enrich.enabled`
106106
* `xpack.flattened.enabled`
107-
* `xpack.ilm.enabled`
108107
* `xpack.monitoring.enabled`
109108
* `xpack.rollup.enabled`
110-
* `xpack.slm.enabled`
111109
* `xpack.sql.enabled`
112110
* `xpack.transform.enabled`
113111
* `xpack.vectors.enabled`
114112
115113
Previously, they could be set to `false` to disable the feature's APIs in a cluster.
116114
115+
The ILM and SLM settings have been deprecated, but still have the effect of disabling
116+
their respective APIs:
117+
118+
* `xpack.ilm.enabled`
119+
* `xpack.slm.enabled`
120+
117121
*Impact* +
118122
To avoid deprecation warnings, discontinue use of these settings.
119123
If you have disabled ILM so that you can use another tool to manage Watcher

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,13 @@ private XPackSettings() {
118118

119119
/**
120120
* Setting for enabling or disabling the index lifecycle extension. Defaults to true.
121-
* <p>
122-
* This setting is now a no-op: setting it to false is permitted, but does nothing.
123121
*/
124122
@Deprecated // since 7.8.0
125123
public static final Setting<Boolean> INDEX_LIFECYCLE_ENABLED = Setting.boolSetting("xpack.ilm.enabled", true,
126124
Property.NodeScope, Property.Deprecated);
127125

128126
/**
129127
* Setting for enabling or disabling the snapshot lifecycle extension. Defaults to true.
130-
* <p>
131-
* This setting is now a no-op: setting it to false is permitted, but does nothing.
132128
*/
133129
@Deprecated // since = "7.8.0"
134130
public static final Setting<Boolean> SNAPSHOT_LIFECYCLE_ENABLED = Setting.boolSetting("xpack.slm.enabled", true,

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsage.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ public void writeTo(StreamOutput out) throws IOException {
4949
}
5050
}
5151

52-
public IndexLifecycleFeatureSetUsage(boolean available) {
53-
this(available, null);
52+
public IndexLifecycleFeatureSetUsage(boolean available, boolean enabled) {
53+
this(available, enabled, null);
5454
}
5555

56-
public IndexLifecycleFeatureSetUsage(boolean available, List<PolicyStats> policyStats) {
57-
super(XPackField.INDEX_LIFECYCLE, available, true);
56+
public IndexLifecycleFeatureSetUsage(boolean available, boolean enabled, List<PolicyStats> policyStats) {
57+
super(XPackField.INDEX_LIFECYCLE, available, enabled);
5858
this.policyStats = policyStats;
5959
}
6060

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/SLMFeatureSetUsage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public void writeTo(StreamOutput out) throws IOException {
3333
out.writeOptionalWriteable(this.slmStats);
3434
}
3535

36-
public SLMFeatureSetUsage(boolean available, @Nullable SnapshotLifecycleStats slmStats) {
37-
super(XPackField.SNAPSHOT_LIFECYCLE, available, true);
36+
public SLMFeatureSetUsage(boolean available, boolean enabled, @Nullable SnapshotLifecycleStats slmStats) {
37+
super(XPackField.SNAPSHOT_LIFECYCLE, available, enabled);
3838
this.slmStats = slmStats;
3939
}
4040

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/IndexTemplateRegistry.java

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.elasticsearch.gateway.GatewayService;
2727
import org.elasticsearch.threadpool.ThreadPool;
2828
import org.elasticsearch.xpack.core.XPackClient;
29+
import org.elasticsearch.xpack.core.XPackSettings;
2930
import org.elasticsearch.xpack.core.ilm.IndexLifecycleMetadata;
3031
import org.elasticsearch.xpack.core.ilm.LifecyclePolicy;
3132
import org.elasticsearch.xpack.core.ilm.action.PutLifecycleAction;
@@ -202,26 +203,29 @@ public void onFailure(Exception e) {
202203
}
203204

204205
private void addIndexLifecyclePoliciesIfMissing(ClusterState state) {
206+
boolean ilmSupported = XPackSettings.INDEX_LIFECYCLE_ENABLED.get(settings);
205207

206-
Optional<IndexLifecycleMetadata> maybeMeta = Optional.ofNullable(state.metadata().custom(IndexLifecycleMetadata.TYPE));
207-
List<LifecyclePolicy> policies = getPolicyConfigs().stream()
208-
.map(policyConfig -> policyConfig.load(xContentRegistry))
209-
.collect(Collectors.toList());
208+
if (ilmSupported) {
209+
Optional<IndexLifecycleMetadata> maybeMeta = Optional.ofNullable(state.metadata().custom(IndexLifecycleMetadata.TYPE));
210+
List<LifecyclePolicy> policies = getPolicyConfigs().stream()
211+
.map(policyConfig -> policyConfig.load(xContentRegistry))
212+
.collect(Collectors.toList());
210213

211-
for (LifecyclePolicy policy : policies) {
212-
final AtomicBoolean creationCheck = policyCreationsInProgress.computeIfAbsent(policy.getName(),
213-
key -> new AtomicBoolean(false));
214-
if (creationCheck.compareAndSet(false, true)) {
215-
final boolean policyNeedsToBeCreated = maybeMeta
216-
.flatMap(ilmMeta -> Optional.ofNullable(ilmMeta.getPolicies().get(policy.getName())))
217-
.isPresent() == false;
218-
if (policyNeedsToBeCreated) {
219-
logger.debug("adding lifecycle policy [{}] for [{}], because it doesn't exist", policy.getName(), getOrigin());
220-
putPolicy(policy, creationCheck);
221-
} else {
222-
logger.trace("not adding lifecycle policy [{}] for [{}], because it already exists",
223-
policy.getName(), getOrigin());
224-
creationCheck.set(false);
214+
for (LifecyclePolicy policy : policies) {
215+
final AtomicBoolean creationCheck = policyCreationsInProgress.computeIfAbsent(policy.getName(),
216+
key -> new AtomicBoolean(false));
217+
if (creationCheck.compareAndSet(false, true)) {
218+
final boolean policyNeedsToBeCreated = maybeMeta
219+
.flatMap(ilmMeta -> Optional.ofNullable(ilmMeta.getPolicies().get(policy.getName())))
220+
.isPresent() == false;
221+
if (policyNeedsToBeCreated) {
222+
logger.debug("adding lifecycle policy [{}] for [{}], because it doesn't exist", policy.getName(), getOrigin());
223+
putPolicy(policy, creationCheck);
224+
} else {
225+
logger.trace("not adding lifecycle policy [{}] for [{}], because it already exists",
226+
policy.getName(), getOrigin());
227+
creationCheck.set(false);
228+
}
225229
}
226230
}
227231
}

x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/anomalydetection/state_index_template.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
"index" : {
99
"auto_expand_replicas" : "0-1",
1010
"hidden": true
11-
},
12-
"index.lifecycle.name": "${xpack.ml.index.lifecycle.name}",
13-
"index.lifecycle.rollover_alias": "${xpack.ml.index.lifecycle.rollover_alias}"
11+
}
12+
${xpack.ml.index.lifecycle.settings}
1413
},
1514
"mappings" : {
1615
"_doc": {

x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/stats_index_template.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
"number_of_shards" : "1",
1010
"auto_expand_replicas" : "0-1",
1111
"hidden": true
12-
},
13-
"index.lifecycle.name": "${xpack.ml.index.lifecycle.name}",
14-
"index.lifecycle.rollover_alias": "${xpack.ml.index.lifecycle.rollover_alias}"
12+
}
13+
${xpack.ml.index.lifecycle.settings}
1514
},
1615
"mappings" : ${xpack.ml.stats.mappings},
1716
"aliases" : {}

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsageTests.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,22 @@ protected IndexLifecycleFeatureSetUsage createTestInstance() {
2828
policyStats.add(PolicyStatsTests.createRandomInstance());
2929
}
3030
}
31-
return new IndexLifecycleFeatureSetUsage(available, policyStats);
31+
return new IndexLifecycleFeatureSetUsage(available, enabled, policyStats);
3232
}
3333

3434
@Override
3535
protected IndexLifecycleFeatureSetUsage mutateInstance(IndexLifecycleFeatureSetUsage instance) throws IOException {
3636
boolean available = instance.available();
37+
boolean enabled = instance.enabled();
3738
List<PolicyStats> policyStats = instance.getPolicyStats();
38-
switch (between(0, 1)) {
39+
switch (between(0, 2)) {
3940
case 0:
4041
available = available == false;
4142
break;
4243
case 1:
44+
enabled = enabled == false;
45+
break;
46+
case 2:
4347
if (policyStats == null) {
4448
policyStats = new ArrayList<>();
4549
policyStats.add(PolicyStatsTests.createRandomInstance());
@@ -53,7 +57,7 @@ protected IndexLifecycleFeatureSetUsage mutateInstance(IndexLifecycleFeatureSetU
5357
default:
5458
throw new AssertionError("Illegal randomisation branch");
5559
}
56-
return new IndexLifecycleFeatureSetUsage(available, policyStats);
60+
return new IndexLifecycleFeatureSetUsage(available, enabled, policyStats);
5761
}
5862

5963
@Override

0 commit comments

Comments
 (0)