Skip to content

Commit 2b8b7c1

Browse files
Make ILM Steps use Infinite Master Timeout (#74143) (#74622)
Same as #72085 but for ILM. Having a timeout on these internal "requests" only adds more noise if master is slow already when timed out steps trigger moves to the error step. It seems like it is safe to remove the setting for the timeout outright as well as it was not used anywhere and never documented as far as I can tell.
1 parent a4908f8 commit 2b8b7c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+63
-161
lines changed

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
import org.elasticsearch.cluster.ClusterState;
1212
import org.elasticsearch.cluster.ClusterStateObserver;
1313
import org.elasticsearch.cluster.metadata.IndexMetadata;
14-
import org.elasticsearch.core.TimeValue;
15-
16-
import java.util.Objects;
1714

1815
/**
1916
* Performs an action which must be performed asynchronously because it may take time to complete.
@@ -31,11 +28,6 @@ protected Client getClient() {
3128
return client;
3229
}
3330

34-
public static TimeValue getMasterTimeout(ClusterState clusterState){
35-
Objects.requireNonNull(clusterState, "cannot determine master timeout when cluster state is null");
36-
return LifecycleSettings.LIFECYCLE_STEP_MASTER_TIMEOUT_SETTING.get(clusterState.metadata().settings());
37-
}
38-
3931
public boolean indexSurvives() {
4032
return true;
4133
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.cluster.ClusterState;
1616
import org.elasticsearch.cluster.metadata.IndexMetadata;
1717
import org.elasticsearch.common.Strings;
18+
import org.elasticsearch.core.TimeValue;
1819
import org.elasticsearch.index.IndexNotFoundException;
1920

2021
import static org.elasticsearch.xpack.core.ilm.LifecycleExecutionState.fromIndexMetadata;
@@ -59,7 +60,7 @@ void performDuringNoSnapshot(IndexMetadata indexMetadata, ClusterState currentCl
5960
return;
6061
}
6162
getClient().admin().indices()
62-
.delete(new DeleteIndexRequest(shrinkIndexName).masterNodeTimeout(getMasterTimeout(currentClusterState)),
63+
.delete(new DeleteIndexRequest(shrinkIndexName).masterNodeTimeout(TimeValue.MAX_VALUE),
6364
new ActionListener<AcknowledgedResponse>() {
6465
@Override
6566
public void onResponse(AcknowledgedResponse acknowledgedResponse) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
import org.elasticsearch.ElasticsearchException;
1010
import org.elasticsearch.action.ActionListener;
11-
import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest;
1211
import org.elasticsearch.action.support.master.AcknowledgedResponse;
1312
import org.elasticsearch.client.Client;
1413
import org.elasticsearch.cluster.ClusterState;
1514
import org.elasticsearch.cluster.metadata.IndexMetadata;
1615
import org.elasticsearch.common.Strings;
16+
import org.elasticsearch.core.TimeValue;
1717
import org.elasticsearch.repositories.RepositoryMissingException;
1818
import org.elasticsearch.snapshots.SnapshotMissingException;
1919

@@ -50,8 +50,8 @@ void performDuringNoSnapshot(IndexMetadata indexMetadata, ClusterState currentCl
5050
listener.onResponse(true);
5151
return;
5252
}
53-
DeleteSnapshotRequest deleteSnapshotRequest = new DeleteSnapshotRequest(repositoryName, snapshotName);
54-
getClient().admin().cluster().deleteSnapshot(deleteSnapshotRequest, new ActionListener<AcknowledgedResponse>() {
53+
getClient().admin().cluster().prepareDeleteSnapshot(repositoryName, snapshotName).setMasterNodeTimeout(TimeValue.MAX_VALUE)
54+
.execute(new ActionListener<AcknowledgedResponse>() {
5555

5656
@Override
5757
public void onResponse(AcknowledgedResponse acknowledgedResponse) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.elasticsearch.client.Client;
1313
import org.elasticsearch.cluster.ClusterState;
1414
import org.elasticsearch.cluster.metadata.IndexMetadata;
15+
import org.elasticsearch.core.TimeValue;
1516

1617
import java.util.Map;
1718

@@ -41,7 +42,7 @@ void performDuringNoSnapshot(IndexMetadata indexMetadata, ClusterState currentCl
4142

4243
if (indexMetadata.getState() == IndexMetadata.State.OPEN) {
4344
CloseIndexRequest closeIndexRequest = new CloseIndexRequest(followerIndex)
44-
.masterNodeTimeout(getMasterTimeout(currentClusterState));
45+
.masterNodeTimeout(TimeValue.MAX_VALUE);
4546
getClient().admin().indices().close(closeIndexRequest, ActionListener.wrap(
4647
r -> {
4748
if (r.isAcknowledged() == false) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.cluster.ClusterState;
1515
import org.elasticsearch.cluster.ClusterStateObserver;
1616
import org.elasticsearch.cluster.metadata.IndexMetadata;
17+
import org.elasticsearch.core.TimeValue;
1718

1819
/**
1920
* Invokes a close step on a single index.
@@ -30,7 +31,7 @@ public class CloseIndexStep extends AsyncActionStep {
3031
public void performAction(IndexMetadata indexMetadata, ClusterState currentClusterState,
3132
ClusterStateObserver observer, ActionListener<Boolean> listener) {
3233
if (indexMetadata.getState() == IndexMetadata.State.OPEN) {
33-
CloseIndexRequest request = new CloseIndexRequest(indexMetadata.getIndex().getName());
34+
CloseIndexRequest request = new CloseIndexRequest(indexMetadata.getIndex().getName()).masterNodeTimeout(TimeValue.MAX_VALUE);
3435
getClient().admin().indices()
3536
.close(request, ActionListener.wrap(closeIndexResponse -> {
3637
if (closeIndexResponse.isAcknowledged() == false) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.cluster.ClusterState;
1616
import org.elasticsearch.cluster.metadata.IndexMetadata;
1717
import org.elasticsearch.common.Strings;
18+
import org.elasticsearch.core.TimeValue;
1819
import org.elasticsearch.snapshots.SnapshotInfo;
1920

2021
import java.util.Locale;
@@ -65,7 +66,7 @@ void performDuringNoSnapshot(IndexMetadata indexMetadata, ClusterState currentCl
6566
// complete
6667
request.waitForCompletion(true);
6768
request.includeGlobalState(false);
68-
request.masterNodeTimeout(getMasterTimeout(currentClusterState));
69+
request.masterNodeTimeout(TimeValue.MAX_VALUE);
6970
getClient().admin().cluster().createSnapshot(request,
7071
ActionListener.wrap(response -> {
7172
logger.debug("create snapshot response for policy [{}] and index [{}] is: {}", policyName, indexName,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.cluster.ClusterState;
1515
import org.elasticsearch.cluster.metadata.IndexAbstraction;
1616
import org.elasticsearch.cluster.metadata.IndexMetadata;
17+
import org.elasticsearch.core.TimeValue;
1718
import org.elasticsearch.xpack.core.action.DeleteDataStreamAction;
1819

1920
import java.util.Locale;
@@ -57,7 +58,7 @@ public void performDuringNoSnapshot(IndexMetadata indexMetadata, ClusterState cu
5758
}
5859

5960
getClient().admin().indices()
60-
.delete(new DeleteIndexRequest(indexName).masterNodeTimeout(getMasterTimeout(currentState)),
61+
.delete(new DeleteIndexRequest(indexName).masterNodeTimeout(TimeValue.MAX_VALUE),
6162
ActionListener.wrap(response -> listener.onResponse(true), listener::onFailure));
6263
}
6364

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.client.Client;
1212
import org.elasticsearch.cluster.ClusterState;
1313
import org.elasticsearch.cluster.metadata.IndexMetadata;
14+
import org.elasticsearch.core.TimeValue;
1415
import org.elasticsearch.protocol.xpack.frozen.FreezeRequest;
1516
import org.elasticsearch.xpack.core.frozen.action.FreezeIndexAction;
1617

@@ -27,7 +28,7 @@ public FreezeStep(StepKey key, StepKey nextStepKey, Client client) {
2728
@Override
2829
public void performDuringNoSnapshot(IndexMetadata indexMetadata, ClusterState currentState, ActionListener<Boolean> listener) {
2930
getClient().admin().indices().execute(FreezeIndexAction.INSTANCE,
30-
new FreezeRequest(indexMetadata.getIndex().getName()).masterNodeTimeout(getMasterTimeout(currentState)),
31+
new FreezeRequest(indexMetadata.getIndex().getName()).masterNodeTimeout(TimeValue.MAX_VALUE),
3132
ActionListener.wrap(response -> {
3233
if (response.isAcknowledged() == false) {
3334
throw new ElasticsearchException("freeze index request failed to be acknowledged");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class LifecycleSettings {
4949
true, Setting.Property.NodeScope);
5050
public static final Setting<TimeValue> LIFECYCLE_STEP_MASTER_TIMEOUT_SETTING =
5151
Setting.positiveTimeSetting(LIFECYCLE_STEP_MASTER_TIMEOUT, TimeValue.timeValueSeconds(30), Setting.Property.Dynamic,
52-
Setting.Property.NodeScope);
52+
Setting.Property.NodeScope, Setting.Property.Deprecated);
5353
// This setting configures how much time since step_time should ILM wait for a condition to be met. After the threshold wait time has
5454
// elapsed ILM will likely stop waiting and go to the next step.
5555
// Also see {@link org.elasticsearch.xpack.core.ilm.ClusterStateWaitUntilThresholdStep}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.cluster.metadata.IndexMetadata;
1616
import org.elasticsearch.common.Strings;
1717
import org.elasticsearch.common.settings.Settings;
18+
import org.elasticsearch.core.TimeValue;
1819
import org.elasticsearch.rest.RestStatus;
1920
import org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider;
2021
import org.elasticsearch.xpack.core.DataTier;
@@ -120,6 +121,7 @@ void performDuringNoSnapshot(IndexMetadata indexMetadata, ClusterState currentCl
120121
// perform expensive operations (ie. clusterStateProcessed)
121122
false,
122123
storageType);
124+
mountSearchableSnapshotRequest.masterNodeTimeout(TimeValue.MAX_VALUE);
123125
getClient().execute(MountSearchableSnapshotAction.INSTANCE, mountSearchableSnapshotRequest,
124126
ActionListener.wrap(response -> {
125127
if (response.status() != RestStatus.OK && response.status() != RestStatus.ACCEPTED) {

0 commit comments

Comments
 (0)