From 4d8e9ce97acbe1d481c536821599ae6a9f8243ee Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Thu, 18 Oct 2018 14:51:39 -0600 Subject: [PATCH 1/2] [ILM] Add null check to CopyExecutionStateStep --- .../core/indexlifecycle/CopyExecutionStateStep.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/CopyExecutionStateStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/CopyExecutionStateStep.java index b3bd4235fae71..e868626af3411 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/CopyExecutionStateStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/CopyExecutionStateStep.java @@ -6,6 +6,8 @@ package org.elasticsearch.xpack.core.indexlifecycle; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; @@ -23,6 +25,8 @@ public class CopyExecutionStateStep extends ClusterStateActionStep { public static final String NAME = "copy_execution_state"; private String shrunkIndexPrefix; + private static final Logger logger = LogManager.getLogger(CopyExecutionStateStep.class); + public CopyExecutionStateStep(StepKey key, StepKey nextStepKey, String shrunkIndexPrefix) { super(key, nextStepKey); this.shrunkIndexPrefix = shrunkIndexPrefix; @@ -35,6 +39,11 @@ String getShrunkIndexPrefix() { @Override public ClusterState performAction(Index index, ClusterState clusterState) { IndexMetaData indexMetaData = clusterState.metaData().index(index); + if (indexMetaData == null) { + // Index must have been since deleted, ignore it + logger.debug("[{}] lifecycle action for index [{}] executed but index no longer exists", getKey().getAction(), index.getName()); + return clusterState; + } // get source index String indexName = indexMetaData.getIndex().getName(); // get target shrink index From 43e59193b36eef2b9f923850ea08f886e6b998ab Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Mon, 22 Oct 2018 09:50:37 -0600 Subject: [PATCH 2/2] Review feedback --- .../xpack/core/indexlifecycle/CopyExecutionStateStep.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/CopyExecutionStateStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/CopyExecutionStateStep.java index e868626af3411..b8192dd7e43be 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/CopyExecutionStateStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/CopyExecutionStateStep.java @@ -23,9 +23,11 @@ */ public class CopyExecutionStateStep extends ClusterStateActionStep { public static final String NAME = "copy_execution_state"; - private String shrunkIndexPrefix; private static final Logger logger = LogManager.getLogger(CopyExecutionStateStep.class); + + private String shrunkIndexPrefix; + public CopyExecutionStateStep(StepKey key, StepKey nextStepKey, String shrunkIndexPrefix) { super(key, nextStepKey);