Skip to content

Commit c8aa8ea

Browse files
committed
Maintain step order for ILM trace logging (#39522)
When trace logging is enabled we log the computed steps for a policy. This commit makes sure that the steps that are logged are in the same order they will be run when the policy executes. This makes it much easier to reason about the policy if the move-to-step API is ever required in the future.
1 parent 7d1182b commit c8aa8ea

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/PolicyStepsRegistry.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.io.IOException;
4040
import java.util.ArrayList;
4141
import java.util.HashMap;
42+
import java.util.LinkedHashMap;
4243
import java.util.List;
4344
import java.util.Map;
4445
import java.util.Optional;
@@ -125,7 +126,7 @@ public LifecyclePolicyMetadata read(StreamInput in, String key) {
125126
List<Step> policyAsSteps = policyMetadata.getPolicy().toSteps(policyClient);
126127
if (policyAsSteps.isEmpty() == false) {
127128
firstStepMap.put(policyMetadata.getName(), policyAsSteps.get(0));
128-
final Map<Step.StepKey, Step> stepMapForPolicy = new HashMap<>();
129+
final Map<Step.StepKey, Step> stepMapForPolicy = new LinkedHashMap<>();
129130
for (Step step : policyAsSteps) {
130131
assert ErrorStep.NAME.equals(step.getKey().getName()) == false : "unexpected error step in policy";
131132
stepMapForPolicy.put(step.getKey(), step);

0 commit comments

Comments
 (0)