From a49d59802a3c277e9315e21c1e5a24c734d9e778 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Mon, 1 Oct 2018 13:45:26 -0600 Subject: [PATCH] Use more descriptive task names for ILM cluster state updates (#34161) Rather than using "ILM" for everything, we should use more descriptive names so debugging from logs is easier to do. Resolves #34118 --- .../xpack/indexlifecycle/IndexLifecycleRunner.java | 10 ++++++---- .../indexlifecycle/IndexLifecycleRunnerTests.java | 14 +++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunner.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunner.java index 3c868332f5f..8671a17a596 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunner.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunner.java @@ -174,7 +174,8 @@ public class IndexLifecycleRunner { private void executeClusterStateSteps(Index index, String policy, Step step) { assert step instanceof ClusterStateActionStep || step instanceof ClusterStateWaitStep; - clusterService.submitStateUpdateTask("ILM", new ExecuteStepsUpdateTask(policy, index, step, stepRegistry, nowSupplier)); + clusterService.submitStateUpdateTask("ilm-execute-cluster-state-steps", + new ExecuteStepsUpdateTask(policy, index, step, stepRegistry, nowSupplier)); } /** @@ -383,18 +384,19 @@ public class IndexLifecycleRunner { private void moveToStep(Index index, String policy, StepKey currentStepKey, StepKey nextStepKey) { logger.debug("moveToStep[" + policy + "] [" + index.getName() + "]" + currentStepKey + " -> " + nextStepKey); - clusterService.submitStateUpdateTask("ILM", new MoveToNextStepUpdateTask(index, policy, currentStepKey, + clusterService.submitStateUpdateTask("ilm-move-to-step", new MoveToNextStepUpdateTask(index, policy, currentStepKey, nextStepKey, nowSupplier)); } private void moveToErrorStep(Index index, String policy, StepKey currentStepKey, Exception e) { logger.error("policy [" + policy + "] for index [" + index.getName() + "] failed on step [" + currentStepKey + "]. Moving to ERROR step.", e); - clusterService.submitStateUpdateTask("ILM", new MoveToErrorStepUpdateTask(index, policy, currentStepKey, e, nowSupplier)); + clusterService.submitStateUpdateTask("ilm-move-to-error-step", + new MoveToErrorStepUpdateTask(index, policy, currentStepKey, e, nowSupplier)); } private void setStepInfo(Index index, String policy, StepKey currentStepKey, ToXContentObject stepInfo) { - clusterService.submitStateUpdateTask("ILM", new SetStepInfoUpdateTask(index, policy, currentStepKey, stepInfo)); + clusterService.submitStateUpdateTask("ilm-set-step-info", new SetStepInfoUpdateTask(index, policy, currentStepKey, stepInfo)); } public static ClusterState setPolicyForIndexes(final String newPolicyName, final Index[] indices, ClusterState currentState, diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunnerTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunnerTests.java index 9994b56612c..604ba29145c 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunnerTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunnerTests.java @@ -137,7 +137,7 @@ public class IndexLifecycleRunnerTests extends ESTestCase { runner.runPolicy(policyName, indexMetaData, null, randomBoolean()); - Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ILM"), + Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ilm-execute-cluster-state-steps"), Mockito.argThat(new ExecuteStepsUpdateTaskMatcher(indexMetaData.getIndex(), policyName, step))); Mockito.verifyNoMoreInteractions(clusterService); } @@ -155,7 +155,7 @@ public class IndexLifecycleRunnerTests extends ESTestCase { runner.runPolicy(policyName, indexMetaData, null, randomBoolean()); - Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ILM"), + Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ilm-execute-cluster-state-steps"), Mockito.argThat(new ExecuteStepsUpdateTaskMatcher(indexMetaData.getIndex(), policyName, step))); Mockito.verifyNoMoreInteractions(clusterService); } @@ -174,7 +174,7 @@ public class IndexLifecycleRunnerTests extends ESTestCase { runner.runPolicy(policyName, indexMetaData, null, false); assertEquals(1, step.getExecuteCount()); - Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ILM"), + Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ilm-move-to-step"), Mockito.argThat(new MoveToNextStepUpdateTaskMatcher(indexMetaData.getIndex(), policyName, stepKey, null))); Mockito.verifyNoMoreInteractions(clusterService); } @@ -229,7 +229,7 @@ public class IndexLifecycleRunnerTests extends ESTestCase { runner.runPolicy(policyName, indexMetaData, null, false); assertEquals(1, step.getExecuteCount()); - Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ILM"), + Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ilm-move-to-error-step"), Mockito.argThat(new MoveToErrorStepUpdateTaskMatcher(indexMetaData.getIndex(), policyName, stepKey, expectedException))); Mockito.verifyNoMoreInteractions(clusterService); } @@ -266,7 +266,7 @@ public class IndexLifecycleRunnerTests extends ESTestCase { runner.runPolicy(policyName, indexMetaData, null, false); assertEquals(1, step.getExecuteCount()); - Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ILM"), + Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ilm-move-to-step"), Mockito.argThat(new MoveToNextStepUpdateTaskMatcher(indexMetaData.getIndex(), policyName, stepKey, null))); Mockito.verifyNoMoreInteractions(clusterService); } @@ -287,7 +287,7 @@ public class IndexLifecycleRunnerTests extends ESTestCase { runner.runPolicy(policyName, indexMetaData, null, false); assertEquals(1, step.getExecuteCount()); - Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ILM"), + Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ilm-set-step-info"), Mockito.argThat(new SetStepInfoUpdateTaskMatcher(indexMetaData.getIndex(), policyName, stepKey, stepInfo))); Mockito.verifyNoMoreInteractions(clusterService); } @@ -326,7 +326,7 @@ public class IndexLifecycleRunnerTests extends ESTestCase { runner.runPolicy(policyName, indexMetaData, null, false); assertEquals(1, step.getExecuteCount()); - Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ILM"), + Mockito.verify(clusterService, Mockito.times(1)).submitStateUpdateTask(Mockito.matches("ilm-move-to-error-step"), Mockito.argThat(new MoveToErrorStepUpdateTaskMatcher(indexMetaData.getIndex(), policyName, stepKey, expectedException))); Mockito.verifyNoMoreInteractions(clusterService); }