Skip to content

Commit

Permalink
[7.16] Drop non-setting deprecations down to warning level (#80374)
Browse files Browse the repository at this point in the history
Complementary to #79665 this change
will reduce the deprecation logging level to WARN for (most) all non-settings that
continue to exist in 8.0+.
  • Loading branch information
jakelandis authored Nov 10, 2021
1 parent f736645 commit 6358afb
Show file tree
Hide file tree
Showing 99 changed files with 191 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public Map<String, AnalysisProvider<TokenFilterFactory>> getTokenFilters() {
filters.put("dutch_stem", DutchStemTokenFilterFactory::new);
filters.put("edge_ngram", EdgeNGramTokenFilterFactory::new);
filters.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.ANALYSIS,
"edgeNGram_deprecation",
"The [edgeNGram] token filter name is deprecated and will be removed in a future version. "
Expand Down Expand Up @@ -276,7 +276,7 @@ public Map<String, AnalysisProvider<TokenFilterFactory>> getTokenFilters() {
filters.put("multiplexer", MultiplexerTokenFilterFactory::new);
filters.put("ngram", NGramTokenFilterFactory::new);
filters.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.ANALYSIS,
"nGram_deprecation",
"The [nGram] token filter name is deprecated and will be removed in a future version. "
Expand Down Expand Up @@ -330,7 +330,7 @@ public Map<String, AnalysisProvider<TokenizerFactory>> getTokenizers() {
tokenizers.put("thai", ThaiTokenizerFactory::new);
tokenizers.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.ANALYSIS,
"nGram_tokenizer_deprecation",
"The [nGram] tokenizer name is deprecated and will be removed in a future version. "
Expand All @@ -342,7 +342,7 @@ public Map<String, AnalysisProvider<TokenizerFactory>> getTokenizers() {
tokenizers.put("ngram", NGramTokenizerFactory::new);
tokenizers.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.ANALYSIS,
"edgeNGram_tokenizer_deprecation",
"The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. "
Expand Down Expand Up @@ -645,7 +645,7 @@ public List<PreConfiguredTokenizer> getPreConfiguredTokenizers() {
// Temporary shim for aliases. TODO deprecate after they are moved
tokenizers.add(PreConfiguredTokenizer.elasticsearchVersion("nGram", (version) -> {
if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.ANALYSIS,
"nGram_tokenizer_deprecation",
"The [nGram] tokenizer name is deprecated and will be removed in a future version. "
Expand All @@ -656,7 +656,7 @@ public List<PreConfiguredTokenizer> getPreConfiguredTokenizers() {
}));
tokenizers.add(PreConfiguredTokenizer.elasticsearchVersion("edgeNGram", (version) -> {
if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.ANALYSIS,
"edgeNGram_tokenizer_deprecation",
"The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class SynonymTokenFilterFactory extends AbstractTokenFilterFactory {
this.settings = settings;

if (settings.get("ignore_case") != null) {
DEPRECATION_LOGGER.critical(
DEPRECATION_LOGGER.warn(
DeprecationCategory.ANALYSIS,
"synonym_ignore_case_option",
"The ignore_case option on the synonym_graph filter is deprecated. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.elasticsearch.analysis.common;

import org.apache.logging.log4j.Level;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.Tokenizer;
import org.elasticsearch.Version;
Expand Down Expand Up @@ -193,6 +194,7 @@ public void testnGramFilterInCustomAnalyzerDeprecationError() throws IOException

createTestAnalysis(IndexSettingsModule.newIndexSettings("index", settings), settings, commonAnalysisPlugin);
assertWarnings(
Level.WARN,
"The [nGram] token filter name is deprecated and will be removed in a future version. "
+ "Please change the filter name to [ngram] instead."
);
Expand All @@ -214,6 +216,7 @@ public void testEdgeNGramFilterInCustomAnalyzerDeprecationError() throws IOExcep

createTestAnalysis(IndexSettingsModule.newIndexSettings("index", settings), settings, commonAnalysisPlugin);
assertWarnings(
Level.WARN,
"The [edgeNGram] token filter name is deprecated and will be removed in a future version. "
+ "Please change the filter name to [edge_ngram] instead."
);
Expand Down Expand Up @@ -276,6 +279,7 @@ public void doTestPrebuiltTokenizerDeprecation(String deprecatedName, String rep
assertNotNull(tokenizer);
if (expectWarning) {
assertWarnings(
Level.WARN,
"The ["
+ deprecatedName
+ "] tokenizer name is deprecated and will be removed in a future version. "
Expand All @@ -302,6 +306,7 @@ public void doTestCustomTokenizerDeprecation(String deprecatedName, String repla

if (expectWarning) {
assertWarnings(
Level.WARN,
"The ["
+ deprecatedName
+ "] tokenizer name is deprecated and will be removed in a future version. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.elasticsearch.analysis.common;

import org.apache.logging.log4j.Level;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
Expand Down Expand Up @@ -57,7 +58,7 @@ public void testDictionaryDecompounder() throws Exception {
hasItems("donau", "dampf", "schiff", "donaudampfschiff", "spargel", "creme", "suppe", "spargelcremesuppe")
);
}
assertWarnings("Setting [version] on analysis component [custom7] has no effect and is deprecated");
assertWarnings(Level.WARN, "Setting [version] on analysis component [custom7] has no effect and is deprecated");
}

private List<String> analyze(Settings settings, String analyzerName, String text) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.elasticsearch.ingest.common;

import org.apache.logging.log4j.Level;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
Expand Down Expand Up @@ -84,6 +85,7 @@ public void testFractional() throws Exception {
processor.execute(ingestDocument);
assertThat(ingestDocument.getFieldValue(fieldName, expectedResultType()), equalTo(1126L));
assertWarnings(
Level.WARN,
"Fractional bytes values are deprecated. Use non-fractional bytes values instead: [1.1kb] found for setting " + "[Ingest Field]"
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void initialValidation(ReindexRequest request) {
);
SearchSourceBuilder searchSource = request.getSearchRequest().source();
if (searchSource != null && searchSource.sorts() != null && searchSource.sorts().isEmpty() == false) {
deprecationLogger.critical(DeprecationCategory.API, "reindex_sort", SORT_DEPRECATED_MESSAGE);
deprecationLogger.warn(DeprecationCategory.API, "reindex_sort", SORT_DEPRECATED_MESSAGE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.elasticsearch.reindex;

import org.apache.logging.log4j.Level;
import org.elasticsearch.index.query.RangeQueryBuilder;
import org.elasticsearch.index.reindex.ReindexAction;
import org.elasticsearch.index.reindex.ReindexRequestBuilder;
Expand Down Expand Up @@ -47,6 +48,6 @@ public void testDeprecatedSort() {

assertHitCount(client().prepareSearch("dest").setSize(0).get(), subsetSize);
assertHitCount(client().prepareSearch("dest").setQuery(new RangeQueryBuilder("foo").gte(0).lt(max - subsetSize)).get(), 0);
assertWarnings(ReindexValidator.SORT_DEPRECATED_MESSAGE);
assertWarnings(Level.WARN, ReindexValidator.SORT_DEPRECATED_MESSAGE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class AzureDiscoveryPlugin extends Plugin implements DiscoveryPlugin {

public AzureDiscoveryPlugin(Settings settings) {
this.settings = settings;
deprecationLogger.critical(DeprecationCategory.PLUGINS, "azure_discovery_plugin", "azure classic discovery plugin is deprecated.");
deprecationLogger.warn(DeprecationCategory.PLUGINS, "azure_discovery_plugin", "azure classic discovery plugin is deprecated.");
logger.trace("starting azure classic discovery plugin...");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static AWSCredentials loadCredentials(Settings settings) {
return null;
} else {
if (key.length() == 0) {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.SETTINGS,
"ec2_invalid_settings",
"Setting [{}] is set but [{}] is not, which will be unsupported in future",
Expand All @@ -160,7 +160,7 @@ static AWSCredentials loadCredentials(Settings settings) {
);
}
if (secret.length() == 0) {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.SETTINGS,
"ec2_invalid_settings",
"Setting [{}] is set but [{}] is not, which will be unsupported in future",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.amazonaws.auth.BasicSessionCredentials;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;

import org.elasticsearch.common.logging.DeprecationLogger;
import org.apache.logging.log4j.Level;
import org.elasticsearch.common.settings.MockSecureSettings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -73,7 +73,7 @@ public void testDeprecationOfLoneAccessKey() {
assertSettingDeprecationsAndWarnings(
new Setting<?>[] {},
new DeprecationWarning(
DeprecationLogger.CRITICAL,
Level.WARN,
"Setting [discovery.ec2.access_key] is set but " + "[discovery.ec2.secret_key] is not, which will be unsupported in future"
)
);
Expand All @@ -91,7 +91,7 @@ public void testDeprecationOfLoneSecretKey() {
assertSettingDeprecationsAndWarnings(
new Setting<?>[] {},
new DeprecationWarning(
DeprecationLogger.CRITICAL,
Level.WARN,
"Setting [discovery.ec2.secret_key] is set but " + "[discovery.ec2.access_key] is not, which will be unsupported in future"
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void testConcurrentDeprecationLogger() throws IOException, UserException,
}
for (int j = 0; j < iterations; j++) {
for (final Integer id : ids) {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.OTHER,
Integer.toString(id),
"This is a maybe logged deprecation message" + id
Expand Down Expand Up @@ -167,7 +167,7 @@ public void testConcurrentDeprecationLogger() throws IOException, UserException,
for (int i = 0; i < 128; i++) {
assertLogLine(
deprecationEvents.get(i),
DeprecationLogger.CRITICAL,
Level.WARN,
"org.elasticsearch.common.logging.DeprecationLogger.logDeprecation",
"This is a maybe logged deprecation message" + i
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private static void checkSystemAliasAccess(
}

if (systemAliases.isEmpty() == false) {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.API,
"open_system_alias_access",
"this request accesses aliases with names reserved for system indices: {}, but in a future major version, direct "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ private Index[] resolveLocalIndices(OriginalIndices localIndices, ClusterState c
}
}
if (frozenIndices != null) {
DEPRECATION_LOGGER.critical(
DEPRECATION_LOGGER.warn(
DeprecationCategory.INDICES,
"search-frozen-indices",
FROZEN_INDICES_DEPRECATION_MESSAGE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public boolean validateDotIndex(String index, @Nullable Boolean isHidden) {
} else if (isHidden) {
logger.trace("index [{}] is a hidden index", index);
} else {
DEPRECATION_LOGGER.critical(
DEPRECATION_LOGGER.warn(
DeprecationCategory.INDICES,
"index_name_starts_with_dot",
"index name [{}] starts with a dot '.', in the next major version, index names "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public static ZoneId dateTimeZoneToZoneId(DateTimeZone timeZone) {
public static ZoneId of(String zoneId) {
String deprecatedId = DEPRECATED_SHORT_TIMEZONES.get(zoneId);
if (deprecatedId != null) {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.PARSING,
"timezone",
"Use of short timezone id " + zoneId + " is deprecated. Use " + deprecatedId + " instead"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private static ByteSizeValue parse(
} catch (final NumberFormatException e) {
try {
final double doubleValue = Double.parseDouble(s);
DeprecationLoggerHolder.deprecationLogger.critical(
DeprecationLoggerHolder.deprecationLogger.warn(
DeprecationCategory.PARSING,
"fractional_byte_values",
"Fractional bytes values are deprecated. Use non-fractional bytes values instead: [{}] found for setting [{}]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public Sort buildIndexSort(
if (this.indexCreatedVersion.onOrAfter(Version.V_7_13_0)) {
throw new IllegalArgumentException("Cannot use alias [" + sortSpec.field + "] as an index sort field");
} else {
DEPRECATION_LOGGER.critical(
DEPRECATION_LOGGER.warn(
DeprecationCategory.MAPPINGS,
"index-sort-aliases",
"Index sort for index ["
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class Analysis {
public static void checkForDeprecatedVersion(String name, Settings settings) {
String sVersion = settings.get("version");
if (sVersion != null) {
DEPRECATION_LOGGER.critical(
DEPRECATION_LOGGER.warn(
DeprecationCategory.ANALYSIS,
"analyzer.version",
"Setting [version] on analysis component [" + name + "] has no effect and is deprecated"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ShingleTokenFilterFactory(IndexSettings indexSettings, Environment enviro
+ "] index level setting."
);
} else {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.ANALYSIS,
"excessive_shingle_diff",
"Deprecated big difference between maxShingleSize and minShingleSize"
Expand Down Expand Up @@ -81,7 +81,7 @@ public TokenFilterFactory getSynonymFilter() {
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) {
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
} else {
DEPRECATION_LOGGER.critical(
DEPRECATION_LOGGER.warn(
DeprecationCategory.ANALYSIS,
"synonym_tokenfilters",
"Token filter " + name() + "] will not be usable to parse synonym after v7.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public CompletionFieldMapper build(MapperBuilderContext context) {

private void checkCompletionContextsLimit() {
if (this.contexts.getValue() != null && this.contexts.getValue().size() > COMPLETION_CONTEXTS_LIMIT) {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.MAPPINGS,
"excessive_completion_contexts",
"You have defined more than ["
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private Long parseNullValue(DateFieldType fieldType) {
try {
return fieldType.parse(nullValue.getValue());
} catch (Exception e) {
DEPRECATION_LOGGER.critical(
DEPRECATION_LOGGER.warn(
DeprecationCategory.MAPPINGS,
"date_mapper_null_field",
"Error parsing ["
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public Query termQuery(Object value, SearchExecutionContext context) {
if (isEnabled() == false) {
throw new IllegalStateException("Cannot run [exists] queries if the [_field_names] field is disabled");
}
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.MAPPINGS,
"terms_query_on_field_names",
"terms query on the _field_names field is deprecated and will be removed, use exists query instead"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected List<Parameter<?>> getParameters() {
@Override
public GeoShapeFieldMapper build(MapperBuilderContext context) {
if (multiFieldsBuilder.hasMultiFields()) {
DEPRECATION_LOGGER.critical(
DEPRECATION_LOGGER.warn(
DeprecationCategory.MAPPINGS,
"geo_shape_multifields",
"Adding multifields to [geo_shape] mappers has no effect and will be forbidden in future"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ protected ScoreFunction doToFunction(SearchExecutionContext context) {
} else {
String fieldName;
if (field == null) {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.QUERIES,
"seed_requires_field",
"As of version 7.0 Elasticsearch will require that a [field] parameter is provided when a [seed] is set"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private static AfterEffect parseAfterEffect(Version indexCreatedVersion, Setting
"After effect [" + afterEffect + "] isn't supported anymore, please use another effect."
);
} else {
deprecationLogger.critical(
deprecationLogger.warn(
DeprecationCategory.QUERIES,
afterEffect + "_after_effect_replaced",
"After effect ["
Expand Down
Loading

0 comments on commit 6358afb

Please sign in to comment.