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 a new REST API endpoint 'GET _cat/cluster_manager' as the replacement of 'GET _cat/master' #2404

Merged
merged 14 commits into from
Mar 18, 2022

Conversation

tlfeng
Copy link
Collaborator

@tlfeng tlfeng commented Mar 8, 2022

Description

Add a new REST API endpoint GET _cat/cluster_manager, as alternative of the existing GET _cat/master

  • Add a new path /_cat/cluster_manager for the REST request handler RestMasterAction
  • Deprecate the existing path /_cat/master
  • Change the name of the RestMasterAction handler from cat_master_action to cat_cluster_manager_action
  • Change the response of GET _cat to only show the new path /_cat/cluster_manager
  • Rename the JSON rest-api-spec file cat.master.json to cat.cluster_manager.json and update the paths.
  • Add YAML REST test. By default, it will run test for both endpoints GET _cat/cluster_manager and GET _cat/master

Current API response of "GET _cat"

=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
...

Proposed API response of "GET _cat"

=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/cluster_manager
...

Testing
running YAML REST test

./gradlew ':rest-api-spec:yamlRestTest' \
  --tests "org.opensearch.test.rest.ClientYamlTestSuiteIT" \
  -Dtests.method="test {p0=cat.cluster_manager/10_basic/*}"

Issues Resolved

Part of #1549

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@opensearch-ci-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@tlfeng tlfeng changed the title Add a new REST API GET _cat/cluster_manager as the replacement of GET _cat/master Add a new REST API 'GET _cat/cluster_manager' as the replacement of 'GET _cat/master' Mar 8, 2022
Signed-off-by: Tianli Feng <[email protected]>
@tlfeng tlfeng added v2.0.0 Version 2.0.0 enhancement Enhancement or improvement to existing feature or request labels Mar 8, 2022
@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure b23c566
Log 3161

Reports 3161

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success a33d574
Log 3162

Reports 3162

public List<Route> routes() {
return singletonList(new Route(GET, "/_cat/master"));
public List<ReplacedRoute> replacedRoutes() {
return singletonList(new ReplacedRoute(GET, "/_cat/cluster_manager", "/_cat/master"));
Copy link
Member

Choose a reason for hiding this comment

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

Is the plan to support this old API forever?
Or is there a EOL defined after couple of major version releases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The "_cat/master" API will be removed in a future major version. Although the current plan is to remove in version 3.0, it depends on the users' acceptance.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for your idea, I added a comment to indicate the deprecated API will be removed in the future.

Signed-off-by: Tianli Feng <[email protected]>
@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure bb79c85
Log 3188

Reports 3188

@tlfeng tlfeng marked this pull request as ready for review March 9, 2022 01:09
@tlfeng tlfeng requested a review from a team as a code owner March 9, 2022 01:09
@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success c6fe237
Log 3194

Reports 3194

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 5a751e6
Log 3260

Reports 3260

"type":"boolean",
"description":"Return local information, do not retrieve the state from master node (default: false)"
},
"master_timeout":{
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this parameter name be changed to be inclusive?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmmm, good question. I didn't think of it at that time. Since the deprecation of the parameter "master_timeout" will be handled in separate PR, maybe it is fair to keep it for now. 🙂

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should introduce a new API with old parameter names. If a client moves to the _cat/cluster_manager API with this in place, they will continue to use the master_timeout parameter name. Then, when we deprecate the parameter, they will need to make another change to prevent breakage.

I would rather we use inclusive naming from the get-go in net-new APIs and code paths.

Copy link
Collaborator Author

@tlfeng tlfeng Mar 16, 2022

Choose a reason for hiding this comment

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

I got it. 😄 Make sense not to introduce a new API with out-dated parameter name.
I realized that a new json file of rest-api-spec may not necessary, because the main code change I made is to give an alternative API path to _cat/master, but not adding a new API.
I will modify the code not to create a new json file of rest-api-spec, and find out a better way to deal with the API path change.
If that works, I will also modify the PR title and description, because the code change is not actually adding a new REST API.

Copy link
Collaborator Author

@tlfeng tlfeng Mar 16, 2022

Choose a reason for hiding this comment

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

I modified the code to:

  • Rename the current JSON rest-api-spec file cat.master.json to cat.cluster_manager.json
  • Add path _cat/cluster_manager and _cat/master path as the deprecated path
  • Test both old and new path in one YAML file to test the both REST API path

If I should deprecate the request parameter master_timeout, I will make the code change after the PR #2435 merged, because that PR will add the method to validate whether the value of master_timeout and cluster_manager_timeout is equal, and also set a sample for all the master_timeout deprecation.

Copy link
Member

Choose a reason for hiding this comment

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

👍 please add an issue so we don't miss out on it

Copy link
Collaborator Author

@tlfeng tlfeng Mar 17, 2022

Choose a reason for hiding this comment

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

I created the issue #2511 to deprecate the old parameter name, and also attached it to #1549 . Thanks

@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure be44736
Log 3435

Reports 3435

@tlfeng
Copy link
Collaborator Author

tlfeng commented Mar 16, 2022

In log 3435:

REPRODUCE WITH: ./gradlew ':server:internalClusterTest' --tests "org.opensearch.search.simple.SimpleSearchIT.testSimpleIndexSortEarlyTerminate" -Dtests.seed=FA0A526C8C721A5F -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=el -Dtests.timezone=Pacific/Pitcairn -Druntime.java=17

org.opensearch.search.simple.SimpleSearchIT > testSimpleIndexSortEarlyTerminate FAILED
    java.lang.AssertionError: at least one shard failed CheckIndex
        at __randomizedtesting.SeedInfo.seed([FA0A526C8C721A5F:32A4955E75677464]:0)
        at org.opensearch.test.OpenSearchTestCase.ensureCheckIndexPassed(OpenSearchTestCase.java:663)
        at org.opensearch.test.OpenSearchTestCase.after(OpenSearchTestCase.java:428)
  1>     test: index sort..........FAILED
  1>     WARNING: exorciseIndex() would remove reference to this segment; full exception:
  1> java.lang.IllegalArgumentException: Field rank is indexed with 4 bytes per dimension, but org.apache.lucene.search.SortedNumericSortField$3@13ca0f8e expected 8
  1> 	at org.apache.lucene.search.comparators.NumericComparator$NumericLeafComparator.<init>(NumericComparator.java:116)

This is caused by Lucene 9 upgrade, and is tracked in issue #2063 (comment)

@tlfeng tlfeng changed the title Add a new REST API 'GET _cat/cluster_manager' as the replacement of 'GET _cat/master' Add a new REST API endpoint 'GET _cat/cluster_manager' as the replacement of 'GET _cat/master' Mar 16, 2022
@tlfeng tlfeng changed the title Add a new REST API endpoint 'GET _cat/cluster_manager' as the replacement of 'GET _cat/master' Add a REST API endpoint 'GET _cat/cluster_manager' as the replacement of 'GET _cat/master' Mar 16, 2022
@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure 466b083
Log 3461

Reports 3461

@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure a17afa7
Log 3462

Reports 3462

@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure c46e535
Log 3463

Reports 3463

@tlfeng tlfeng changed the title Add a REST API endpoint 'GET _cat/cluster_manager' as the replacement of 'GET _cat/master' Add a new REST API endpoint 'GET _cat/cluster_manager' as the replacement of 'GET _cat/master' Mar 17, 2022
@@ -50,18 +50,19 @@
public class RestMasterAction extends AbstractCatAction {
Copy link
Member

Choose a reason for hiding this comment

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

Such class name won't be considered as inclusive?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @owaiskazi19, thanks for your review! The RestMasterAction class is published to maven as Java API (https://opensearch.org/javadocs/1.2.4/OpenSearch/server/build/docs/javadoc/org/opensearch/rest/action/cat/RestMasterAction.html). I didn't plan to rename them in 2.0 version, in case giving clients or plugins which use such classes too much work in upgrading to support 2.0 version. 😄
There is a discussion in the PR #2453, you could take a look at. Renaming the Java APIs is tracked in issue #1684

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. Thanks for clearing it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are welcome! 😁

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 0b7b236
Log 3467

Reports 3467

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 300f18b
Log 3471

Reports 3471

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or improvement to existing feature or request v2.0.0 Version 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants