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

Introduce deprecation categories #67443

Merged
merged 10 commits into from
Jan 18, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -253,7 +254,7 @@ public TokenStream create(TokenStream tokenStream) {
"The [edgeNGram] token filter name was deprecated in 6.4 and cannot be used in new indices. "
+ "Please change the filter name to [edge_ngram] instead.");
} else {
deprecationLogger.deprecate("edgeNGram_deprecation",
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_deprecation",
"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 @@ -290,7 +291,7 @@ public TokenStream create(TokenStream tokenStream) {
"The [nGram] token filter name was deprecated in 6.4 and cannot be used in new indices. "
+ "Please change the filter name to [ngram] instead.");
} else {
deprecationLogger.deprecate("nGram_deprecation",
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_deprecation",
"The [nGram] token filter name is deprecated and will be removed in a future version. "
+ "Please change the filter name to [ngram] instead.");
}
Expand Down Expand Up @@ -346,7 +347,7 @@ public Map<String, AnalysisProvider<TokenizerFactory>> getTokenizers() {
throw new IllegalArgumentException("The [nGram] tokenizer name was deprecated in 7.6. "
+ "Please use the tokenizer name to [ngram] for indices created in versions 8 or higher instead.");
} else if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.deprecate("nGram_tokenizer_deprecation",
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation",
"The [nGram] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [ngram] instead.");
}
Expand All @@ -358,7 +359,7 @@ public Map<String, AnalysisProvider<TokenizerFactory>> getTokenizers() {
throw new IllegalArgumentException("The [edgeNGram] tokenizer name was deprecated in 7.6. "
+ "Please use the tokenizer name to [edge_nGram] for indices created in versions 8 or higher instead.");
} else if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.deprecate("edgeNGram_tokenizer_deprecation",
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation",
"The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [edge_ngram] instead.");
}
Expand Down Expand Up @@ -551,7 +552,7 @@ public List<PreConfiguredTokenizer> getPreConfiguredTokenizers() {
throw new IllegalArgumentException("The [nGram] tokenizer name was deprecated in 7.6. "
+ "Please use the tokenizer name to [ngram] for indices created in versions 8 or higher instead.");
} else if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.deprecate("nGram_tokenizer_deprecation",
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation",
"The [nGram] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [ngram] instead.");
}
Expand All @@ -562,7 +563,7 @@ public List<PreConfiguredTokenizer> getPreConfiguredTokenizers() {
throw new IllegalArgumentException("The [edgeNGram] tokenizer name was deprecated in 7.6. "
+ "Please use the tokenizer name to [edge_ngram] for indices created in versions 8 or higher instead.");
} else if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.deprecate("edgeNGram_tokenizer_deprecation",
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation",
"The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [edge_ngram] instead.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.synonym.SynonymFilter;
import org.apache.lucene.analysis.synonym.SynonymMap;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
Expand Down Expand Up @@ -57,7 +58,7 @@ public class SynonymTokenFilterFactory extends AbstractTokenFilterFactory {
this.settings = settings;

if (settings.get("ignore_case") != null) {
DEPRECATION_LOGGER.deprecate("synonym_ignore_case_option",
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_ignore_case_option",
"The ignore_case option on the synonym_graph filter is deprecated. " +
"Instead, insert a lowercase filter in the filter chain before the synonym_graph filter.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.elasticsearch.ingest.useragent;

import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.ingest.AbstractProcessor;
import org.elasticsearch.ingest.IngestDocument;
Expand Down Expand Up @@ -186,7 +187,7 @@ public UserAgentProcessor create(Map<String, Processor.Factory> factories, Strin
boolean ignoreMissing = readBooleanProperty(TYPE, processorTag, config, "ignore_missing", false);
Object ecsValue = config.remove("ecs");
if (ecsValue != null) {
deprecationLogger.deprecate("ingest_useragent_ecs_settings",
deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "ingest_useragent_ecs_settings",
"setting [ecs] is deprecated as ECS format is the default and only option");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -66,7 +67,7 @@ void initialValidation(ReindexRequest request) {
state);
SearchSourceBuilder searchSource = request.getSearchRequest().source();
if (searchSource != null && searchSource.sorts() != null && searchSource.sorts().isEmpty() == false) {
deprecationLogger.deprecate("reindex_sort", SORT_DEPRECATED_MESSAGE);
deprecationLogger.deprecate(DeprecationCategory.API, "reindex_sort", SORT_DEPRECATED_MESSAGE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.logging.log4j.Logger;
import org.elasticsearch.cloud.azure.classic.management.AzureComputeService;
import org.elasticsearch.cloud.azure.classic.management.AzureComputeServiceImpl;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.settings.Setting;
Expand All @@ -48,7 +49,7 @@ public class AzureDiscoveryPlugin extends Plugin implements DiscoveryPlugin {

public AzureDiscoveryPlugin(Settings settings) {
this.settings = settings;
deprecationLogger.deprecate("azure_discovery_plugin", "azure classic discovery plugin is deprecated.");
deprecationLogger.deprecate(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 @@ -26,6 +26,7 @@
import com.amazonaws.auth.BasicSessionCredentials;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.SecureSetting;
import org.elasticsearch.common.settings.SecureString;
Expand Down Expand Up @@ -135,12 +136,12 @@ static AWSCredentials loadCredentials(Settings settings) {
return null;
} else {
if (key.length() == 0) {
deprecationLogger.deprecate("ec2_invalid_settings",
deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "ec2_invalid_settings",
"Setting [{}] is set but [{}] is not, which will be unsupported in future",
SECRET_KEY_SETTING.getKey(), ACCESS_KEY_SETTING.getKey());
}
if (secret.length() == 0) {
deprecationLogger.deprecate("ec2_invalid_settings",
deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "ec2_invalid_settings",
"Setting [{}] is set but [{}] is not, which will be unsupported in future",
ACCESS_KEY_SETTING.getKey(), SECRET_KEY_SETTING.getKey());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ public void testConcurrentDeprecationLogger() throws IOException, UserException,
}
for (int j = 0; j < iterations; j++) {
for (final Integer id : ids) {
deprecationLogger.deprecate(Integer.toString(id), "This is a maybe logged deprecation message" + id);
deprecationLogger.deprecate(DeprecationCategory.OTHER, Integer.toString(id),
"This is a maybe logged deprecation message" + id);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void tearDown() throws Exception {
public void testDeprecatedMessageWithoutXOpaqueId() throws IOException {
final DeprecationLogger testLogger = DeprecationLogger.getLogger("test");

testLogger.deprecate("a key", "deprecated message1");
testLogger.deprecate(DeprecationCategory.OTHER, "a key", "deprecated message1");

final Path path = PathUtils.get(System.getProperty("es.logs.base_path"),
System.getProperty("es.logs.cluster_name") + "_deprecated.json");
Expand All @@ -111,7 +111,8 @@ public void testDeprecatedMessageWithoutXOpaqueId() throws IOException {
hasEntry("data_stream.namespace", "default"),
hasEntry("ecs.version", DeprecatedMessage.ECS_VERSION),
hasEntry("key", "a key"),
not(hasKey("x-opaque-id"))
not(hasKey("x-opaque-id")),
hasEntry("elasticsearch.event.category", "other")
)
)
);
Expand All @@ -124,7 +125,7 @@ public void testDeprecatedMessage() throws Exception {
withThreadContext(threadContext -> {
threadContext.putHeader(Task.X_OPAQUE_ID, "someId");
final DeprecationLogger testLogger = DeprecationLogger.getLogger("test");
testLogger.deprecate("someKey", "deprecated message1");
testLogger.deprecate(DeprecationCategory.OTHER, "someKey", "deprecated message1");

final Path path = PathUtils.get(
System.getProperty("es.logs.base_path"),
Expand All @@ -149,7 +150,8 @@ public void testDeprecatedMessage() throws Exception {
hasEntry("data_stream.namespace", "default"),
hasEntry("ecs.version", DeprecatedMessage.ECS_VERSION),
hasEntry("key", "someKey"),
hasEntry("x-opaque-id", "someId")
hasEntry("x-opaque-id", "someId"),
hasEntry("elasticsearch.event.category", "other")
)
)
);
Expand Down Expand Up @@ -336,8 +338,8 @@ public void testDuplicateLogMessages() throws Exception {
// For the same key and X-Opaque-ID deprecation should be once
withThreadContext(threadContext -> {
threadContext.putHeader(Task.X_OPAQUE_ID, "ID1");
deprecationLogger.deprecate("key", "message1");
deprecationLogger.deprecate("key", "message2");
deprecationLogger.deprecate(DeprecationCategory.OTHER, "key", "message1");
deprecationLogger.deprecate(DeprecationCategory.OTHER, "key", "message2");
assertWarnings("message1", "message2");

final Path path = PathUtils.get(System.getProperty("es.logs.base_path"),
Expand All @@ -354,7 +356,8 @@ public void testDuplicateLogMessages() throws Exception {
hasEntry("cluster.name", "elasticsearch"),
hasEntry("node.name", "sample-name"),
hasEntry("message", "message1"),
hasEntry("x-opaque-id", "ID1"))
hasEntry("x-opaque-id", "ID1"),
hasEntry("elasticsearch.event.category", "other"))
)
);
}
Expand All @@ -364,8 +367,8 @@ public void testDuplicateLogMessages() throws Exception {
//continuing with message1-ID1 in logs already, adding a new deprecation log line with message2-ID2
withThreadContext(threadContext -> {
threadContext.putHeader(Task.X_OPAQUE_ID, "ID2");
deprecationLogger.deprecate("key", "message1");
deprecationLogger.deprecate("key", "message2");
deprecationLogger.deprecate(DeprecationCategory.OTHER, "key", "message1");
deprecationLogger.deprecate(DeprecationCategory.OTHER, "key", "message2");
assertWarnings("message1", "message2");

final Path path = PathUtils.get(
Expand All @@ -385,7 +388,8 @@ public void testDuplicateLogMessages() throws Exception {
hasEntry("cluster.name", "elasticsearch"),
hasEntry("node.name", "sample-name"),
hasEntry("message", "message1"),
hasEntry("x-opaque-id", "ID1")
hasEntry("x-opaque-id", "ID1"),
hasEntry("elasticsearch.event.category", "other")
),
allOf(
hasEntry("type", "deprecation"),
Expand All @@ -394,7 +398,8 @@ public void testDuplicateLogMessages() throws Exception {
hasEntry("cluster.name", "elasticsearch"),
hasEntry("node.name", "sample-name"),
hasEntry("message", "message1"),
hasEntry("x-opaque-id", "ID2")
hasEntry("x-opaque-id", "ID2"),
hasEntry("elasticsearch.event.category", "other")
)
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.indices.SystemIndices;
Expand Down Expand Up @@ -112,7 +113,7 @@ private static void checkSystemIndexAccess(GetAliasesRequest request, SystemIndi
}
}
if (systemIndicesNames.isEmpty() == false) {
deprecationLogger.deprecate("open_system_index_access",
deprecationLogger.deprecate(DeprecationCategory.API, "open_system_index_access",
"this request accesses system indices: {}, but in a future major version, direct access to system " +
"indices will be prevented by default", systemIndicesNames);
} else {
Expand All @@ -125,7 +126,7 @@ private static void checkSystemAliasAccess(GetAliasesRequest request, SystemIndi
.filter(alias -> systemIndices.isSystemIndex(alias))
.collect(Collectors.toList());
if (systemAliases.isEmpty() == false) {
deprecationLogger.deprecate("open_system_alias_access",
deprecationLogger.deprecate(DeprecationCategory.API, "open_system_alias_access",
"this request accesses aliases with names reserved for system indices: {}, but in a future major version, direct" +
"access to system indices and their aliases will not be allowed", systemAliases);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.elasticsearch.common.Nullable;
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.regex.Regex;
import org.elasticsearch.common.time.DateFormatter;
Expand Down Expand Up @@ -321,7 +322,7 @@ private void checkSystemIndexAccess(Context context, Metadata metadata, Set<Inde
.sorted() // reliable order for testing
.collect(Collectors.toList());
if (resolvedSystemIndices.isEmpty() == false) {
deprecationLogger.deprecate("open_system_index_access",
deprecationLogger.deprecate(DeprecationCategory.API, "open_system_index_access",
"this request accesses system indices: {}, but in a future major version, direct access to system " +
"indices will be prevented by default", resolvedSystemIndices);
}
Expand Down
Loading