Skip to content

Commit 916ce6d

Browse files
Deprecations for single data node setting
In elastic#55805, we added a setting to allow single data node clusters to respect the high watermark. This commit adds deprecation warnings to 7.x to ensure we can make only true valid in 8.0.
1 parent 3c3cebe commit 916ce6d

File tree

6 files changed

+102
-2
lines changed

6 files changed

+102
-2
lines changed

docs/reference/migration/migrate_7_14.asciidoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,20 @@ cluster then you must upgrade the affected nodes. Once upgraded, they will join
5555
the cluster again.
5656
====
5757

58+
[discrete]
59+
[[breaking_714_core_deprecations]]
60+
=== Core deprecations
61+
62+
[discrete]
63+
[[deprecate-single-data-node-watermark]]
64+
.Setting `cluster.routing.allocation.disk.watermark.enable_for_single_data_node=false` is deprecated.
65+
[%collapsible]
66+
====
67+
*Details* +
68+
The setting `cluster.routing.allocation.disk.watermark.enable_for_single_data_node`
69+
should never be explicitly set to false. In 8.0, the only legal value will be
70+
true. In a future release, the setting will be removed completely, with same
71+
behavior as if the setting was `true`.
72+
====
73+
5874
// end::notable-breaking-changes[]

server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
2727
import org.elasticsearch.common.Strings;
2828
import org.elasticsearch.common.collect.ImmutableOpenMap;
29+
import org.elasticsearch.common.logging.DeprecationCategory;
30+
import org.elasticsearch.common.logging.DeprecationLogger;
2931
import org.elasticsearch.common.settings.ClusterSettings;
3032
import org.elasticsearch.common.settings.Setting;
3133
import org.elasticsearch.common.settings.Settings;
@@ -35,6 +37,7 @@
3537
import org.elasticsearch.snapshots.SnapshotShardSizeInfo;
3638

3739
import java.util.List;
40+
import java.util.Map;
3841
import java.util.Set;
3942

4043
import static org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING;
@@ -66,11 +69,28 @@
6669
public class DiskThresholdDecider extends AllocationDecider {
6770

6871
private static final Logger logger = LogManager.getLogger(DiskThresholdDecider.class);
72+
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DiskThresholdDecider.class);
6973

7074
public static final String NAME = "disk_threshold";
7175

7276
public static final Setting<Boolean> ENABLE_FOR_SINGLE_DATA_NODE =
73-
Setting.boolSetting("cluster.routing.allocation.disk.watermark.enable_for_single_data_node", false, Setting.Property.NodeScope);
77+
Setting.boolSetting("cluster.routing.allocation.disk.watermark.enable_for_single_data_node", false,
78+
new Setting.Validator<Boolean>() {
79+
@Override
80+
public void validate(Boolean value) {
81+
// empty
82+
}
83+
84+
@Override
85+
public void validate(Boolean value, Map<Setting<?>, Object> settings, boolean isPresent) {
86+
if (value == Boolean.FALSE && isPresent) {
87+
deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "watermark_enable_for_single_data_node",
88+
"setting [{}=false] is deprecated and will not be available in a future version",
89+
ENABLE_FOR_SINGLE_DATA_NODE.getKey());
90+
}
91+
}
92+
},
93+
Setting.Property.NodeScope);
7494

7595
public static final Setting<Boolean> SETTING_IGNORE_DISK_WATERMARKS =
7696
Setting.boolSetting("index.routing.allocation.disk.watermark.ignore", false,

server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.elasticsearch.snapshots.Snapshot;
5454
import org.elasticsearch.snapshots.SnapshotId;
5555
import org.elasticsearch.snapshots.SnapshotShardSizeInfo;
56+
import org.elasticsearch.test.MockLogAppender;
5657
import org.elasticsearch.test.gateway.TestGatewayAllocator;
5758

5859
import java.util.Arrays;
@@ -1133,6 +1134,17 @@ Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLU
11331134
" actual free: [20.0%]"));
11341135
}
11351136

1137+
public void testSingleDataNodeDeprecationWarning() {
1138+
Settings settings = Settings.builder()
1139+
.put(DiskThresholdDecider.ENABLE_FOR_SINGLE_DATA_NODE.getKey(), false)
1140+
.build();
1141+
1142+
new DiskThresholdDecider(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
1143+
1144+
assertWarnings("setting [cluster.routing.allocation.disk.watermark.enable_for_single_data_node=false] is deprecated and" +
1145+
" will not be available in a future version");
1146+
}
1147+
11361148
public void testDiskThresholdWithSnapshotShardSizes() {
11371149
final long shardSizeInBytes = randomBoolean() ? 10L : 50L;
11381150
logger.info("--> using shard size [{}]", shardSizeInBytes);

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ private DeprecationChecks() {
8686
NodeDeprecationChecks::checkMultipleDataPaths,
8787
NodeDeprecationChecks::checkDataPathsList,
8888
NodeDeprecationChecks::checkBootstrapSystemCallFilterSetting,
89-
NodeDeprecationChecks::checkSharedDataPathSetting
89+
NodeDeprecationChecks::checkSharedDataPathSetting,
90+
NodeDeprecationChecks::checkSingleDataNodeWatermarkSetting
9091
)
9192
).collect(Collectors.toList());
9293
}

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
1414
import org.elasticsearch.common.Strings;
1515
import org.elasticsearch.bootstrap.BootstrapSettings;
16+
import org.elasticsearch.cluster.ClusterInfo;
17+
import org.elasticsearch.cluster.ClusterInfoService;
18+
import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider;
1619
import org.elasticsearch.common.settings.Setting;
1720
import org.elasticsearch.common.settings.Setting.Property;
1821
import org.elasticsearch.common.settings.Settings;
@@ -420,4 +423,18 @@ static DeprecationIssue checkSharedDataPathSetting(final Settings settings, fina
420423
}
421424
return null;
422425
}
426+
427+
static DeprecationIssue checkSingleDataNodeWatermarkSetting(final Settings settings, final PluginsAndModules pluginsAndModules) {
428+
if (DiskThresholdDecider.ENABLE_FOR_SINGLE_DATA_NODE.get(settings) == false && DiskThresholdDecider.ENABLE_FOR_SINGLE_DATA_NODE.exists(settings)) {
429+
String key = DiskThresholdDecider.ENABLE_FOR_SINGLE_DATA_NODE.getKey();
430+
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
431+
String.format("setting [%s=false] is deprecated and will not be available in a future version", key),
432+
"https://www.elastic.co/guide/en/elasticsearch/reference/7.14/" +
433+
"breaking-changes-7.14.html#deprecate-single-data-node-watermark",
434+
String.format("found [%s] configured to false. Discontinue use of this setting or set it to true.", key)
435+
);
436+
}
437+
438+
return null;
439+
}
423440
}

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.Locale;
3333
import java.util.stream.Collectors;
3434

35+
import static org.hamcrest.Matchers.contains;
3536
import static org.hamcrest.Matchers.containsString;
3637
import static org.hamcrest.Matchers.empty;
3738
import static org.hamcrest.Matchers.equalTo;
@@ -40,6 +41,15 @@
4041
import static org.hamcrest.Matchers.nullValue;
4142
import static org.hamcrest.Matchers.startsWith;
4243

44+
import java.util.List;
45+
46+
import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider;
47+
import org.elasticsearch.common.settings.Setting;
48+
import org.elasticsearch.common.settings.Settings;
49+
import org.elasticsearch.env.Environment;
50+
import org.elasticsearch.test.ESTestCase;
51+
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
52+
4353
public class NodeDeprecationChecksTests extends ESTestCase {
4454

4555
public void testCheckDefaults() {
@@ -590,4 +600,28 @@ public void testSharedDataPathSetting() {
590600
"Found shared data path configured. Discontinue use of this setting."
591601
)));
592602
}
603+
604+
public void testSingleDataNodeWatermarkSetting() {
605+
Settings settings = Settings.builder()
606+
.put(DiskThresholdDecider.ENABLE_FOR_SINGLE_DATA_NODE.getKey(), false)
607+
.build();
608+
609+
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(DeprecationChecks.NODE_SETTINGS_CHECKS, c -> c.apply(settings,
610+
null));
611+
612+
final String expectedUrl =
613+
"https://www.elastic.co/guide/en/elasticsearch/reference/7.14/" +
614+
"breaking-changes-7.14.html#deprecate-single-data-node-watermark";
615+
assertThat(issues, contains(
616+
new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
617+
"setting [cluster.routing.allocation.disk.watermark.enable_for_single_data_node=false] is deprecated and" +
618+
" will not be available in a future version",
619+
expectedUrl,
620+
"found [cluster.routing.allocation.disk.watermark.enable_for_single_data_node] configured to false." +
621+
" Discontinue use of this setting or set it to true."
622+
)));
623+
624+
assertWarnings("setting [cluster.routing.allocation.disk.watermark.enable_for_single_data_node=false] is deprecated and" +
625+
" will not be available in a future version");
626+
}
593627
}

0 commit comments

Comments
 (0)