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

Add GET /_cluster/master endpoint #40047

Closed

Conversation

DaveCTurner
Copy link
Contributor

We discussed recently that the cluster state API should be considered
"internal" and therefore our usual cast-iron stability guarantees do not hold
for this API.

However, today there is no stable API for identifying the current master node
in JSON format. The REST tests that need to do this will typically call GET /_cluster/state and extract the master from the response.

This change introduces the GET /_cluster/master API endpoint to identify the
current master node so that clients do not need to extract the current master
from the cluster state.

We discussed recently that the cluster state API should be considered
"internal" and therefore our usual cast-iron stability guarantees do not hold
for this API.

However, today there is no stable API for identifying the current master node
in JSON format. The REST tests that need to do this will typically call `GET
/_cluster/state` and extract the master from the response.

This change introduces the `GET /_cluster/master` API endpoint to identify the
current master node so that clients do not need to extract the current master
from the cluster state.
@DaveCTurner DaveCTurner added >enhancement :Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. v8.0.0 v7.2.0 labels Mar 14, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

"get cluster master":
- skip:
version: " - 7.99.99"
reason: Get cluster master API was introduced in 8.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After backporting, as a follow up, this skip can be removed, and all the REST tests that get the master ID from the cluster state can migrate to using this API instead.

@javanna
Copy link
Member

javanna commented Mar 14, 2019

nice, shall we add support for this new api to the high-level client as part of this PR?

@ywelsch
Copy link
Contributor

ywelsch commented Mar 14, 2019

However, today there is no stable API for identifying the current master node
in JSON format

I wonder if we can just achieve the same thing with GET /_nodes/_master?metrics=

@DaveCTurner
Copy link
Contributor Author

I wonder if we can just achieve the same thing with GET /_nodes/_master?metrics=

The node ID only appears as the (unique) key of the resulting map of nodes. I sketched a possible way to do this in #40052, but it's kinda icky.

@ywelsch
Copy link
Contributor

ywelsch commented Mar 15, 2019

The advantage of the approach in #40052 is that the yml tests become simpler, avoiding the extra call to determine the master at the beginning of the test. I'm not sure yet whether we want to enforce uniqueness or whether we should just support a wildcard selector * as a (non-deterministic) choice operator, and leave it to the caller to make sure that the given property makes sense for any key.

@DaveCTurner
Copy link
Contributor Author

In fact most of the REST tests don't want the master node ID: picking an arbitrary ID (perhaps of a data node) is closer to what they want. Closing this in favour of #40052.

@DaveCTurner DaveCTurner deleted the 2019-03-14-cluster-master-api branch March 18, 2019 12:24
DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Mar 27, 2019
We discussed recently that the cluster state API should be considered
"internal" and therefore our usual cast-iron stability guarantees do not hold
for this API.

However, there are a good number of REST tests that try to identify the master
node. Today they call `GET /_cluster/state` API and extract the master node ID
from the response. In fact many of these tests just want an arbitary node ID
(or perhaps a data node ID) so an alternative is to call `GET _nodes` or `GET
_nodes/data:true` and obtain a node ID from the keys of the `nodes` map in the
response.

This change adds the ability for YAML-based REST tests to extract an arbitrary
key from a map so that they can obtain a node ID from the nodes info API
instead of using the master node ID from the cluster state API.

Relates elastic#40047.
DaveCTurner added a commit that referenced this pull request Mar 27, 2019
We discussed recently that the cluster state API should be considered
"internal" and therefore our usual cast-iron stability guarantees do not hold
for this API.

However, there are a good number of REST tests that try to identify the master
node. Today they call `GET /_cluster/state` API and extract the master node ID
from the response. In fact many of these tests just want an arbitary node ID
(or perhaps a data node ID) so an alternative is to call `GET _nodes` or `GET
_nodes/data:true` and obtain a node ID from the keys of the `nodes` map in the
response.

This change adds the ability for YAML-based REST tests to extract an arbitrary
key from a map so that they can obtain a node ID from the nodes info API
instead of using the master node ID from the cluster state API.

Relates #40047.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. >enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants