Skip to content

Add min_* conditions to rollover #83345

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

Merged
merged 59 commits into from
Jul 26, 2022
Merged
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
e6fe054
min conditions
probakowski Jan 20, 2022
12879c4
min conditions
probakowski Jan 31, 2022
2dfe23a
tests
probakowski Jan 31, 2022
a46dc91
Merge remote-tracking branch 'origin/master' into min-age
probakowski Jan 31, 2022
431f1a9
fix
probakowski Feb 1, 2022
d6a7569
remove unused method
probakowski Feb 1, 2022
4446623
tests
probakowski Feb 1, 2022
16b459f
import
probakowski Feb 1, 2022
c3438d1
spotless
probakowski Feb 1, 2022
84a89cd
Merge remote-tracking branch 'origin/master' into min-age
probakowski Feb 1, 2022
31c286b
fix test
probakowski Feb 1, 2022
3568399
fix imports
probakowski Feb 1, 2022
ac7a903
spotless
probakowski Feb 1, 2022
2aae5c8
spotless
probakowski Feb 1, 2022
6502e7d
fix compilation
probakowski Feb 1, 2022
3cf3dc9
fix tests
probakowski Feb 1, 2022
f74a590
spotless
probakowski Feb 1, 2022
b2821fc
Merge remote-tracking branch 'origin/master' into min-age
probakowski Feb 1, 2022
2d797c5
Merge remote-tracking branch 'origin/master' into min-age
probakowski Feb 24, 2022
721ab16
fix tests
probakowski Feb 24, 2022
6170581
fix tests
probakowski Feb 24, 2022
e036e58
spotless
probakowski Feb 24, 2022
39cf0bf
spotless
probakowski Feb 24, 2022
f7f377a
fix rolloveraction tests
probakowski Feb 24, 2022
a4ccd7a
Update docs/changelog/83345.yaml
probakowski Feb 24, 2022
c6ca948
Merge branch 'master' into min-age
joegallo Jun 29, 2022
aff95df
Bump min_* BWC version to 8.4.0
joegallo Jun 29, 2022
577e98d
Change visibility
joegallo Jun 29, 2022
b588c21
Add/rewrite these javadocs
joegallo Jun 29, 2022
7945472
Merge branch 'master' into min-age
joegallo Jul 22, 2022
9f54660
Typo, fix a comment
joegallo Jul 21, 2022
a50b1c7
Add min_size and min_primary_shard_docs
joegallo Jul 22, 2022
b6cc438
Actually, these tests were wrong as written
joegallo Jul 21, 2022
3ba144c
Test that we won't rollover with only min_* conditions
joegallo Jul 21, 2022
6d034f6
Add yaml rest tests
joegallo Jul 21, 2022
591de5c
Typo, fix variable case
joegallo Jul 22, 2022
dabb4d8
Fix a minor buglet
joegallo Jul 22, 2022
929077e
Pull out a randomByteSize test utility
joegallo Jul 22, 2022
1a3ee5f
Add min_* to ilm usage
joegallo Jul 22, 2022
7ee742d
Add some missing asserts in RolloverActionTests
joegallo Jul 22, 2022
bd91ba4
Fix these switch betweens
joegallo Jul 22, 2022
22b03f4
Oops, fix deserialization else branch
joegallo Jul 22, 2022
ebda57e
Nit: follow builder pattern
joegallo Jul 22, 2022
6e0d386
Add min_size, min_primary_shard_docs to NamedXContents
joegallo Jul 22, 2022
b4248ea
Don't leak a mutable map
joegallo Jul 22, 2022
573b384
Rewrite areConditionsMet slightly
joegallo Jul 22, 2022
f5bdfbe
Use areConditionsMet in the task executor, too
joegallo Jul 22, 2022
9c2c03d
Merge branch 'master' into min-age
joegallo Jul 22, 2022
e346d57
Whitespace
joegallo Jul 22, 2022
6658822
Add a validation rule to _rollover requests
joegallo Jul 22, 2022
7927ec9
Merge branch 'main' into min-age
joegallo Jul 25, 2022
3c990a8
Add/fix includedInVersion for min_* conditions
joegallo Jul 25, 2022
76249a4
Tidier RolloverAction Writeable implementation
joegallo Jul 25, 2022
becd6af
Nicer fromXContent error message for conditions
joegallo Jul 25, 2022
8a60331
Add a condition Type (MIN/MAX) and drop isRequired
joegallo Jul 25, 2022
4d1f3c1
Add javadoc for areConditionsMet
joegallo Jul 25, 2022
912120a
Simpler serialization for min_age and min_size
joegallo Jul 25, 2022
99769ed
Merge branch 'main' into min-age
joegallo Jul 25, 2022
bcfd250
Spotless
joegallo Jul 25, 2022
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
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
probakowski committed Feb 1, 2022
commit 31c286b04cde840fffb325a0949e6a735ddd6077
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,10 @@
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.json.JsonXContent;
import org.elasticsearch.xpack.core.ilm.AbstractStepTestCase;
import org.elasticsearch.xpack.core.ilm.ErrorStep;
import org.elasticsearch.xpack.core.ilm.IndexLifecycleMetadata;
import org.elasticsearch.xpack.core.ilm.LifecycleAction;
import org.elasticsearch.xpack.core.ilm.LifecyclePolicy;
import org.elasticsearch.xpack.core.ilm.LifecyclePolicyMetadata;
import org.elasticsearch.xpack.core.ilm.LifecyclePolicyTests;
import org.elasticsearch.xpack.core.ilm.LifecycleSettings;
import org.elasticsearch.xpack.core.ilm.MockAction;
import org.elasticsearch.xpack.core.ilm.MockStep;
import org.elasticsearch.xpack.core.ilm.OperationMode;
import org.elasticsearch.xpack.core.ilm.Phase;
import org.elasticsearch.xpack.core.ilm.PhaseCompleteStep;
import org.elasticsearch.xpack.core.ilm.RolloverAction;
import org.elasticsearch.xpack.core.ilm.RolloverStep;
import org.elasticsearch.xpack.core.ilm.SetPriorityAction;
import org.elasticsearch.xpack.core.ilm.Step;
import org.elasticsearch.xpack.core.ilm.WaitForRolloverReadyStep;
import org.elasticsearch.xpack.core.ilm.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand All @@ -60,11 +39,7 @@
import static org.elasticsearch.xpack.ilm.IndexLifecycleRunnerTests.createOneStepPolicyStepRegistry;
import static org.elasticsearch.xpack.ilm.IndexLifecycleTransition.moveStateToNextActionAndUpdateCachedPhase;
import static org.elasticsearch.xpack.ilm.LifecyclePolicyTestsUtils.newTestLifecyclePolicy;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.*;

public class IndexLifecycleTransitionTests extends ESTestCase {

Expand Down Expand Up @@ -382,7 +357,7 @@ public void testRemovePolicyForIndex() {
);
ClusterState clusterState = buildClusterState(indexName, indexSettingsBuilder, lifecycleState.build(), policyMetadatas);
Index index = clusterState.metadata().index(indexName).getIndex();
Index[] indices = new Index[] { index };
Index[] indices = new Index[]{index};
List<String> failedIndexes = new ArrayList<>();

ClusterState newClusterState = IndexLifecycleTransition.removePolicyForIndexes(indices, clusterState, failedIndexes);
Expand All @@ -401,7 +376,7 @@ public void testRemovePolicyForIndexNoCurrentPolicy() {
Collections.emptyList()
);
Index index = clusterState.metadata().index(indexName).getIndex();
Index[] indices = new Index[] { index };
Index[] indices = new Index[]{index};
List<String> failedIndexes = new ArrayList<>();

ClusterState newClusterState = IndexLifecycleTransition.removePolicyForIndexes(indices, clusterState, failedIndexes);
Expand All @@ -426,7 +401,7 @@ public void testRemovePolicyForIndexIndexDoesntExist() {
);
ClusterState clusterState = buildClusterState(indexName, indexSettingsBuilder, lifecycleState.build(), policyMetadatas);
Index index = new Index("doesnt_exist", "im_not_here");
Index[] indices = new Index[] { index };
Index[] indices = new Index[]{index};
List<String> failedIndexes = new ArrayList<>();

ClusterState newClusterState = IndexLifecycleTransition.removePolicyForIndexes(indices, clusterState, failedIndexes);
Expand All @@ -452,7 +427,7 @@ public void testRemovePolicyForIndexIndexInUnsafe() {
);
ClusterState clusterState = buildClusterState(indexName, indexSettingsBuilder, lifecycleState.build(), policyMetadatas);
Index index = clusterState.metadata().index(indexName).getIndex();
Index[] indices = new Index[] { index };
Index[] indices = new Index[]{index};
List<String> failedIndexes = new ArrayList<>();

ClusterState newClusterState = IndexLifecycleTransition.removePolicyForIndexes(indices, clusterState, failedIndexes);
Expand All @@ -479,7 +454,7 @@ public void testRemovePolicyWithIndexingComplete() {
);
ClusterState clusterState = buildClusterState(indexName, indexSettingsBuilder, lifecycleState.build(), policyMetadatas);
Index index = clusterState.metadata().index(indexName).getIndex();
Index[] indices = new Index[] { index };
Index[] indices = new Index[]{index};
List<String> failedIndexes = new ArrayList<>();

ClusterState newClusterState = IndexLifecycleTransition.removePolicyForIndexes(indices, clusterState, failedIndexes);
Expand Down Expand Up @@ -603,7 +578,7 @@ public void testValidateTransitionToCachedStepMissingFromPolicy() {
try (Client client = new NoOpClient(getTestName())) {
Step.StepKey currentStepKey = new Step.StepKey("hot", RolloverAction.NAME, WaitForRolloverReadyStep.NAME);
Step.StepKey nextStepKey = new Step.StepKey("hot", RolloverAction.NAME, RolloverStep.NAME);
Step currentStep = new WaitForRolloverReadyStep(currentStepKey, nextStepKey, client, null, null, null, 1L);
Step currentStep = new WaitForRolloverReadyStep(currentStepKey, nextStepKey, client, null, null, null, 1L, null, null, null);
try {
IndexLifecycleTransition.validateTransition(
meta,
Expand Down Expand Up @@ -906,7 +881,7 @@ public void testRefreshPhaseJson() throws IOException {
String index = meta.getIndex().getName();

Map<String, LifecycleAction> actions = new HashMap<>();
actions.put("rollover", new RolloverAction(null, null, null, 1L));
actions.put("rollover", new RolloverAction(null, null, null, 1L, null, null, null));
actions.put("set_priority", new SetPriorityAction(100));
Phase hotPhase = new Phase("hot", TimeValue.ZERO, actions);
Map<String, Phase> phases = Collections.singletonMap("hot", hotPhase);
Expand Down Expand Up @@ -1057,7 +1032,7 @@ public void testMoveStateToNextActionAndUpdateCachedPhase() {
IndexMetadata meta = buildIndexMetadata("my-policy", currentExecutionState);

Map<String, LifecycleAction> actions = new HashMap<>();
actions.put("rollover", new RolloverAction(null, null, null, 1L));
actions.put("rollover", new RolloverAction(null, null, null, 1L, null, null, null));
actions.put("set_priority", new SetPriorityAction(100));
Phase hotPhase = new Phase("hot", TimeValue.ZERO, actions);
Map<String, Phase> phases = Collections.singletonMap("hot", hotPhase);
Expand Down Expand Up @@ -1105,7 +1080,7 @@ public void testMoveStateToNextActionAndUpdateCachedPhase() {
// the expected new state is that the index is moved into the next action (could be the complete one) and the cached phase
// definition is updated
Map<String, LifecycleAction> actionsWitoutSetPriority = new HashMap<>();
actionsWitoutSetPriority.put("rollover", new RolloverAction(null, null, null, 1L));
actionsWitoutSetPriority.put("rollover", new RolloverAction(null, null, null, 1L, null, null, null));
Phase hotPhaseNoSetPriority = new Phase("hot", TimeValue.ZERO, actionsWitoutSetPriority);
Map<String, Phase> phasesWithoutSetPriority = Collections.singletonMap("hot", hotPhaseNoSetPriority);
LifecyclePolicyMetadata updatedPolicyMetadata = new LifecyclePolicyMetadata(
Expand Down