Skip to content

Commit

Permalink
Maintain step order for ILM trace logging (#39522)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dakrone committed Mar 7, 2019
1 parent e8fe942 commit 1449f64
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -125,7 +126,7 @@ public LifecyclePolicyMetadata read(StreamInput in, String key) {
List<Step> policyAsSteps = policyMetadata.getPolicy().toSteps(policyClient);
if (policyAsSteps.isEmpty() == false) {
firstStepMap.put(policyMetadata.getName(), policyAsSteps.get(0));
final Map<Step.StepKey, Step> stepMapForPolicy = new HashMap<>();
final Map<Step.StepKey, Step> stepMapForPolicy = new LinkedHashMap<>();
for (Step step : policyAsSteps) {
assert ErrorStep.NAME.equals(step.getKey().getName()) == false : "unexpected error step in policy";
stepMapForPolicy.put(step.getKey(), step);
Expand Down

0 comments on commit 1449f64

Please sign in to comment.