Allow dynamic updates for index.hidden setting (#52837)

This commit changes the `index.hidden` setting from being final to a
dynamic setting. While the setting being final allows for easier
reasoning about an index, making this setting update-able has more
benefits in that we can upgrade existing indices to be hidden and it
will enable future features that would dynamically make indices hidden.

Backport of #52772
This commit is contained in:
Jay Modi 2020-02-26 11:46:29 -07:00 committed by GitHub
parent bfaa487757
commit 07ef8ccff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -262,7 +262,7 @@ public class IndexMetaData implements Diffable<IndexMetaData>, ToXContentFragmen
* normal wildcard searches unless explicitly allowed
*/
public static final Setting<Boolean> INDEX_HIDDEN_SETTING =
Setting.boolSetting(SETTING_INDEX_HIDDEN, false, Property.IndexScope, Property.Final);
Setting.boolSetting(SETTING_INDEX_HIDDEN, false, Property.Dynamic, Property.IndexScope);
/**
* an internal index format description, allowing us to find out if this index is upgraded or needs upgrading

View File

@ -77,6 +77,15 @@ public class HiddenIndexIT extends ESIntegTestCase {
.get();
matchedHidden = Arrays.stream(searchResponse.getHits().getHits()).anyMatch(hit -> ".hidden-index".equals(hit.getIndex()));
assertTrue(matchedHidden);
// make index not hidden
assertAcked(client().admin().indices().prepareUpdateSettings("hidden-index")
.setSettings(Settings.builder().put("index.hidden", false).build())
.get());
searchResponse =
client().prepareSearch(randomFrom("*", "_all", "h*", "*index")).setSize(1000).setQuery(QueryBuilders.matchAllQuery()).get();
matchedHidden = Arrays.stream(searchResponse.getHits().getHits()).anyMatch(hit -> "hidden-index".equals(hit.getIndex()));
assertTrue(matchedHidden);
}
public void testGlobalTemplatesDoNotApply() {

View File

@ -368,6 +368,7 @@ public class TransportResumeFollowAction extends TransportMasterNodeAction<Resum
nonReplicatedSettings.add(IndexMetaData.INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING);
nonReplicatedSettings.add(IndexMetaData.INDEX_PRIORITY_SETTING);
nonReplicatedSettings.add(IndexMetaData.SETTING_WAIT_FOR_ACTIVE_SHARDS);
nonReplicatedSettings.add(IndexMetaData.INDEX_HIDDEN_SETTING);
nonReplicatedSettings.add(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING);
nonReplicatedSettings.add(EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING);