Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resurrect _cluster/voting_config_exclusions/{node_name} #75951

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
@@ -0,0 +1,33 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this route will always produce an error even in compatibility mode, should we not create an API specification for it? I'm not sure we want this API to be in generated clients

Copy link
Contributor Author

@joegallo joegallo Aug 10, 2021

Choose a reason for hiding this comment

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

Since it's under rest-api-spec/src/yamlRestCompatTest/resources/rest-api-spec/api/, I think we're already good on that, right? That is, this is just intended to be a spec definition for the purposes of the yml tests themselves, it's not supposed to leak up and out.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I don't know the rules for which files are picked up by the artifacts API and which aren't. If this file doesn't make it's way into the built artifact for rest-api-spec then this is fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am pretty confident that this will not get picked up to be visible by clients, if it does we can quickly fix it (or revert this PR).

"cluster.post_voting_config_exclusions_with_node_name_part":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html",
"description":"Updates the cluster voting config exclusions by node_name (not node ids or node names)."
},
"stability":"stable",
"visibility":"public",
"headers":{
"accept": [ "application/vnd.elasticsearch+json;compatible-with=7"]
},
"url":{
"paths":[
{
"path":"/_cluster/voting_config_exclusions/{node_name}",
"methods":[
"POST"
],
"parts":{
"node_name":{
"type":"string",
"description":"A comma-separated list of node descriptors of the nodes to exclude from the voting configuration."
}
},
"deprecated":{
"version":"7.8.0",
"description":"node_name is deprecated, use node_names or node_ids instead"
}
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
setup:
- skip:
version: "9.0.0 - "
reason: "compatible from 8.x to 7.x"
features:
- "headers"
- "warnings_regex"

---
"Throw exception when adding voting config exclusion by specifying a 'node_name'":
- do:
headers:
Content-Type: "application/vnd.elasticsearch+json;compatible-with=7"
Accept: "application/vnd.elasticsearch+json;compatible-with=7"
cluster.post_voting_config_exclusions_with_node_name_part:
node_name: someNodeName
warnings_regex:
- ".* /_cluster/voting_config_exclusions/\\{node_name\\} has been removed. .*"
catch: /\[node_name\] has been removed, you must set \[node_names\] or \[node_ids\]/
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.elasticsearch.action.admin.cluster.configuration.AddVotingConfigExclusionsRequest;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
Expand All @@ -25,14 +26,22 @@
public class RestAddVotingConfigExclusionAction extends BaseRestHandler {
private static final TimeValue DEFAULT_TIMEOUT = TimeValue.timeValueSeconds(30L);

private static final String DEPRECATION_MESSAGE = "POST /_cluster/voting_config_exclusions/{node_name} " +
"has been removed. You must use POST /_cluster/voting_config_exclusions?node_ids=... " +
"or POST /_cluster/voting_config_exclusions?node_names=... instead.";

@Override
public String getName() {
return "add_voting_config_exclusions_action";
}

@Override
public List<Route> routes() {
return List.of(new Route(POST, "/_cluster/voting_config_exclusions"));
return List.of(
new Route(POST, "/_cluster/voting_config_exclusions"),
Route.builder(POST, "/_cluster/voting_config_exclusions/{node_name}")
.deprecated(DEPRECATION_MESSAGE, RestApiVersion.V_7).build()
);
}

@Override
Expand All @@ -49,6 +58,10 @@ AddVotingConfigExclusionsRequest resolveVotingConfigExclusionsRequest(final Rest
String nodeIds = null;
String nodeNames = null;

if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("node_name")) {
throw new IllegalArgumentException("[node_name] has been removed, you must set [node_names] or [node_ids]");
}

if (request.hasParam("node_ids")) {
nodeIds = request.param("node_ids");
}
Expand Down