|
@@ -5,11 +5,10 @@
|
|
|
*/
|
|
|
package org.elasticsearch.xpack.deprecation;
|
|
|
|
|
|
+import org.apache.logging.log4j.LogManager;
|
|
|
+import org.apache.logging.log4j.Logger;
|
|
|
import org.elasticsearch.action.ActionListener;
|
|
|
-import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest;
|
|
|
-import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
|
|
-import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest;
|
|
|
-import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
|
|
|
+import org.elasticsearch.action.FailedNodeException;
|
|
|
import org.elasticsearch.action.support.ActionFilters;
|
|
|
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
|
|
|
import org.elasticsearch.client.node.NodeClient;
|
|
@@ -20,7 +19,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|
|
import org.elasticsearch.cluster.service.ClusterService;
|
|
|
import org.elasticsearch.common.inject.Inject;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
-import org.elasticsearch.common.util.concurrent.ThreadContext;
|
|
|
import org.elasticsearch.license.LicenseUtils;
|
|
|
import org.elasticsearch.license.XPackLicenseState;
|
|
|
import org.elasticsearch.threadpool.ThreadPool;
|
|
@@ -29,14 +27,22 @@ import org.elasticsearch.xpack.core.ClientHelper;
|
|
|
import org.elasticsearch.xpack.core.XPackField;
|
|
|
import org.elasticsearch.xpack.core.XPackSettings;
|
|
|
import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction;
|
|
|
+import org.elasticsearch.xpack.core.deprecation.NodesDeprecationCheckAction;
|
|
|
+import org.elasticsearch.xpack.core.deprecation.NodesDeprecationCheckRequest;
|
|
|
import org.elasticsearch.xpack.core.ml.action.GetDatafeedsAction;
|
|
|
import org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfig;
|
|
|
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import static org.elasticsearch.xpack.deprecation.DeprecationChecks.CLUSTER_SETTINGS_CHECKS;
|
|
|
+import static org.elasticsearch.xpack.deprecation.DeprecationChecks.INDEX_SETTINGS_CHECKS;
|
|
|
+import static org.elasticsearch.xpack.deprecation.DeprecationChecks.ML_SETTINGS_CHECKS;
|
|
|
|
|
|
public class TransportDeprecationInfoAction extends TransportMasterNodeReadAction<DeprecationInfoAction.Request,
|
|
|
DeprecationInfoAction.Response> {
|
|
|
+ private static final Logger logger = LogManager.getLogger(TransportDeprecationInfoAction.class);
|
|
|
|
|
|
private final XPackLicenseState licenseState;
|
|
|
private final NodeClient client;
|
|
@@ -76,39 +82,32 @@ public class TransportDeprecationInfoAction extends TransportMasterNodeReadActio
|
|
|
protected final void masterOperation(final DeprecationInfoAction.Request request, ClusterState state,
|
|
|
final ActionListener<DeprecationInfoAction.Response> listener) {
|
|
|
if (licenseState.isDeprecationAllowed()) {
|
|
|
- NodesInfoRequest nodesInfoRequest = new NodesInfoRequest("_local").settings(true).plugins(true);
|
|
|
- NodesStatsRequest nodesStatsRequest = new NodesStatsRequest("_local").fs(true);
|
|
|
|
|
|
- final ThreadContext threadContext = client.threadPool().getThreadContext();
|
|
|
- ClientHelper.executeAsyncWithOrigin(threadContext, ClientHelper.DEPRECATION_ORIGIN, nodesInfoRequest,
|
|
|
- ActionListener.<NodesInfoResponse>wrap(
|
|
|
- nodesInfoResponse -> {
|
|
|
- if (nodesInfoResponse.hasFailures()) {
|
|
|
- throw nodesInfoResponse.failures().get(0);
|
|
|
- }
|
|
|
- ClientHelper.executeAsyncWithOrigin(threadContext, ClientHelper.DEPRECATION_ORIGIN, nodesStatsRequest,
|
|
|
- ActionListener.<NodesStatsResponse>wrap(
|
|
|
- nodesStatsResponse -> {
|
|
|
- if (nodesStatsResponse.hasFailures()) {
|
|
|
- throw nodesStatsResponse.failures().get(0);
|
|
|
- }
|
|
|
+ NodesDeprecationCheckRequest nodeDepReq = new NodesDeprecationCheckRequest("_all");
|
|
|
+ ClientHelper.executeAsyncWithOrigin(client, ClientHelper.DEPRECATION_ORIGIN,
|
|
|
+ NodesDeprecationCheckAction.INSTANCE, nodeDepReq,
|
|
|
+ ActionListener.wrap(response -> {
|
|
|
+ if (response.hasFailures()) {
|
|
|
+ List<String> failedNodeIds = response.failures().stream()
|
|
|
+ .map(failure -> failure.nodeId() + ": " + failure.getMessage())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ logger.warn("nodes failed to run deprecation checks: {}", failedNodeIds);
|
|
|
+ for (FailedNodeException failure : response.failures()) {
|
|
|
+ logger.debug("node {} failed to run deprecation checks: {}", failure.nodeId(), failure);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ getDatafeedConfigs(ActionListener.wrap(
|
|
|
+ datafeeds -> {
|
|
|
+ listener.onResponse(
|
|
|
+ DeprecationInfoAction.Response.from(state, indexNameExpressionResolver,
|
|
|
+ request.indices(), request.indicesOptions(), datafeeds,
|
|
|
+ response, INDEX_SETTINGS_CHECKS, CLUSTER_SETTINGS_CHECKS,
|
|
|
+ ML_SETTINGS_CHECKS));
|
|
|
+ },
|
|
|
+ listener::onFailure
|
|
|
+ ));
|
|
|
|
|
|
- getDatafeedConfigs(ActionListener.wrap(
|
|
|
- datafeeds -> {
|
|
|
- listener.onResponse(
|
|
|
- DeprecationInfoAction.Response.from(nodesInfoResponse.getNodes(),
|
|
|
- nodesStatsResponse.getNodes(), state, indexNameExpressionResolver,
|
|
|
- request.indices(), request.indicesOptions(), datafeeds,
|
|
|
- DeprecationChecks.CLUSTER_SETTINGS_CHECKS,
|
|
|
- DeprecationChecks.NODE_SETTINGS_CHECKS,
|
|
|
- DeprecationChecks.INDEX_SETTINGS_CHECKS,
|
|
|
- DeprecationChecks.ML_SETTINGS_CHECKS));
|
|
|
- },
|
|
|
- listener::onFailure
|
|
|
- ));
|
|
|
- }, listener::onFailure),
|
|
|
- client.admin().cluster()::nodesStats);
|
|
|
- }, listener::onFailure), client.admin().cluster()::nodesInfo);
|
|
|
+ }, listener::onFailure));
|
|
|
} else {
|
|
|
listener.onFailure(LicenseUtils.newComplianceException(XPackField.DEPRECATION));
|
|
|
}
|