Skip to content

Commit

Permalink
Deprecation logs indexing is enabled by default (elastic#78991)
Browse files Browse the repository at this point in the history
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 elastic#78850 is done.

closes elastic#76292
  • Loading branch information
pgomulka committed Oct 13, 2021
1 parent 48582ec commit 0737ece
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public class ElasticsearchNode implements TestClusterConfiguration {
private static final TimeUnit ADDITIONAL_CONFIG_TIMEOUT_UNIT = TimeUnit.SECONDS;
private static final List<String> OVERRIDABLE_SETTINGS = Arrays.asList(
"path.repo",
"discovery.seed_providers"
"discovery.seed_providers",
"cluster.deprecation_indexing.enabled"

);

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugin/deprecation/qa/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,15 @@ 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"));
assertOK(response);
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(() -> {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class Deprecation extends Plugin implements ActionPlugin {

public static final Setting<Boolean> WRITE_DEPRECATION_LOGS_TO_INDEX = Setting.boolSetting(
"cluster.deprecation_indexing.enabled",
false,
true,
Setting.Property.NodeScope,
Setting.Property.Dynamic
);
Expand Down Expand Up @@ -99,12 +99,12 @@ public Collection<Object> 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,
Expand Down

0 comments on commit 0737ece

Please sign in to comment.