Skip to content

Commit

Permalink
Add a deprecation notice to shadow replicas (#22647)
Browse files Browse the repository at this point in the history
Relates to #22024

On top of documentation, the PR adds deprecation loggers and deals with the resulting warning headers.

The yaml test is set exclude versions up to 6.0. This is need to make sure bwc tests pass until this is backported to 5.2.0 . Once that's done, I will change the yaml test version limits
  • Loading branch information
bleskes committed Jan 19, 2017
1 parent 2126168 commit a5cd12a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ static Setting<Integer> buildNumberOfShardsSetting() {
Setting.intSetting(SETTING_NUMBER_OF_REPLICAS, 1, 0, Property.Dynamic, Property.IndexScope);
public static final String SETTING_SHADOW_REPLICAS = "index.shadow_replicas";
public static final Setting<Boolean> INDEX_SHADOW_REPLICAS_SETTING =
Setting.boolSetting(SETTING_SHADOW_REPLICAS, false, Property.IndexScope);
Setting.boolSetting(SETTING_SHADOW_REPLICAS, false, Property.IndexScope, Property.Deprecated);

public static final String SETTING_SHARED_FILESYSTEM = "index.shared_filesystem";
public static final Setting<Boolean> INDEX_SHARED_FILESYSTEM_SETTING =
Setting.boolSetting(SETTING_SHARED_FILESYSTEM, false, Property.IndexScope);
Setting.boolSetting(SETTING_SHARED_FILESYSTEM, INDEX_SHADOW_REPLICAS_SETTING, Property.IndexScope, Property.Deprecated);

public static final String SETTING_AUTO_EXPAND_REPLICAS = "index.auto_expand_replicas";
public static final Setting<AutoExpandReplicas> INDEX_AUTO_EXPAND_REPLICAS_SETTING = AutoExpandReplicas.SETTING;
Expand Down Expand Up @@ -235,7 +235,8 @@ static Setting<Integer> buildNumberOfShardsSetting() {
new Setting<>(SETTING_DATA_PATH, "", Function.identity(), Property.IndexScope);
public static final String SETTING_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE = "index.shared_filesystem.recover_on_any_node";
public static final Setting<Boolean> INDEX_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE_SETTING =
Setting.boolSetting(SETTING_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE, false, Property.Dynamic, Property.IndexScope);
Setting.boolSetting(SETTING_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE, false,
Property.Dynamic, Property.IndexScope, Property.Deprecated);
public static final String INDEX_UUID_NA_VALUE = "_na_";

public static final String INDEX_ROUTING_REQUIRE_GROUP_PREFIX = "index.routing.allocation.require";
Expand Down Expand Up @@ -1217,6 +1218,7 @@ public static IndexMetaData fromXContent(XContentParser parser) throws IOExcepti
* {@link #isIndexUsingShadowReplicas(org.elasticsearch.common.settings.Settings)}.
*/
public static boolean isOnSharedFilesystem(Settings settings) {
// don't use the setting directly, not to trigger verbose deprecation logging
return settings.getAsBoolean(SETTING_SHARED_FILESYSTEM, isIndexUsingShadowReplicas(settings));
}

Expand All @@ -1226,6 +1228,7 @@ public static boolean isOnSharedFilesystem(Settings settings) {
* setting for this is <code>false</code>.
*/
public static boolean isIndexUsingShadowReplicas(Settings settings) {
// don't use the setting directly, not to trigger verbose deprecation logging
return settings.getAsBoolean(SETTING_SHADOW_REPLICAS, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,10 @@ static NodeShardsResult buildVersionBasedNodeShardsResult(ShardRouting shard, bo
* recovered on any node
*/
private boolean recoverOnAnyNode(IndexMetaData metaData) {
// don't use the setting directly, not to trigger verbose deprecation logging
return (IndexMetaData.isOnSharedFilesystem(metaData.getSettings()) || IndexMetaData.isOnSharedFilesystem(this.settings))
&& IndexMetaData.INDEX_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE_SETTING.get(metaData.getSettings(), this.settings);
&& (metaData.getSettings().getAsBoolean(IndexMetaData.SETTING_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE, false) ||
this.settings.getAsBoolean(IndexMetaData.SETTING_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE, false));
}

protected abstract FetchResult<NodeGatewayStartedShards> fetchData(ShardRouting shard, RoutingAllocation allocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
private final DiscoveryNode node3 = newNode("node3");
private TestAllocator testAllocator;


/**
* needed due to random usage of {@link IndexMetaData#INDEX_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE_SETTING}. removed once
* shadow replicas are removed.
*/
@Override
protected boolean enableWarningsCheck() {
return false;
}

@Before
public void buildTestAllocator() {
this.testAllocator = new TestAllocator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ public class IndicesClusterStateServiceRandomUpdatesTests extends AbstractIndice

private final ClusterStateChanges cluster = new ClusterStateChanges(xContentRegistry());

/**
* needed due to random usage of {@link IndexMetaData#INDEX_SHADOW_REPLICAS_SETTING}. removed once
* shadow replicas are removed.
*/
@Override
protected boolean enableWarningsCheck() {
return false;
}

public void testRandomClusterStateUpdates() {
// we have an IndicesClusterStateService per node in the cluster
final Map<DiscoveryNode, IndicesClusterStateService> clusterStateServiceMap = new HashMap<>();
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/indices/shadow-replicas.asciidoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[[indices-shadow-replicas]]
== Shadow replica indices

experimental[]
deprecated[5.2.0, Shadow replicas don't see much usage and we are planning to remove them]

If you would like to use a shared filesystem, you can use the shadow replicas
settings to choose where on disk the data for an index should be kept, as well
Expand Down
6 changes: 5 additions & 1 deletion docs/reference/migration/migrate_5_2.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ Please use the non-`source` methods instead (like `settings` and `type`).
[float]
==== Timestamp meta-data field type for ingest processors has changed

The type of the "timestamp" meta-data field for ingest processors has changed from `java.lang.String` to `java.util.Date`.
The type of the "timestamp" meta-data field for ingest processors has changed from `java.lang.String` to `java.util.Date`.

=== Shadow Replicas are deprecated

<<indices-shadow-replicas,Shadow Replicas>> don't see much usage and we are planning to remove them.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@
$body: |
/^(index2 \s+ \d \s+ (p|r) \s+ ((STARTED|INITIALIZING|RELOCATING) \s+ (\d \s+ (\d+|\d+[.]\d+)(kb|b) \s+)? \d{1,3}.\d{1,3}.\d{1,3}.\d{1,3} \s+ .+|UNASSIGNED \s+) \n?){5}$/
---
"Test cat shards with shadow replicas":
- skip:
version: " - 6.99.99"
reason: deprecation was added in 5.2.0 (but this is disable now due to a bug in ThreadContext, Boaz is on it)
features: "warnings"

- do:
indices.create:
index: index3
Expand All @@ -174,6 +181,9 @@
number_of_replicas: "1"
shadow_replicas: true
shared_filesystem: false
warnings:
- "[index.shadow_replicas] setting was deprecated in Elasticsearch and it will be removed in a future release! See the breaking changes lists in the documentation for details"
- "[index.shared_filesystem] setting was deprecated in Elasticsearch and it will be removed in a future release! See the breaking changes lists in the documentation for details"

- do:
cat.shards:
Expand Down

0 comments on commit a5cd12a

Please sign in to comment.