Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make xpack.ilm.enabled setting a no-op (#55592) #55980

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions docs/reference/migration/migrate_7_0/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,22 @@ greater than `Integer.MAX_VALUE`. This leniency has been removed.
[float]
==== Option to disable basic license features is deprecated

In Elasticsearch 7.8.0, the following settings have been deprecated:
In Elasticsearch 7.8.0, the following settings no longer have any effect, and
have been deprecated:

* `xpack.ilm.enabled`

In other words, even if `xpack.ilm.enabled` is set to `false`, the ILM APIs
will be available.

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:

* `xpack.enrich.enabled`
* `xpack.flattened.enabled`
* `xpack.ilm.enabled`
* `xpack.monitoring.enabled`
* `xpack.rollup.enabled`
* `xpack.slm.enabled`
Expand All @@ -305,4 +316,4 @@ In Elasticsearch 7.8.0, the following settings have been deprecated:
* `xpack.vectors.enabled`

In future releases, it will not be possible to disable the APIs for Enrichment,
Flattened mappings, ILM, Monitoring, Rollup, SLM, SQL, Transforms, and Vectors.
Flattened mappings, Monitoring, Rollup, SLM, SQL, Transforms, and Vectors.
5 changes: 2 additions & 3 deletions docs/reference/settings/ilm-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ These are the settings available for configuring Index Lifecycle Management
==== Cluster level settings

`xpack.ilm.enabled`::
deprecated:[7.8.0,Basic License features should always be enabled] +
Whether ILM is enabled or disabled, setting this to `false` disables any ILM
REST API endpoints and functionality. Defaults to `true`.
deprecated:[7.8.0,Basic License features are always enabled] +
This deprecated setting has no effect and will be removed in Elasticsearch 8.0.

`indices.lifecycle.poll_interval`::
(<<time-units, time units>>) How often {ilm} checks for indices that meet policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ private XPackSettings() {

/**
* Setting for enabling or disabling the index lifecycle extension. Defaults to true.
* <p>
* 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<Boolean> INDEX_LIFECYCLE_ENABLED = Setting.boolSetting("xpack.ilm.enabled", true,
Property.NodeScope, Property.Deprecated);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public void writeTo(StreamOutput out) throws IOException {
}
}

public IndexLifecycleFeatureSetUsage(boolean available, boolean enabled) {
this(available, enabled, null);
public IndexLifecycleFeatureSetUsage(boolean available) {
this(available, null);
}

public IndexLifecycleFeatureSetUsage(boolean available, boolean enabled, List<PolicyStats> policyStats) {
super(XPackField.INDEX_LIFECYCLE, available, enabled);
public IndexLifecycleFeatureSetUsage(boolean available, List<PolicyStats> policyStats) {
super(XPackField.INDEX_LIFECYCLE, available, true);
this.policyStats = policyStats;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
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;
Expand Down Expand Up @@ -203,29 +202,26 @@ public void onFailure(Exception e) {
}

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

if (ilmSupported) {
Optional<IndexLifecycleMetadata> maybeMeta = Optional.ofNullable(state.metadata().custom(IndexLifecycleMetadata.TYPE));
List<LifecyclePolicy> policies = getPolicyConfigs().stream()
.map(policyConfig -> policyConfig.load(xContentRegistry))
.collect(Collectors.toList());
Optional<IndexLifecycleMetadata> maybeMeta = Optional.ofNullable(state.metadata().custom(IndexLifecycleMetadata.TYPE));
List<LifecyclePolicy> 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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"index" : {
"auto_expand_replicas" : "0-1",
"hidden": true
}
${xpack.ml.index.lifecycle.settings}
},
"index.lifecycle.name": "${xpack.ml.index.lifecycle.name}",
"index.lifecycle.rollover_alias": "${xpack.ml.index.lifecycle.rollover_alias}"
},
"mappings" : {
"_doc": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"number_of_shards" : "1",
"auto_expand_replicas" : "0-1",
"hidden": true
}
${xpack.ml.index.lifecycle.settings}
},
"index.lifecycle.name": "${xpack.ml.index.lifecycle.name}",
"index.lifecycle.rollover_alias": "${xpack.ml.index.lifecycle.rollover_alias}"
},
"mappings" : ${xpack.ml.stats.mappings},
"aliases" : {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,18 @@ protected IndexLifecycleFeatureSetUsage createTestInstance() {
policyStats.add(PolicyStatsTests.createRandomInstance());
}
}
return new IndexLifecycleFeatureSetUsage(available, enabled, policyStats);
return new IndexLifecycleFeatureSetUsage(available, policyStats);
}

@Override
protected IndexLifecycleFeatureSetUsage mutateInstance(IndexLifecycleFeatureSetUsage instance) throws IOException {
boolean available = instance.available();
boolean enabled = instance.enabled();
List<PolicyStats> policyStats = instance.getPolicyStats();
switch (between(0, 2)) {
switch (between(0, 1)) {
case 0:
available = available == false;
break;
case 1:
enabled = enabled == false;
break;
case 2:
if (policyStats == null) {
policyStats = new ArrayList<>();
policyStats.add(PolicyStatsTests.createRandomInstance());
Expand All @@ -57,7 +53,7 @@ protected IndexLifecycleFeatureSetUsage mutateInstance(IndexLifecycleFeatureSetU
default:
throw new AssertionError("Illegal randomisation branch");
}
return new IndexLifecycleFeatureSetUsage(available, enabled, policyStats);
return new IndexLifecycleFeatureSetUsage(available, policyStats);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,11 @@ public class IndexLifecycle extends Plugin implements ActionPlugin {
private final SetOnce<SnapshotRetentionService> snapshotRetentionService = new SetOnce<>();
private final SetOnce<SnapshotHistoryStore> 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);
}
Expand Down Expand Up @@ -197,17 +195,15 @@ public Collection<Object> createComponents(Client client, ClusterService cluster
return Collections.emptyList();
}
final List<Object> components = new ArrayList<>();
if (ilmEnabled) {
// This registers a cluster state listener, so appears unused but is not.
@SuppressWarnings("unused")
ILMHistoryTemplateRegistry ilmTemplateRegistry =
new ILMHistoryTemplateRegistry(settings, clusterService, threadPool, client, xContentRegistry);
ilmHistoryStore.set(new ILMHistoryStore(settings, new OriginSettingClient(client, INDEX_LIFECYCLE_ORIGIN),
clusterService, threadPool));
indexLifecycleInitialisationService.set(new IndexLifecycleService(settings, client, clusterService, threadPool,
getClock(), System::currentTimeMillis, xContentRegistry, ilmHistoryStore.get()));
components.add(indexLifecycleInitialisationService.get());
}
// This registers a cluster state listener, so appears unused but is not.
@SuppressWarnings("unused")
ILMHistoryTemplateRegistry ilmTemplateRegistry =
new ILMHistoryTemplateRegistry(settings, clusterService, threadPool, client, xContentRegistry);
ilmHistoryStore.set(new ILMHistoryStore(settings, new OriginSettingClient(client, INDEX_LIFECYCLE_ORIGIN),
clusterService, threadPool));
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")
Expand Down Expand Up @@ -263,20 +259,19 @@ public List<RestHandler> getRestHandlers(Settings settings, RestController restC
IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<DiscoveryNodes> nodesInCluster) {
List<RestHandler> handlers = new ArrayList<>();
if (ilmEnabled) {
handlers.addAll(Arrays.asList(
new RestPutLifecycleAction(),
new RestGetLifecycleAction(),
new RestDeleteLifecycleAction(),
new RestExplainLifecycleAction(),
new RestRemoveIndexLifecyclePolicyAction(),
new RestMoveToStepAction(),
new RestRetryAction(),
new RestStopAction(),
new RestStartILMAction(),
new RestGetStatusAction()
));
}
// add ILM rest handlers
handlers.addAll(Arrays.asList(
new RestPutLifecycleAction(),
new RestGetLifecycleAction(),
new RestDeleteLifecycleAction(),
new RestExplainLifecycleAction(),
new RestRemoveIndexLifecyclePolicyAction(),
new RestMoveToStepAction(),
new RestRetryAction(),
new RestStopAction(),
new RestStartILMAction(),
new RestGetStatusAction()
));
if (slmEnabled) {
handlers.addAll(Arrays.asList(
new RestPutSnapshotLifecycleAction(),
Expand All @@ -296,20 +291,19 @@ public List<RestHandler> getRestHandlers(Settings settings, RestController restC
@Override
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> actions = new ArrayList<>();
if (ilmEnabled) {
actions.addAll(Arrays.asList(
new ActionHandler<>(PutLifecycleAction.INSTANCE, TransportPutLifecycleAction.class),
new ActionHandler<>(GetLifecycleAction.INSTANCE, TransportGetLifecycleAction.class),
new ActionHandler<>(DeleteLifecycleAction.INSTANCE, TransportDeleteLifecycleAction.class),
new ActionHandler<>(ExplainLifecycleAction.INSTANCE, TransportExplainLifecycleAction.class),
new ActionHandler<>(RemoveIndexLifecyclePolicyAction.INSTANCE, TransportRemoveIndexLifecyclePolicyAction.class),
new ActionHandler<>(MoveToStepAction.INSTANCE, TransportMoveToStepAction.class),
new ActionHandler<>(RetryAction.INSTANCE, TransportRetryAction.class),
new ActionHandler<>(StartILMAction.INSTANCE, TransportStartILMAction.class),
new ActionHandler<>(StopILMAction.INSTANCE, TransportStopILMAction.class),
new ActionHandler<>(GetStatusAction.INSTANCE, TransportGetStatusAction.class)
));
}
// add ILM actions
actions.addAll(Arrays.asList(
new ActionHandler<>(PutLifecycleAction.INSTANCE, TransportPutLifecycleAction.class),
new ActionHandler<>(GetLifecycleAction.INSTANCE, TransportGetLifecycleAction.class),
new ActionHandler<>(DeleteLifecycleAction.INSTANCE, TransportDeleteLifecycleAction.class),
new ActionHandler<>(ExplainLifecycleAction.INSTANCE, TransportExplainLifecycleAction.class),
new ActionHandler<>(RemoveIndexLifecyclePolicyAction.INSTANCE, TransportRemoveIndexLifecyclePolicyAction.class),
new ActionHandler<>(MoveToStepAction.INSTANCE, TransportMoveToStepAction.class),
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),
Expand All @@ -328,10 +322,8 @@ public List<RestHandler> getRestHandlers(Settings settings, RestController restC

@Override
public void onIndexModule(IndexModule indexModule) {
if (ilmEnabled) {
assert indexLifecycleInitialisationService.get() != null;
indexModule.addIndexEventListener(indexLifecycleInitialisationService.get());
}
assert indexLifecycleInitialisationService.get() != null;
indexModule.addIndexEventListener(indexLifecycleInitialisationService.get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.xpack.core.XPackFeatureSet;
import org.elasticsearch.xpack.core.XPackField;
import org.elasticsearch.xpack.core.XPackSettings;
import org.elasticsearch.xpack.core.ilm.IndexLifecycleFeatureSetUsage;
import org.elasticsearch.xpack.core.ilm.IndexLifecycleFeatureSetUsage.PhaseStats;
import org.elasticsearch.xpack.core.ilm.IndexLifecycleFeatureSetUsage.PolicyStats;
Expand All @@ -29,14 +27,12 @@

public class IndexLifecycleFeatureSet implements XPackFeatureSet {

private final boolean enabled;
private final XPackLicenseState licenseState;
private ClusterService clusterService;

@Inject
public IndexLifecycleFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState, ClusterService clusterService) {
public IndexLifecycleFeatureSet(@Nullable XPackLicenseState licenseState, ClusterService clusterService) {
this.clusterService = clusterService;
this.enabled = XPackSettings.INDEX_LIFECYCLE_ENABLED.get(settings);
this.licenseState = licenseState;
}

Expand All @@ -52,7 +48,7 @@ public boolean available() {

@Override
public boolean enabled() {
return enabled;
return true;
}

@Override
Expand Down Expand Up @@ -83,9 +79,9 @@ public void usage(ActionListener<XPackFeatureSet.Usage> listener) {
}).collect(Collectors.toMap(Tuple::v1, Tuple::v2));
return new PolicyStats(phaseStats, policyUsage.getOrDefault(policy.getName(), 0));
}).collect(Collectors.toList());
listener.onResponse(new IndexLifecycleFeatureSetUsage(available(), enabled(), policyStats));
listener.onResponse(new IndexLifecycleFeatureSetUsage(available(), policyStats));
} else {
listener.onResponse(new IndexLifecycleFeatureSetUsage(available(), enabled()));
listener.onResponse(new IndexLifecycleFeatureSetUsage(available()));
}
}

Expand Down
Loading