-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run Node deprecation checks locally (#38065)
At times, we need to check for usage of deprecated settings in settings which should not be returned by the NodeInfo API. This commit changes the deprecation info API to run all node checks locally so that these settings can be checked without exposing them via any externally accessible API.
- Loading branch information
Showing
14 changed files
with
600 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
...e/src/main/java/org/elasticsearch/xpack/core/deprecation/NodesDeprecationCheckAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.deprecation; | ||
|
||
import org.elasticsearch.action.Action; | ||
import org.elasticsearch.action.support.nodes.BaseNodeRequest; | ||
import org.elasticsearch.action.support.nodes.BaseNodeResponse; | ||
import org.elasticsearch.action.support.nodes.NodesOperationRequestBuilder; | ||
import org.elasticsearch.client.ElasticsearchClient; | ||
import org.elasticsearch.cluster.node.DiscoveryNode; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Runs deprecation checks on each node. Deprecation checks are performed locally so that filtered settings | ||
* can be accessed in the deprecation checks. | ||
*/ | ||
public class NodesDeprecationCheckAction extends Action<NodesDeprecationCheckRequest, NodesDeprecationCheckResponse, | ||
NodesDeprecationCheckAction.RequestBuilder> { | ||
public static final NodesDeprecationCheckAction INSTANCE = new NodesDeprecationCheckAction(); | ||
public static final String NAME = "cluster:admin/xpack/deprecation/nodes/info"; | ||
|
||
private NodesDeprecationCheckAction() { | ||
super(NAME); | ||
} | ||
|
||
@Override | ||
public RequestBuilder newRequestBuilder(ElasticsearchClient client) { | ||
return new RequestBuilder(client, INSTANCE, new NodesDeprecationCheckRequest()); | ||
} | ||
|
||
@Override | ||
public NodesDeprecationCheckResponse newResponse() { | ||
return new NodesDeprecationCheckResponse(); | ||
} | ||
|
||
public static class NodeRequest extends BaseNodeRequest { | ||
|
||
NodesDeprecationCheckRequest request; | ||
|
||
public NodeRequest() {} | ||
public NodeRequest(String nodeId, NodesDeprecationCheckRequest request) { | ||
super(nodeId); | ||
this.request = request; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
request = new NodesDeprecationCheckRequest(); | ||
request.readFrom(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
request.writeTo(out); | ||
} | ||
} | ||
|
||
public static class NodeResponse extends BaseNodeResponse { | ||
private List<DeprecationIssue> deprecationIssues; | ||
|
||
public NodeResponse() { | ||
super(); | ||
} | ||
|
||
public NodeResponse(DiscoveryNode node, List<DeprecationIssue> deprecationIssues) { | ||
super(node); | ||
this.deprecationIssues = deprecationIssues; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
deprecationIssues = in.readList(DeprecationIssue::new); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeList(this.deprecationIssues); | ||
} | ||
|
||
public static NodeResponse readNodeResponse(StreamInput in) throws IOException { | ||
NodeResponse nodeResponse = new NodeResponse(); | ||
nodeResponse.readFrom(in); | ||
return nodeResponse; | ||
} | ||
|
||
public List<DeprecationIssue> getDeprecationIssues() { | ||
return deprecationIssues; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
NodeResponse that = (NodeResponse) o; | ||
return Objects.equals(getDeprecationIssues(), that.getDeprecationIssues()) | ||
&& Objects.equals(getNode(), that.getNode()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getNode(), getDeprecationIssues()); | ||
} | ||
} | ||
|
||
public static class RequestBuilder extends NodesOperationRequestBuilder<NodesDeprecationCheckRequest, | ||
NodesDeprecationCheckResponse, RequestBuilder> { | ||
|
||
protected RequestBuilder(ElasticsearchClient client, | ||
Action<NodesDeprecationCheckRequest, NodesDeprecationCheckResponse, RequestBuilder> action, | ||
NodesDeprecationCheckRequest request) { | ||
super(client, action, request); | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
.../src/main/java/org/elasticsearch/xpack/core/deprecation/NodesDeprecationCheckRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.deprecation; | ||
|
||
import org.elasticsearch.action.support.nodes.BaseNodesRequest; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
public class NodesDeprecationCheckRequest extends BaseNodesRequest<NodesDeprecationCheckRequest> { | ||
public NodesDeprecationCheckRequest() {} | ||
|
||
public NodesDeprecationCheckRequest(String... nodesIds) { | ||
super(nodesIds); | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash((Object[]) this.nodesIds()); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null || getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
NodesDeprecationCheckRequest that = (NodesDeprecationCheckRequest) obj; | ||
return Arrays.equals(this.nodesIds(), that.nodesIds()); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...src/main/java/org/elasticsearch/xpack/core/deprecation/NodesDeprecationCheckResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.deprecation; | ||
|
||
import org.elasticsearch.action.FailedNodeException; | ||
import org.elasticsearch.action.support.nodes.BaseNodesResponse; | ||
import org.elasticsearch.cluster.ClusterName; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class NodesDeprecationCheckResponse extends BaseNodesResponse<NodesDeprecationCheckAction.NodeResponse> { | ||
|
||
public NodesDeprecationCheckResponse() {} | ||
|
||
public NodesDeprecationCheckResponse(ClusterName clusterName, | ||
List<NodesDeprecationCheckAction.NodeResponse> nodes, | ||
List<FailedNodeException> failures) { | ||
super(clusterName, nodes, failures); | ||
} | ||
|
||
@Override | ||
protected List<NodesDeprecationCheckAction.NodeResponse> readNodesFrom(StreamInput in) throws IOException { | ||
return in.readList(NodesDeprecationCheckAction.NodeResponse::readNodeResponse); | ||
} | ||
|
||
@Override | ||
protected void writeNodesTo(StreamOutput out, List<NodesDeprecationCheckAction.NodeResponse> nodes) throws IOException { | ||
out.writeStreamableList(nodes); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
NodesDeprecationCheckResponse that = (NodesDeprecationCheckResponse) o; | ||
return Objects.equals(getClusterName(), that.getClusterName()) | ||
&& Objects.equals(getNodes(), that.getNodes()) | ||
&& Objects.equals(failures(), that.failures()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getClusterName(), getNodes(), failures()); | ||
} | ||
} |
Oops, something went wrong.