Skip to content

[ILM] Add null check to CopyExecutionStateStep #34619

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
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,8 +23,12 @@
*/
public class CopyExecutionStateStep extends ClusterStateActionStep {
public static final String NAME = "copy_execution_state";

private static final Logger logger = LogManager.getLogger(CopyExecutionStateStep.class);

private String shrunkIndexPrefix;


public CopyExecutionStateStep(StepKey key, StepKey nextStepKey, String shrunkIndexPrefix) {
super(key, nextStepKey);
this.shrunkIndexPrefix = shrunkIndexPrefix;
Expand All @@ -35,6 +41,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
Expand Down