Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
eb7b42a
Remove unnecessary bwc code from test
gmarouli Jan 29, 2025
1be4642
Convert TransformDeprecationChecker from a plugin check to cluster se…
gmarouli Jan 29, 2025
18fddc5
Create NodeDeprecationChecker that retrieves the node settings issues
gmarouli Jan 29, 2025
2d9cb35
Remove unused LegacyIndexTemplateDeprecationChecker.java
gmarouli Jan 29, 2025
cd19eca
Keep one of the `filterChecks` methods
gmarouli Jan 29, 2025
d52eea2
Move the creation of the DeprecationInfoAction out of the data class
gmarouli Jan 29, 2025
d0b1f5c
Restructure the remote requests in TransportDeprecationInfoAction
gmarouli Jan 29, 2025
d9c304e
Rename Context to something with more "context"
gmarouli Jan 29, 2025
14c1a4c
Merge with main
gmarouli Jan 29, 2025
3715174
Fix format
gmarouli Jan 29, 2025
82ceafc
Fix test
gmarouli Jan 29, 2025
c01c625
Clean up my listener mess
gmarouli Jan 29, 2025
bf1e2a8
Change the merged issue for node warnings, this is tested of in NodeD…
gmarouli Jan 29, 2025
fb3df0a
Merge branch 'main' into handle-9/deprecate-node-attrs-v2-follow-up
gmarouli Jan 30, 2025
7ce49fc
merge with main
gmarouli Jan 31, 2025
7bdaebb
Merge branch 'main' into handle-9/deprecate-node-attrs-v2-follow-up
gmarouli Jan 31, 2025
0ffc1c7
Polishing
gmarouli Jan 31, 2025
5ca2c91
Clean up
gmarouli Jan 31, 2025
8f7d322
Merge branch 'main' into handle-9/deprecate-node-attrs-v2-follow-up
gmarouli Feb 3, 2025
1793a4d
Merge branch 'main' into handle-9/deprecate-node-attrs-v2-follow-up
gmarouli Feb 3, 2025
b4ccb49
Merge branch 'main' into handle-9/deprecate-node-attrs-v2-follow-up
gmarouli Feb 4, 2025
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 @@ -18,7 +18,6 @@
import java.util.List;
import java.util.Map;

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;

public class SourceModeRollingUpgradeIT extends AbstractRollingUpgradeTestCase {
Expand Down Expand Up @@ -83,20 +82,10 @@ public void testConfigureStoredSourceWhenIndexIsCreatedLegacy() throws IOExcepti
private void assertDeprecationWarningForTemplate(String templateName) throws IOException {
var request = new Request("GET", "/_migration/deprecations");
var response = entityAsMap(client().performRequest(request));
if (response.containsKey("templates")) {
// Check the newer version of the deprecation API that contains the templates section
Map<?, ?> issuesByTemplate = (Map<?, ?>) response.get("templates");
assertThat(issuesByTemplate.containsKey(templateName), equalTo(true));
var templateIssues = (List<?>) issuesByTemplate.get(templateName);
assertThat(((Map<?, ?>) templateIssues.getFirst()).get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING));
} else {
// Bwc version with 8.18 until https://github.com/elastic/elasticsearch/pull/120505/ gets backported, clean up after backport
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed because the backport has been completed.

var nodeSettings = (Map<?, ?>) ((List<?>) response.get("node_settings")).getFirst();
assertThat(nodeSettings.get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING));
assertThat(
(String) nodeSettings.get("details"),
containsString(SourceFieldMapper.DEPRECATION_WARNING + " Affected component templates: [" + templateName + "]")
);
}
assertThat(response.containsKey("templates"), equalTo(true));
Map<?, ?> issuesByTemplate = (Map<?, ?>) response.get("templates");
assertThat(issuesByTemplate.containsKey(templateName), equalTo(true));
var templateIssues = (List<?>) issuesByTemplate.get(templateName);
assertThat(((Map<?, ?>) templateIssues.getFirst()).get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING));
}
}
1 change: 1 addition & 0 deletions x-pack/plugin/deprecation/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
requires org.apache.logging.log4j;
requires org.apache.logging.log4j.core;
requires log4j2.ecs.layout;
requires org.apache.lucene.core;

exports org.elasticsearch.xpack.deprecation to org.elasticsearch.server;
exports org.elasticsearch.xpack.deprecation.logging to org.elasticsearch.server;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.deprecation;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.common.TriConsumer;
import org.elasticsearch.xcontent.NamedXContentRegistry;
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
import org.elasticsearch.xpack.core.transform.transforms.TransformConfig;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
* Cluster-specific deprecation checks, this is used to populate the {@code cluster_settings} field
*/
public class ClusterDeprecationChecker {

private static final Logger logger = LogManager.getLogger(ClusterDeprecationChecker.class);
private final List<TriConsumer<ClusterState, List<TransformConfig>, List<DeprecationIssue>>> CHECKS = List.of(
this::checkTransformSettings
);
private final NamedXContentRegistry xContentRegistry;

ClusterDeprecationChecker(NamedXContentRegistry xContentRegistry) {
this.xContentRegistry = xContentRegistry;
}

public List<DeprecationIssue> check(ClusterState clusterState, List<TransformConfig> transformConfigs) {
List<DeprecationIssue> allIssues = new ArrayList<>();
CHECKS.forEach(check -> check.apply(clusterState, transformConfigs, allIssues));
return allIssues;
}

private void checkTransformSettings(
ClusterState clusterState,
List<TransformConfig> transformConfigs,
List<DeprecationIssue> allIssues
) {
for (var config : transformConfigs) {
try {
allIssues.addAll(config.checkForDeprecations(xContentRegistry));
} catch (IOException e) {
logger.warn("failed to check transformation settings for '" + config.getId() + "'", e);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.stream.Collectors;

import static java.util.Map.entry;
import static java.util.Map.ofEntries;
import static org.elasticsearch.xpack.deprecation.DeprecationInfoAction.filterChecks;

/**
* Checks the data streams for deprecation warnings.
Expand All @@ -44,10 +44,24 @@ public DataStreamDeprecationChecker(IndexNameExpressionResolver indexNameExpress

/**
* @param clusterState The cluster state provided for the checker
* @param request not used yet in these checks
* @param precomputedData not used yet in these checks
* @return the name of the data streams that have violated the checks with their respective warnings.
*/
@Override
public Map<String, List<DeprecationIssue>> check(ClusterState clusterState, DeprecationInfoAction.Request request) {
public Map<String, List<DeprecationIssue>> check(
ClusterState clusterState,
DeprecationInfoAction.Request request,
TransportDeprecationInfoAction.PrecomputedData precomputedData
) {
return check(clusterState);
}

/**
* @param clusterState The cluster state provided for the checker
* @return the name of the data streams that have violated the checks with their respective warnings.
*/
public Map<String, List<DeprecationIssue>> check(ClusterState clusterState) {
List<String> dataStreamNames = indexNameExpressionResolver.dataStreamNames(
clusterState,
IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN
Expand All @@ -58,7 +72,10 @@ public Map<String, List<DeprecationIssue>> check(ClusterState clusterState, Depr
Map<String, List<DeprecationIssue>> dataStreamIssues = new HashMap<>();
for (String dataStreamName : dataStreamNames) {
DataStream dataStream = clusterState.metadata().dataStreams().get(dataStreamName);
List<DeprecationIssue> issuesForSingleDataStream = filterChecks(DATA_STREAM_CHECKS, c -> c.apply(dataStream, clusterState));
List<DeprecationIssue> issuesForSingleDataStream = DATA_STREAM_CHECKS.stream()
.map(c -> c.apply(dataStream, clusterState))
.filter(Objects::nonNull)
.toList();
if (issuesForSingleDataStream.isEmpty() == false) {
dataStreamIssues.put(dataStreamName, issuesForSingleDataStream);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.util.function.Predicate;
import java.util.function.Supplier;

import static org.elasticsearch.xpack.deprecation.DeprecationChecks.SKIP_DEPRECATIONS_SETTING;
import static org.elasticsearch.xpack.deprecation.TransportDeprecationInfoAction.SKIP_DEPRECATIONS_SETTING;
import static org.elasticsearch.xpack.deprecation.logging.DeprecationIndexingComponent.DEPRECATION_INDEXING_FLUSH_INTERVAL;

/**
Expand Down

This file was deleted.

Loading