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 authored Jan 18, 2017
1 parent 797d105 commit 1227044
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ 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_ROUTING_PARTITION_SIZE = "index.routing_partition_size";
public static final Setting<Integer> INDEX_ROUTING_PARTITION_SIZE_SETTING =
Setting.intSetting(SETTING_ROUTING_PARTITION_SIZE, 1, 1, Property.IndexScope);

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 @@ -241,7 +241,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 @@ -1263,6 +1264,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 @@ -1272,6 +1274,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 @@ -38,7 +38,6 @@
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
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 @@ -74,6 +74,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
5 changes: 5 additions & 0 deletions docs/reference/migration/migrate_6_0/indices.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ PUT _template/template_2
}
--------------------------------------------------
// CONSOLE


=== 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 @@ -169,6 +169,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 @@ -178,6 +185,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 1227044

Please sign in to comment.