From 0737ecec14ab777caf7610599d0b80e090eb1c39 Mon Sep 17 00:00:00 2001 From: Przemyslaw Gomulka Date: Wed, 13 Oct 2021 09:49:12 +0200 Subject: [PATCH] Deprecation logs indexing is enabled by default (#78991) Changing the default for deprecation log indexing to be true. This commit also overrides this default to tests where a deprecation data stream would interfere - because it uses index template, it would not be possible to delete with _index_template/*. The overrides should be removed when #78850 is done. closes #76292 --- .../gradle/testclusters/ElasticsearchCluster.java | 6 ++++++ .../gradle/testclusters/ElasticsearchNode.java | 3 ++- x-pack/plugin/deprecation/qa/rest/build.gradle | 1 + .../elasticsearch/xpack/deprecation/DeprecationHttpIT.java | 7 ++----- .../org/elasticsearch/xpack/deprecation/Deprecation.java | 6 +++--- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java index 947d1c6dc22f8..4857a21118152 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java @@ -11,6 +11,7 @@ import org.elasticsearch.gradle.Jdk; import org.elasticsearch.gradle.PropertyNormalization; import org.elasticsearch.gradle.ReaperService; +import org.elasticsearch.gradle.Version; import org.gradle.api.Named; import org.gradle.api.NamedDomainObjectContainer; import org.gradle.api.Project; @@ -332,6 +333,11 @@ private void commonNodeConfig() { } ElasticsearchNode firstNode = null; for (ElasticsearchNode node : nodes) { + if (node.getTestDistribution().equals(TestDistribution.DEFAULT)) { + if (node.getVersion().onOrAfter("7.16.0")) { + node.defaultConfig.put("cluster.deprecation_indexing.enabled", "false"); + } + } // Can only configure master nodes if we have node names defined if (nodeNames != null) { commonNodeConfig(node, nodeNames, firstNode); diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java index 8ba787a773f95..81e9df2ed83c1 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java @@ -104,7 +104,8 @@ public class ElasticsearchNode implements TestClusterConfiguration { private static final TimeUnit ADDITIONAL_CONFIG_TIMEOUT_UNIT = TimeUnit.SECONDS; private static final List OVERRIDABLE_SETTINGS = Arrays.asList( "path.repo", - "discovery.seed_providers" + "discovery.seed_providers", + "cluster.deprecation_indexing.enabled" ); diff --git a/x-pack/plugin/deprecation/qa/rest/build.gradle b/x-pack/plugin/deprecation/qa/rest/build.gradle index 8904da0e5cdd8..b2cf233921fc1 100644 --- a/x-pack/plugin/deprecation/qa/rest/build.gradle +++ b/x-pack/plugin/deprecation/qa/rest/build.gradle @@ -26,6 +26,7 @@ restResources { testClusters.configureEach { testDistribution = 'DEFAULT' + setting 'cluster.deprecation_indexing.enabled', 'true' setting 'xpack.security.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' } diff --git a/x-pack/plugin/deprecation/qa/rest/src/javaRestTest/java/org/elasticsearch/xpack/deprecation/DeprecationHttpIT.java b/x-pack/plugin/deprecation/qa/rest/src/javaRestTest/java/org/elasticsearch/xpack/deprecation/DeprecationHttpIT.java index 253f3f3787612..762ea7203b24c 100644 --- a/x-pack/plugin/deprecation/qa/rest/src/javaRestTest/java/org/elasticsearch/xpack/deprecation/DeprecationHttpIT.java +++ b/x-pack/plugin/deprecation/qa/rest/src/javaRestTest/java/org/elasticsearch/xpack/deprecation/DeprecationHttpIT.java @@ -65,7 +65,6 @@ public class DeprecationHttpIT extends ESRestTestCase { @Before public void assertIndexingIsEnabled() throws Exception { - configureWriteDeprecationLogsToIndex(true); // make sure the deprecation logs indexing is enabled Response response = client().performRequest(new Request("GET", "/_cluster/settings?include_defaults=true&flat_settings=true")); @@ -73,8 +72,8 @@ public void assertIndexingIsEnabled() throws Exception { ObjectMapper mapper = new ObjectMapper(); final JsonNode jsonNode = mapper.readTree(response.getEntity().getContent()); - final boolean transientValue = jsonNode.at("/transient/cluster.deprecation_indexing.enabled").asBoolean(); - assertTrue(transientValue); + final boolean defaultValue = jsonNode.at("/defaults/cluster.deprecation_indexing.enabled").asBoolean(); + assertTrue(defaultValue); // assert index does not exist, which will prevent previous tests to interfere assertBusy(() -> { @@ -348,8 +347,6 @@ public void testDeprecationRouteThrottling() throws Exception { } public void testDisableDeprecationLogIndexing() throws Exception { - - configureWriteDeprecationLogsToIndex(true); final Request deprecatedRequest = deprecatedRequest("GET", "xOpaqueId-testDisableDeprecationLogIndexing"); assertOK(client().performRequest(deprecatedRequest)); configureWriteDeprecationLogsToIndex(false); diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java index 5342b4670942c..89fed9dea1b51 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java @@ -49,7 +49,7 @@ public class Deprecation extends Plugin implements ActionPlugin { public static final Setting WRITE_DEPRECATION_LOGS_TO_INDEX = Setting.boolSetting( "cluster.deprecation_indexing.enabled", - false, + true, Setting.Property.NodeScope, Setting.Property.Dynamic ); @@ -99,12 +99,12 @@ public Collection createComponents( final RateLimitingFilter rateLimitingFilterForIndexing = new RateLimitingFilter(); // enable on start. - rateLimitingFilterForIndexing.setUseXOpaqueId(USE_X_OPAQUE_ID_IN_FILTERING.getDefault(environment.settings())); + rateLimitingFilterForIndexing.setUseXOpaqueId(USE_X_OPAQUE_ID_IN_FILTERING.get(environment.settings())); final DeprecationIndexingComponent component = new DeprecationIndexingComponent(client, environment.settings(), rateLimitingFilterForIndexing, - WRITE_DEPRECATION_LOGS_TO_INDEX.getDefault(environment.settings()) //pass the default on startup + WRITE_DEPRECATION_LOGS_TO_INDEX.get(environment.settings()) //pass the default on startup ); clusterService.getClusterSettings().addSettingsUpdateConsumer(USE_X_OPAQUE_ID_IN_FILTERING,