Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecations for single data node setting #73733

16 changes: 16 additions & 0 deletions docs/reference/migration/migrate_7_14.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,20 @@ cluster then you must upgrade the affected nodes. Once upgraded, they will join
the cluster again.
====

[discrete]
[[breaking_714_core_deprecations]]
=== Core deprecations

[discrete]
[[deprecate-single-data-node-watermark]]
.Setting `cluster.routing.allocation.disk.watermark.enable_for_single_data_node=false` is deprecated.
[%collapsible]
====
*Details* +
The setting `cluster.routing.allocation.disk.watermark.enable_for_single_data_node`
should never be explicitly set to false. In 8.0, the only legal value will be
true. In a future release, the setting will be removed completely, with same
behavior as if the setting was `true`.
====

// end::notable-breaking-changes[]
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
Expand All @@ -35,6 +37,7 @@
import org.elasticsearch.snapshots.SnapshotShardSizeInfo;

import java.util.List;
import java.util.Map;
import java.util.Set;

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

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

public static final String NAME = "disk_threshold";

public static final Setting<Boolean> ENABLE_FOR_SINGLE_DATA_NODE =
Setting.boolSetting("cluster.routing.allocation.disk.watermark.enable_for_single_data_node", false, Setting.Property.NodeScope);
Setting.boolSetting("cluster.routing.allocation.disk.watermark.enable_for_single_data_node", false,
new Setting.Validator<Boolean>() {
@Override
public void validate(Boolean value) {
// empty
}

@Override
public void validate(Boolean value, Map<Setting<?>, Object> settings, boolean isPresent) {
if (value == Boolean.FALSE && isPresent) {
deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "watermark_enable_for_single_data_node",
"setting [{}=false] is deprecated and will not be available in a future version",
ENABLE_FOR_SINGLE_DATA_NODE.getKey());
}
}
},
Setting.Property.NodeScope);

public static final Setting<Boolean> SETTING_IGNORE_DISK_WATERMARKS =
Setting.boolSetting("index.routing.allocation.disk.watermark.ignore", false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,17 @@ Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLU
" actual free: [20.0%]"));
}

public void testSingleDataNodeDeprecationWarning() {
Settings settings = Settings.builder()
.put(DiskThresholdDecider.ENABLE_FOR_SINGLE_DATA_NODE.getKey(), false)
.build();

new DiskThresholdDecider(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));

assertWarnings("setting [cluster.routing.allocation.disk.watermark.enable_for_single_data_node=false] is deprecated and" +
" will not be available in a future version");
}

public void testDiskThresholdWithSnapshotShardSizes() {
final long shardSizeInBytes = randomBoolean() ? 10L : 50L;
logger.info("--> using shard size [{}]", shardSizeInBytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ private DeprecationChecks() {
NodeDeprecationChecks::checkMultipleDataPaths,
NodeDeprecationChecks::checkDataPathsList,
NodeDeprecationChecks::checkBootstrapSystemCallFilterSetting,
NodeDeprecationChecks::checkSharedDataPathSetting
NodeDeprecationChecks::checkSharedDataPathSetting,
NodeDeprecationChecks::checkSingleDataNodeWatermarkSetting
)
).collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
import org.elasticsearch.common.Strings;
import org.elasticsearch.bootstrap.BootstrapSettings;
import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -420,4 +421,19 @@ static DeprecationIssue checkSharedDataPathSetting(final Settings settings, fina
}
return null;
}

static DeprecationIssue checkSingleDataNodeWatermarkSetting(final Settings settings, final PluginsAndModules pluginsAndModules) {
if (DiskThresholdDecider.ENABLE_FOR_SINGLE_DATA_NODE.get(settings) == false
&& DiskThresholdDecider.ENABLE_FOR_SINGLE_DATA_NODE.exists(settings)) {
String key = DiskThresholdDecider.ENABLE_FOR_SINGLE_DATA_NODE.getKey();
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
String.format(Locale.ROOT, "setting [%s=false] is deprecated and will not be available in a future version", key),
"https://www.elastic.co/guide/en/elasticsearch/reference/7.14/" +
"breaking-changes-7.14.html#deprecate-single-data-node-watermark",
String.format(Locale.ROOT, "found [%s] configured to false. Discontinue use of this setting or set it to true.", key)
);
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.startsWith;


import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider;

public class NodeDeprecationChecksTests extends ESTestCase {

public void testCheckDefaults() {
Expand Down Expand Up @@ -590,4 +593,28 @@ public void testSharedDataPathSetting() {
"Found shared data path configured. Discontinue use of this setting."
)));
}

public void testSingleDataNodeWatermarkSetting() {
Settings settings = Settings.builder()
.put(DiskThresholdDecider.ENABLE_FOR_SINGLE_DATA_NODE.getKey(), false)
.build();

List<DeprecationIssue> issues = DeprecationChecks.filterChecks(DeprecationChecks.NODE_SETTINGS_CHECKS, c -> c.apply(settings,
null));

final String expectedUrl =
"https://www.elastic.co/guide/en/elasticsearch/reference/7.14/" +
"breaking-changes-7.14.html#deprecate-single-data-node-watermark";
assertThat(issues, hasItem(
new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"setting [cluster.routing.allocation.disk.watermark.enable_for_single_data_node=false] is deprecated and" +
" will not be available in a future version",
expectedUrl,
"found [cluster.routing.allocation.disk.watermark.enable_for_single_data_node] configured to false." +
" Discontinue use of this setting or set it to true."
)));

assertWarnings("setting [cluster.routing.allocation.disk.watermark.enable_for_single_data_node=false] is deprecated and" +
" will not be available in a future version");
}
}