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 cluster UUID to Cluster Stats API response #32206

Merged

Conversation

ycombinator
Copy link
Contributor

Resolves #32205.

Adds cluster_uuid field to GET _cluster/stats REST API response.

@ycombinator ycombinator added review :Data Management/Stats Statistics tracking and retrieval APIs v7.0.0 v6.4.0 labels Jul 19, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

I am good with it.

@ycombinator ycombinator force-pushed the rest/cluster-stats/expose-cluster-uuid branch from b47e1f2 to f34899e Compare July 19, 2018 22:30
@original-brownbear
Copy link
Member

@ycombinator this is failing integration tests

   >                     cluster_uuid: unexpected but found [YjAvIhsCQ9CbjWZb2qJw3Q]

I think you need to add a line - is_true for the cluster_uuid field to rest-api-spec/test/cluster.stats/10_basic.yml to make this pass.

@ycombinator
Copy link
Contributor Author

Thanks so much @original-brownbear. I kept looking at another unrelated failure in CI!

@ycombinator
Copy link
Contributor Author

ycombinator commented Jul 20, 2018

@pickypg I could use your advice on this PR. The goal of this PR is to include cluster_uuid in the Cluster Stats API response alongside the cluster_name field. That way Metricbeat won't have to make an additional API call just to fetch the cluster UUID.

The current CI failure is this:

FAILURE 0.12s J2 | ClusterStatsMonitoringDocTests.testToXContent <<< FAILURES!
   > Throwable #1: org.junit.ComparisonFailure: expected:<...},"cluster_stats":{"[]timestamp":145160640...> but was:<...},"cluster_stats":{"[cluster_uuid":"Z7R4gXE2RvyLDG0ROIP_8g","]timestamp":145160640...>
   >  at __randomizedtesting.SeedInfo.seed([84826F5AB62CCA24:629968E21F2084CF]:0)
   >  at org.elasticsearch.xpack.monitoring.collector.cluster.ClusterStatsMonitoringDocTests.testToXContent(ClusterStatsMonitoringDocTests.java:327)
   >  at java.lang.Thread.run(Thread.java:748)
Completed [17/50] on J2 in 0.19s, 15 tests, 1 failure <<< FAILURES!

I could simply "fix" it by including cluster_uuid inside the cluster_stats object in the cluster stats monitoring doc. But I don't think that's the right fix, especially since cluster_uuid is a top-level field in that monitoring doc already!

One hacky way to fix this would be to somehow remove the cluster_uuid field after this call:

But I'm not even sure if that's possible. And even if it is, it's pretty hacky :(

Another fix, probably the right one, would be to remove this line from my PR:

https://github.com/elastic/elasticsearch/pull/32206/files#diff-7016058c4ba8556b31beb10519607597R121

... and instead insert cluster_uuid into the response body the same way cluster_name is being inserted today, over here:

builder.field("cluster_name", response.getClusterName().value());

But that's a far-reaching change with tons of other classes being touched in the process.

Any ideas on how best to proceed here?

@pickypg
Copy link
Member

pickypg commented Jul 20, 2018

@ycombinator I faced a nearly identical issue when I made an equivalent change to the GET /_cluster/state endpoint: #30143. FWIW, X-Pack monitoring combines the response from _cluster/stats and _cluster/state into the cluster_stats object, so you may not even need this step, but I think it's appropriate for every cluster API to respond with the UUID.

In that PR, one thing that I did that will probably help you is I disabled the REST test for 6.x until I actually backported the change, then enabled it in a follow-up PR: #30264.

In my case, I did what you are currently doing and I think what you are currently doing is the right approach. I have always thought that it was weird that the cluster name is added by the REST handler.

Either way, you're going to have to fix a few tests that depend on the response from cluster stats, and I think that just is what it is.

@ycombinator
Copy link
Contributor Author

Thanks @pickypg. I looked at #30143 and took away two things from it for this PR:

  1. I should add a rest-api-spec test to assert that the cluster stats API response now contains the cluster_uuid field at the top level in the response JSON. I've tried to address that in bef4ab3.
  2. In cluster stats Monitoring docs, it looks like you ended up duplicating the cluster_uuid in the cluster_state object inside the doc as well as at the top-level of the doc. It looks like I'll have to live with the same thing in this PR, that is, we'll now have cluster_uuid show up in a third place in cluster stats Monitoring docs, in the cluster_stats object as well.

Do these seem right to you?

@pickypg
Copy link
Member

pickypg commented Jul 30, 2018

Sounds great to me. The duplicated cluster_uuid is unfortunate, but we won't index it and thus won't pay much of a penalty for it.

@ycombinator ycombinator force-pushed the rest/cluster-stats/expose-cluster-uuid branch 2 times, most recently from 0e8536a to 5e15f54 Compare July 30, 2018 22:58
@ycombinator ycombinator force-pushed the rest/cluster-stats/expose-cluster-uuid branch from 43c93ed to d454c97 Compare July 31, 2018 16:16
@ycombinator ycombinator requested a review from pickypg July 31, 2018 23:57
Copy link
Member

@pickypg pickypg left a comment

Choose a reason for hiding this comment

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

LGTM

@ycombinator ycombinator merged commit 0a83968 into elastic:master Aug 3, 2018
@ycombinator ycombinator deleted the rest/cluster-stats/expose-cluster-uuid branch August 3, 2018 00:14
dnhatn added a commit that referenced this pull request Aug 3, 2018
* master:
  HLRC: Move commercial clients from XPackClient (#32596)
  Add cluster UUID to Cluster Stats API response (#32206)
  Security: move User to protocol project (#32367)
  [TEST] Test for shard failures, add debug to testProfileMatchesRegular
  Minor fix for javadoc (applicable for java 11). (#32573)
  Painless: Move Some Lookup Logic to PainlessLookup (#32565)
  TEST: Avoid merges in testSeqNoAndCheckpoints
  [Rollup] Remove builders from HistoGroupConfig (#32533)
  Mutes failing SQL string function tests due to #32589
  fixed elements in array of produced terms (#32519)
  INGEST: Enable default pipelines (#32286)
  Remove cluster state initial customs (#32501)
  Mutes LicensingDocumentationIT due to #32580
  [ML] Remove multiple_bucket_spans (#32496)
  [ML] Rename JobProvider to JobResultsProvider (#32551)
  Correct minor typo in explain.asciidoc for HLRC
  Build: Add elastic maven to repos used by BuildPlugin (#32549)
  Clarify the error message when a pipeline agg is used in the 'order' parameter. (#32522)
  Revert "[test] turn on host io cache for opensuse (#32053)"
  Enable packaging tests on suse boxes
  [ML] Improve error when no available field exists for rule scope (#32550)
  [ML] Improve error for functions with limited rule condition support (#32548)
  Painless: Clean Up PainlessField (#32525)
  Add @AwaitsFix for #32554
  Remove broken @link in Javadoc
  Scripting: Conditionally use java time api in scripting (#31441)
  [ML] Fix thread leak when waiting for job flush (#32196) (#32541)
  Add AwaitsFix to failing test - see #32546
  Core: Minor size reduction for AbstractComponent (#32509)
  SQL: Added support for string manipulating functions with more than one parameter (#32356)
  [DOCS] Reloadable Secure Settings (#31713)
  Watcher: Reenable HttpSecretsIntegrationTests#testWebhookAction test (#32456)
  [Rollup] Remove builders from TermsGroupConfig (#32507)
  Use hostname instead of IP with SPNEGO test (#32514)
  Switch x-pack rolling restart to new style Requests (#32339)
  NETWORKING: Fix Netty Leaks by upgrading to 4.1.28 (#32511)
  [DOCS] Small fixes in rule configuration page (#32516)
  Painless: Clean up PainlessMethod (#32476)
  Build: Remove shadowing from benchmarks (#32475)
  Docs: Add all JDKs to CONTRIBUTING.md
  Add licensing enforcement for FIPS mode (#32437)
  SQL: Add test for handling of partial results (#32474)
  Mute testFilterCacheStats
  [ML][DOCS] Fix typo applied_to => applies_to
  Scripting: Fix painless compiler loader to know about context classes (#32385)
ycombinator added a commit that referenced this pull request Aug 3, 2018
* Make cluster stats response contain cluster UUID

* Updating constructor usage in Monitoring tests

* Adding cluster_uuid field to Cluster Stats API reference doc

* Adding rest api spec test for expecting cluster_uuid in cluster stats response

* Adding missing newline

* Indenting do section properly

* Missed a spot!

* Fixing the test cluster ID
@ycombinator
Copy link
Contributor Author

Backported to:

@ycombinator ycombinator added v6.5.0 and removed v6.4.0 labels Aug 3, 2018
dnhatn added a commit that referenced this pull request Aug 6, 2018
* 6.x:
  [Kerberos] Use canonical host name (#32588)
  Cross-cluster search: preserve cluster alias in shard failures (#32608)
  [TEST] Allow to run in FIPS JVM (#32607)
  Handle AlreadyClosedException when bumping primary term
  [Test] Add ckb to the list of unsupported languages (#32611)
  SCRIPTING: Move Aggregation Scripts to their own context (#32068) (#32629)
  [TEST] Enhance failure message when bulk updates have failures
  [ML] Add ML result classes to protocol library (#32587)
  Suppress LicensingDocumentationIT.testPutLicense in release builds (#32613)
  [Rollup] Improve ID scheme for rollup documents (#32558)
  Mutes failing SQL string function tests due to #32589
  Suppress Wildfly test in FIPS JVMs (#32543)
  Add cluster UUID to Cluster Stats API response (#32206)
  [ML] Add some ML config classes to protocol library (#32502)
  [TEST]Split transport verification mode none tests (#32488)
  [Rollup] Remove builders from DateHistogramGroupConfig (#32555)
  [ML] Add Detector config classes to protocol library (#32495)
  [Rollup] Remove builders from MetricConfig (#32536)
  Fix race between replica reset and primary promotion (#32442)
  HLRC: Move commercial clients from XPackClient (#32596)
  Security: move User to protocol project (#32367)
  Minor fix for javadoc (applicable for java 11). (#32573)
  Painless: Move Some Lookup Logic to PainlessLookup (#32565)
  Core: Minor size reduction for AbstractComponent (#32509)
  INGEST: Enable default pipelines (#32286) (#32591)
  TEST: Avoid merges in testSeqNoAndCheckpoints
  [Rollup] Remove builders from HistoGroupConfig (#32533)
  fixed elements in array of produced terms (#32519)
  Mutes ReindexFailureTests.searchFailure dues to #28053
  Mutes LicensingDocumentationIT due to #32580
  Remove the SATA controller from OpenSUSE box
  [ML] Rename JobProvider to JobResultsProvider (#32551)
ycombinator added a commit to elastic/beats that referenced this pull request Oct 14, 2018
Starting from 6.5.0, Elasticsearch [will return](elastic/elasticsearch#32206) the `cluster_uuid` as part of the `GET _cluster/stats` API response. However, the Elasticsearch metricbeat module has been in existence since 6.3.0 so it must fetch the cluster UUID from the `GET /` Elasticsearch API.

This PR makes it so the `GET /` API is always called and the cluster UUID from it is used. This is obviously not ideal in terms of API calls, but it's the simplest fix (for now, until we can figure out a nicer way to deal with version differences).
ycombinator added a commit to elastic/beats that referenced this pull request Oct 16, 2018
Starting from 6.5.0, Elasticsearch [will return](elastic/elasticsearch#32206) the `cluster_uuid` as part of the `GET _cluster/stats` API response. However, the Elasticsearch metricbeat module has been in existence since 6.3.0 so it must fetch the cluster UUID from the `GET /` Elasticsearch API.

This PR makes it so the `GET /` API is always called and the cluster UUID from it is used. This is obviously not ideal in terms of API calls, but it's the simplest fix (for now, until we can figure out a nicer way to deal with version differences).

(cherry picked from commit ccfc8d7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants