[CCR] Make index.xpack.ccr.following_index an internal setting (#33768)

This commit is contained in:
Martijn van Groningen 2018-09-17 18:08:19 +02:00 committed by GitHub
parent 5d2a01dcc3
commit 7046cc467f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -27,7 +27,7 @@ public final class CcrSettings {
* Index setting for a following index.
*/
public static final Setting<Boolean> CCR_FOLLOWING_INDEX_SETTING =
Setting.boolSetting("index.xpack.ccr.following_index", false, Setting.Property.IndexScope);
Setting.boolSetting("index.xpack.ccr.following_index", false, Property.IndexScope, Property.InternalIndex);
/**
* Setting for controlling the interval in between polling leader clusters to check whether there are indices to follow

View File

@ -9,6 +9,8 @@ package org.elasticsearch.xpack.ccr;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksAction;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
import org.elasticsearch.action.admin.indices.close.CloseIndexRequest;
import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest;
import org.elasticsearch.action.admin.indices.stats.ShardStats;
import org.elasticsearch.action.bulk.BulkProcessor;
import org.elasticsearch.action.bulk.BulkRequest;
@ -477,6 +479,24 @@ public class ShardChangesIT extends ESIntegTestCase {
assertThat(e.getMessage(), containsString("follow index [index2] should reference"));
}
public void testAttemptToChangeCcrFollowingIndexSetting() throws Exception {
String leaderIndexSettings = getIndexSettings(1, 0, singletonMap(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "true"));
assertAcked(client().admin().indices().prepareCreate("index1").setSource(leaderIndexSettings, XContentType.JSON).get());
ensureYellow("index1");
FollowIndexAction.Request followRequest = createFollowRequest("index1", "index2");
CreateAndFollowIndexAction.Request createAndFollowRequest = new CreateAndFollowIndexAction.Request(followRequest);
client().execute(CreateAndFollowIndexAction.INSTANCE, createAndFollowRequest).get();
unfollowIndex("index2");
client().admin().indices().close(new CloseIndexRequest("index2")).actionGet();
UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest("index2");
updateSettingsRequest.settings(Settings.builder().put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), false).build());
Exception e = expectThrows(IllegalArgumentException.class,
() -> client().admin().indices().updateSettings(updateSettingsRequest).actionGet());
assertThat(e.getMessage(), equalTo("can not update internal setting [index.xpack.ccr.following_index]; " +
"this setting is managed via a dedicated API"));
}
private CheckedRunnable<Exception> assertTask(final int numberOfPrimaryShards, final Map<ShardId, Long> numDocsPerShard) {
return () -> {
final ClusterState clusterState = client().admin().cluster().prepareState().get().getState();