Skip to content

Commit 3e59bc0

Browse files
Deprecations for single data node setting (#73733)
In #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. Co-authored-by: David Turner <[email protected]>
1 parent eba76db commit 3e59bc0

File tree

8 files changed

+224
-42
lines changed

8 files changed

+224
-42
lines changed

client/rest-high-level/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,6 @@ testClusters.all {
116116

117117
setting 'xpack.searchable.snapshot.shared_cache.size', '1mb'
118118
setting 'xpack.searchable.snapshot.shared_cache.region_size', '16kb'
119+
120+
setting 'cluster.routing.allocation.disk.watermark.enable_for_single_data_node', 'true'
119121
}

docs/reference/migration/migrate_7_14.asciidoc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,31 @@ 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+
*Impact* +
74+
75+
If your cluster has a single data node then set
76+
`cluster.routing.allocation.disk.watermark.enable_for_single_data_node: true`
77+
to opt in to the future behaviour today. If you wish to disable the disk
78+
watermarks then set `cluster.routing.allocation.disk.threshold_enabled: false`.
79+
80+
If your cluster has multiple data nodes then the
81+
`cluster.routing.allocation.disk.watermark.enable_for_single_data_node` setting
82+
has no effect and you should discontinue its use.
83+
====
84+
5885
// 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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,17 @@ Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLU
11331133
" actual free: [20.0%]"));
11341134
}
11351135

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

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.elasticsearch.cluster.ClusterState;
1111
import org.elasticsearch.cluster.metadata.IndexMetadata;
1212
import org.elasticsearch.cluster.node.DiscoveryNode;
13+
import org.elasticsearch.common.TriFunction;
1314
import org.elasticsearch.common.settings.Settings;
1415
import org.elasticsearch.xpack.core.XPackSettings;
1516
import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction;
@@ -19,7 +20,6 @@
1920
import java.util.Collections;
2021
import java.util.List;
2122
import java.util.Objects;
22-
import java.util.function.BiFunction;
2323
import java.util.function.Function;
2424
import java.util.stream.Collectors;
2525
import java.util.stream.Stream;
@@ -42,13 +42,14 @@ private DeprecationChecks() {
4242
ClusterDeprecationChecks::checkTemplatesWithMultipleTypes
4343
));
4444

45-
static final List<BiFunction<Settings, PluginsAndModules, DeprecationIssue>> NODE_SETTINGS_CHECKS;
45+
static final List<TriFunction<Settings, PluginsAndModules, ClusterState, DeprecationIssue>> NODE_SETTINGS_CHECKS;
4646

4747
static {
48-
final Stream<BiFunction<Settings, PluginsAndModules, DeprecationIssue>> legacyRoleSettings = DiscoveryNode.getPossibleRoles()
48+
final Stream<TriFunction<Settings, PluginsAndModules, ClusterState, DeprecationIssue>> legacyRoleSettings =
49+
DiscoveryNode.getPossibleRoles()
4950
.stream()
5051
.filter(r -> r.legacySetting() != null)
51-
.map(r -> (s, p) -> NodeDeprecationChecks.checkLegacyRoleSettings(r.legacySetting(), s, p));
52+
.map(r -> (s, p, cs) -> NodeDeprecationChecks.checkLegacyRoleSettings(r.legacySetting(), s, p));
5253
NODE_SETTINGS_CHECKS = Stream.concat(
5354
legacyRoleSettings,
5455
Stream.of(
@@ -58,35 +59,36 @@ private DeprecationChecks() {
5859
NodeDeprecationChecks::checkMissingRealmOrders,
5960
NodeDeprecationChecks::checkUniqueRealmOrders,
6061
NodeDeprecationChecks::checkImplicitlyDisabledBasicRealms,
61-
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkThreadPoolListenerQueueSize(settings),
62-
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkThreadPoolListenerSize(settings),
62+
(settings, pluginsAndModules, cs) -> NodeDeprecationChecks.checkThreadPoolListenerQueueSize(settings),
63+
(settings, pluginsAndModules, cs) -> NodeDeprecationChecks.checkThreadPoolListenerSize(settings),
6364
NodeDeprecationChecks::checkClusterRemoteConnectSetting,
6465
NodeDeprecationChecks::checkNodeLocalStorageSetting,
6566
NodeDeprecationChecks::checkGeneralScriptSizeSetting,
6667
NodeDeprecationChecks::checkGeneralScriptExpireSetting,
6768
NodeDeprecationChecks::checkGeneralScriptCompileSettings,
68-
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
69+
(settings, pluginsAndModules, cs) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
6970
XPackSettings.ENRICH_ENABLED_SETTING),
70-
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
71+
(settings, pluginsAndModules, cs) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
7172
XPackSettings.FLATTENED_ENABLED),
72-
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
73+
(settings, pluginsAndModules, cs) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
7374
XPackSettings.INDEX_LIFECYCLE_ENABLED),
74-
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
75+
(settings, pluginsAndModules, cs) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
7576
XPackSettings.MONITORING_ENABLED),
76-
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
77+
(settings, pluginsAndModules, cs) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
7778
XPackSettings.ROLLUP_ENABLED),
78-
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
79+
(settings, pluginsAndModules, cs) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
7980
XPackSettings.SNAPSHOT_LIFECYCLE_ENABLED),
80-
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
81+
(settings, pluginsAndModules, cs) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
8182
XPackSettings.SQL_ENABLED),
82-
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
83+
(settings, pluginsAndModules, cs) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
8384
XPackSettings.TRANSFORM_ENABLED),
84-
(settings, pluginsAndModules) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
85+
(settings, pluginsAndModules, cs) -> NodeDeprecationChecks.checkNodeBasicLicenseFeatureEnabledSetting(settings,
8586
XPackSettings.VECTORS_ENABLED),
8687
NodeDeprecationChecks::checkMultipleDataPaths,
8788
NodeDeprecationChecks::checkDataPathsList,
8889
NodeDeprecationChecks::checkBootstrapSystemCallFilterSetting,
89-
NodeDeprecationChecks::checkSharedDataPathSetting
90+
NodeDeprecationChecks::checkSharedDataPathSetting,
91+
NodeDeprecationChecks::checkSingleDataNodeWatermarkSetting
9092
)
9193
).collect(Collectors.toList());
9294
}

0 commit comments

Comments
 (0)