Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ private DeprecationChecks() {
NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial,
NodeDeprecationChecks::checkSearchRemoteSettings,
NodeDeprecationChecks::checkMonitoringExporterPassword,
NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting,
NodeDeprecationChecks::checkClusterRoutingRequireSetting,
NodeDeprecationChecks::checkClusterRoutingIncludeSetting,
NodeDeprecationChecks::checkClusterRoutingExcludeSetting,
NodeDeprecationChecks::checkAcceptDefaultPasswordSetting,
NodeDeprecationChecks::checkAcceptRolesCacheMaxSizeSetting,
NodeDeprecationChecks::checkRolesCacheTTLSizeSetting,
Expand All @@ -117,6 +121,9 @@ private DeprecationChecks() {
IndexDeprecationChecks::indexingSlowLogLevelSettingCheck,
IndexDeprecationChecks::searchSlowLogLevelSettingCheck,
IndexDeprecationChecks::storeTypeSettingCheck,
IndexDeprecationChecks::checkIndexRoutingRequireSetting,
IndexDeprecationChecks::checkIndexRoutingIncludeSetting,
IndexDeprecationChecks::checkIndexRoutingExcludeSetting,
IndexDeprecationChecks::checkGeoShapeMappings
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.elasticsearch.cluster.metadata.MappingMetadata;
import org.elasticsearch.common.joda.JodaDeprecationPatterns;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexModule;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexingSlowLog;
Expand All @@ -34,6 +35,10 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_EXCLUDE_SETTING;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_INCLUDE_SETTING;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_REQUIRE_SETTING;


/**
* Index-specific deprecation checks
Expand Down Expand Up @@ -320,6 +325,46 @@ static DeprecationIssue storeTypeSettingCheck(IndexMetadata indexMetadata) {
return null;
}

static DeprecationIssue checkRemovedSetting(final Settings settings,
final Setting<?> removedSetting,
final String url,
DeprecationIssue.Level deprecationLevel) {
if (removedSetting.exists(settings) == false) {
return null;
}
final String removedSettingKey = removedSetting.getKey();
final String value = removedSetting.get(settings).toString();
final String message =
String.format(Locale.ROOT, "setting [%s] is deprecated and will be removed in the next major version", removedSettingKey);
final String details =
String.format(Locale.ROOT, "the setting [%s] is currently set to [%s], remove this setting", removedSettingKey, value);
return new DeprecationIssue(deprecationLevel, message, url, details, false, null);
}

static DeprecationIssue checkIndexRoutingRequireSetting(IndexMetadata indexMetadata) {
return checkRemovedSetting(indexMetadata.getSettings(),
INDEX_ROUTING_REQUIRE_SETTING,
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
DeprecationIssue.Level.CRITICAL
);
}

static DeprecationIssue checkIndexRoutingIncludeSetting(IndexMetadata indexMetadata) {
return checkRemovedSetting(indexMetadata.getSettings(),
INDEX_ROUTING_INCLUDE_SETTING,
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
DeprecationIssue.Level.CRITICAL
);
}

static DeprecationIssue checkIndexRoutingExcludeSetting(IndexMetadata indexMetadata) {
return checkRemovedSetting(indexMetadata.getSettings(),
INDEX_ROUTING_EXCLUDE_SETTING,
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
DeprecationIssue.Level.CRITICAL
);
}

protected static boolean isGeoShapeFieldWithDeprecatedParam(Map<?, ?> property) {
return LegacyGeoShapeFieldMapper.CONTENT_TYPE.equals(property.get("type")) &&
LegacyGeoShapeFieldMapper.DEPRECATED_PARAMETERS.stream().anyMatch(deprecatedParameter ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
import java.util.stream.Collectors;

import static org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.CLUSTER_ROUTING_EXCLUDE_SETTING;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.CLUSTER_ROUTING_INCLUDE_SETTING;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.CLUSTER_ROUTING_REQUIRE_SETTING;
import static org.elasticsearch.xpack.core.security.authc.RealmSettings.RESERVED_REALM_NAME_PREFIX;

class NodeDeprecationChecks {
Expand Down Expand Up @@ -649,32 +652,65 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f
);
}

static DeprecationIssue checkAcceptDefaultPasswordSetting(final Settings settings,
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
static DeprecationIssue checkClusterRoutingRequireSetting(final Settings settings,
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
return checkRemovedSetting(settings,
Setting.boolSetting(SecurityField.setting("authc.accept_default_password"),true, Setting.Property.Deprecated),
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_security_changes",
CLUSTER_ROUTING_REQUIRE_SETTING,
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
DeprecationIssue.Level.CRITICAL
);
}

static DeprecationIssue checkAcceptRolesCacheMaxSizeSetting(final Settings settings,
static DeprecationIssue checkClusterRoutingIncludeSetting(final Settings settings,
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
return checkRemovedSetting(settings,
Setting.intSetting(SecurityField.setting("authz.store.roles.index.cache.max_size"), 10000, Setting.Property.Deprecated),
CLUSTER_ROUTING_INCLUDE_SETTING,
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
DeprecationIssue.Level.CRITICAL
);
}

static DeprecationIssue checkClusterRoutingExcludeSetting(final Settings settings,
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
return checkRemovedSetting(settings,
CLUSTER_ROUTING_EXCLUDE_SETTING,
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
DeprecationIssue.Level.CRITICAL
);
}

static DeprecationIssue checkAcceptDefaultPasswordSetting(final Settings settings,
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
return checkRemovedSetting(settings,
Setting.boolSetting(SecurityField.setting("authc.accept_default_password"),true, Setting.Property.Deprecated),
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_security_changes",
DeprecationIssue.Level.CRITICAL
);
}

static DeprecationIssue checkRolesCacheTTLSizeSetting(final Settings settings,
static DeprecationIssue checkAcceptRolesCacheMaxSizeSetting(final Settings settings,
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
return checkRemovedSetting(settings,
Setting.intSetting(SecurityField.setting("authz.store.roles.index.cache.max_size"), 10000, Setting.Property.Deprecated),
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_security_changes",
DeprecationIssue.Level.CRITICAL
);
}

static DeprecationIssue checkRolesCacheTTLSizeSetting(final Settings settings,
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
return checkRemovedSetting(settings,
Setting.timeSetting(SecurityField.setting("authz.store.roles.index.cache.ttl"), TimeValue.timeValueMinutes(20),
Setting.Property.Deprecated),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,27 @@
import org.elasticsearch.index.mapper.FieldNamesFieldMapper;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.xpack.core.DataTier;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.Collections.singletonList;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_EXCLUDE_SETTING;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_INCLUDE_SETTING;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_REQUIRE_SETTING;
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.INDEX_SETTINGS_CHECKS;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;

Expand Down Expand Up @@ -503,6 +509,72 @@ public void testSimpleFSSetting() {
));
}

public void testTierAllocationSettings() {
String settingValue = DataTier.DATA_HOT;
final Settings settings = settings(Version.CURRENT)
.put(INDEX_ROUTING_REQUIRE_SETTING.getKey(), DataTier.DATA_HOT)
.put(INDEX_ROUTING_INCLUDE_SETTING.getKey(), DataTier.DATA_HOT)
.put(INDEX_ROUTING_EXCLUDE_SETTING.getKey(), DataTier.DATA_HOT)
.build();
final DeprecationIssue expectedRequireIssue = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
String.format(Locale.ROOT,
"setting [%s] is deprecated and will be removed in the next major version",
INDEX_ROUTING_REQUIRE_SETTING.getKey()),
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
String.format(Locale.ROOT,
"the setting [%s] is currently set to [%s], remove this setting",
INDEX_ROUTING_REQUIRE_SETTING.getKey(),
settingValue),
false, null
);
final DeprecationIssue expectedIncludeIssue = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
String.format(Locale.ROOT,
"setting [%s] is deprecated and will be removed in the next major version",
INDEX_ROUTING_INCLUDE_SETTING.getKey()),
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
String.format(Locale.ROOT,
"the setting [%s] is currently set to [%s], remove this setting",
INDEX_ROUTING_INCLUDE_SETTING.getKey(),
settingValue),
false, null
);
final DeprecationIssue expectedExcludeIssue = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
String.format(Locale.ROOT,
"setting [%s] is deprecated and will be removed in the next major version",
INDEX_ROUTING_EXCLUDE_SETTING.getKey()),
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
String.format(Locale.ROOT,
"the setting [%s] is currently set to [%s], remove this setting",
INDEX_ROUTING_EXCLUDE_SETTING.getKey(),
settingValue),
false, null
);

IndexMetadata indexMetadata = IndexMetadata.builder("test").settings(settings).numberOfShards(1).numberOfReplicas(0).build();
assertThat(
IndexDeprecationChecks.checkIndexRoutingRequireSetting(indexMetadata),
equalTo(expectedRequireIssue)
);
assertThat(
IndexDeprecationChecks.checkIndexRoutingIncludeSetting(indexMetadata),
equalTo(expectedIncludeIssue)
);
assertThat(
IndexDeprecationChecks.checkIndexRoutingExcludeSetting(indexMetadata),
equalTo(expectedExcludeIssue)
);

final String warningTemplate = "[%s] setting was deprecated in Elasticsearch and will be removed in a future release! " +
"See the breaking changes documentation for the next major version.";
final String[] expectedWarnings = {
String.format(Locale.ROOT, warningTemplate, INDEX_ROUTING_REQUIRE_SETTING.getKey()),
String.format(Locale.ROOT, warningTemplate, INDEX_ROUTING_INCLUDE_SETTING.getKey()),
String.format(Locale.ROOT, warningTemplate, INDEX_ROUTING_EXCLUDE_SETTING.getKey()),
};

assertWarnings(expectedWarnings);
}

public void testCheckGeoShapeMappings() throws Exception {
Map<String, Object> emptyMappingMap = Collections.emptyMap();
MappingMetadata mappingMetadata = new MappingMetadata("", emptyMappingMap);
Expand Down
Loading