Make index.lifecycle.name setting internal (#32518)
This commit makes the `index.lifecycle.name` setting internal an index, this means that the policy can only be set on the index creation, or with the specialized `RestSetIndexLifecyclePolicy` action. Relates to #29823
This commit is contained in:
parent
ea1e26ca27
commit
1bb7b53f26
|
@ -29,7 +29,7 @@ public class LifecycleSettings {
|
|||
public static final Setting<TimeValue> LIFECYCLE_POLL_INTERVAL_SETTING = Setting.positiveTimeSetting(LIFECYCLE_POLL_INTERVAL,
|
||||
TimeValue.timeValueSeconds(3), Setting.Property.Dynamic, Setting.Property.NodeScope);
|
||||
public static final Setting<String> LIFECYCLE_NAME_SETTING = Setting.simpleString(LIFECYCLE_NAME,
|
||||
Setting.Property.Dynamic, Setting.Property.IndexScope);
|
||||
Setting.Property.Dynamic, Setting.Property.IndexScope, Setting.Property.InternalIndex);
|
||||
public static final Setting<String> LIFECYCLE_PHASE_SETTING = Setting.simpleString(LIFECYCLE_PHASE,
|
||||
Setting.Property.Dynamic, Setting.Property.IndexScope, Setting.Property.InternalIndex);
|
||||
public static final Setting<String> LIFECYCLE_ACTION_SETTING = Setting.simpleString(LIFECYCLE_ACTION,
|
||||
|
|
|
@ -51,13 +51,18 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|||
policy = randomAlphaOfLength(5);
|
||||
}
|
||||
|
||||
public static void updatePolicy(String indexName, String policy) throws IOException {
|
||||
Request request = new Request("PUT", "/" + indexName + "/_lifecycle/" + policy);
|
||||
client().performRequest(request);
|
||||
}
|
||||
|
||||
public void testAllocate() throws Exception {
|
||||
createIndexWithSettings(index, Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 2)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0));
|
||||
String allocateNodeName = "node-" + randomFrom(0, 1);
|
||||
AllocateAction allocateAction = new AllocateAction(null, null, singletonMap("_name", allocateNodeName));
|
||||
createNewSingletonPolicy(randomFrom("warm", "cold"), allocateAction);
|
||||
updateIndexSettings(index, Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy));
|
||||
updatePolicy(index, policy);
|
||||
assertBusy(() -> {
|
||||
Map<String, Object> settings = getOnlyIndexSettings(index);
|
||||
assertThat(getStepKey(settings), equalTo(TerminalPolicyStep.KEY));
|
||||
|
@ -69,7 +74,7 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|||
createIndexWithSettings(index, Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0));
|
||||
createNewSingletonPolicy("delete", new DeleteAction());
|
||||
updateIndexSettings(index, Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy));
|
||||
updatePolicy(index, policy);
|
||||
assertBusy(() -> assertFalse(indexExists(index)));
|
||||
}
|
||||
|
||||
|
@ -77,7 +82,7 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|||
createIndexWithSettings(index, Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0));
|
||||
createNewSingletonPolicy("warm", new ReadOnlyAction());
|
||||
updateIndexSettings(index, Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy));
|
||||
updatePolicy(index, policy);
|
||||
assertBusy(() -> {
|
||||
Map<String, Object> settings = getOnlyIndexSettings(index);
|
||||
assertThat(getStepKey(settings), equalTo(TerminalPolicyStep.KEY));
|
||||
|
@ -111,7 +116,7 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|||
assertThat(numSegments.get(), greaterThan(1));
|
||||
|
||||
createNewSingletonPolicy("warm", new ForceMergeAction(1));
|
||||
updateIndexSettings(index, Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy));
|
||||
updatePolicy(index, policy);
|
||||
|
||||
assertBusy(() -> {
|
||||
assertThat(getStepKey(getOnlyIndexSettings(index)), equalTo(TerminalPolicyStep.KEY));
|
||||
|
@ -126,7 +131,7 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|||
createIndexWithSettings(index, Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, numReplicas));
|
||||
createNewSingletonPolicy(randomFrom("warm", "cold"), new ReplicasAction(finalNumReplicas));
|
||||
updateIndexSettings(index, Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy));
|
||||
updatePolicy(index, policy);
|
||||
|
||||
assertBusy(() -> {
|
||||
Map<String, Object> settings = getOnlyIndexSettings(index);
|
||||
|
@ -143,7 +148,7 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|||
createIndexWithSettings(index, Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0));
|
||||
createNewSingletonPolicy("warm", new ShrinkAction(expectedFinalShards));
|
||||
updateIndexSettings(index, Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy));
|
||||
updatePolicy(index, policy);
|
||||
assertBusy(() -> {
|
||||
assertTrue(indexExists(shrunkenIndex));
|
||||
assertTrue(aliasExists(shrunkenIndex, index));
|
||||
|
|
|
@ -219,10 +219,8 @@ setup:
|
|||
- match: { error.root_cause.0.reason: "Cannot delete policy [my_timeseries_lifecycle]. It is being used by at least one index [my_timeseries_index]" }
|
||||
|
||||
- do:
|
||||
indices.put_settings:
|
||||
xpack.index_lifecycle.remove_policy:
|
||||
index: my_timeseries_index
|
||||
body:
|
||||
index.lifecycle.name: ""
|
||||
|
||||
- do:
|
||||
acknowledge: true
|
||||
|
|
Loading…
Reference in New Issue