diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java index c28c3f9dd73de..9bab08d3f4772 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java @@ -26,6 +26,7 @@ import org.elasticsearch.common.util.concurrent.AtomicArray; import org.elasticsearch.common.util.concurrent.CountDown; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexSettings; import org.elasticsearch.license.LicenseUtils; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xpack.ccr.CcrLicenseChecker; @@ -370,7 +371,7 @@ static List getLeaderIndicesToFollow(String clusterAlias, // has a leader index uuid custom metadata entry that matches with uuid of leaderIndexMetaData variable // If so then handle it differently: not follow it, but just add an entry to // AutoFollowMetadata#followedLeaderIndexUUIDs - if (TransportPutFollowAction.canFollow(clusterAlias, leaderIndexMetaData) == null) { + if (leaderIndexMetaData.getSettings().getAsBoolean(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), false)) { leaderIndicesToFollow.add(leaderIndexMetaData.getIndex()); } } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutFollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutFollowAction.java index 05aecf1745022..f79a95204aec9 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutFollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutFollowAction.java @@ -103,20 +103,6 @@ protected void masterOperation( createFollowerIndexAndFollowRemoteIndex(request, leaderCluster, leaderIndex, listener); } - /** - * Pre-flight check if the given index can be a leader index. - * This method returns {@code null} if no issue found; otherwise it returns the first issue that it found. - */ - static Exception canFollow(String leaderCluster, IndexMetaData leaderIndexMetaData) { - Objects.requireNonNull(leaderIndexMetaData, "leader index metadata must not be null"); - // soft-deletes is mandatory for the leader index. - if (leaderIndexMetaData.getSettings().getAsBoolean(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), false) == false) { - return new IllegalArgumentException("leader index [" + leaderCluster + ":" + leaderIndexMetaData.getIndex().getName() - + "] does not have soft deletes enabled"); - } - return null; - } - private void createFollowerIndexAndFollowRemoteIndex( final PutFollowAction.Request request, final String leaderCluster, @@ -139,11 +125,9 @@ private void createFollowerIndex( listener.onFailure(new IllegalArgumentException("leader index [" + request.getLeaderIndex() + "] does not exist")); return; } - - final Exception preFlightError = canFollow(request.getLeaderCluster(), leaderIndexMetaData); - if (preFlightError != null) { - listener.onFailure(preFlightError); - return; + if (leaderIndexMetaData.getSettings().getAsBoolean(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), false) == false) { + listener.onFailure( + new IllegalArgumentException("leader index [" + request.getLeaderIndex() + "] does not enable soft-deletes")); } ActionListener handler = ActionListener.wrap(