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

Replace 'master' with 'cluster_manager' in 'GET Cat Nodes' API #2441

Merged
merged 6 commits into from
Mar 18, 2022

Conversation

tlfeng
Copy link
Collaborator

@tlfeng tlfeng commented Mar 11, 2022

Description

  • Replace 'master' with 'cluster_manager' in the table header of GET Cat Nodes API, to promote inclusive language.
  • Add cm as the alias for the table header cluster_manager
  • Add master as the alias for the table header cluster_manager, for keeping compatibility when using GET _cat/nodes?v&h=master to show the specific column only.
  • Add YAML rest test

Current response of 'GET Cat Nodes' API:

http://localhost:9200/_cat/nodes?v

ip        heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
127.0.0.1           10         100  22    4.28                  dimr      *      runTask-0

Proposed response of 'GET Cat Health' API:

http://localhost:9200/_cat/nodes?v

ip        heap.percent ram.percent cpu load_1m load_5m load_15m node.role cluster_manager name
127.0.0.1           10         100  22    4.28                  dimr      *               runTask-0

Explanation on the API response compatibility
Because "cat API is a human-readable interface" (https://opensearch.org/docs/latest/opensearch/rest-api/cat/index/), and are not intended for use by software program, the old name "master" is not retained.

To keep the same API response with nodes in 1.x version, users can specify "header" in the request parameter, then the API response will remain the same for nodes in both 1.x and 2.x versions.
For example:

GET _cat/nodes?v&h=version&master

version master
2.0.0   *

Testing

./gradlew ':rest-api-spec:yamlRestTest' \
--tests "org.opensearch.test.rest.ClientYamlTestSuiteIT" \
-Dtests.method="test {p0=cat.nodes/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.

Signed-off-by: Tianli Feng <ftianli@amazon.com>
@opensearch-ci-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@tlfeng tlfeng added enhancement Enhancement or improvement to existing feature or request v2.0.0 Version 2.0.0 documentation pending Tracks issues which have PRs merged but documentation changes pending >breaking Identifies a breaking change. labels Mar 11, 2022
@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure 9cadbce
Log 3258

Reports 3258

@tlfeng tlfeng marked this pull request as draft March 11, 2022 17:38
@tlfeng tlfeng marked this pull request as draft March 11, 2022 17:38
@tlfeng
Copy link
Collaborator Author

tlfeng commented Mar 11, 2022

In log 3258:
Because the table header of "_cat/nodes" will be changed in this PR, a method org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase.readVersionsFromCatNodes(OpenSearchClientYamlSuiteTestCase.java:337) used for Yaml REST testing can not read the proper value for both old and new versions of OpenSearch.

> Task :qa:mixed-cluster:v1.4.0#mixedClusterTest

REPRODUCE WITH: ./gradlew ':qa:mixed-cluster:v1.4.0#mixedClusterTest' --tests "org.opensearch.backwards.MixedClusterClientYamlTestSuiteIT.test {p0=search/110_field_collapsing/field collapsing and rescore}" -Dtests.seed=2308CADB0B4AEF70 -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=no -Dtests.timezone=Europe/San_Marino -Druntime.java=17

org.opensearch.backwards.MixedClusterClientYamlTestSuiteIT > test {p0=search/110_field_collapsing/field collapsing and rescore} FAILED
    java.lang.AssertionError: invalid line: 2.0.0 length: 1
        at __randomizedtesting.SeedInfo.seed([2308CADB0B4AEF70:AB5CF501A5B68288]:0)
        at org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase.readVersionsFromCatNodes(OpenSearchClientYamlSuiteTestCase.java:337)
        at org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase.initAndResetContext(OpenSearchClientYamlSuiteTestCase.java:145)
...

Tianli Feng added 3 commits March 12, 2022 22:06
Signed-off-by: Tianli Feng <ftianli@amazon.com>
…ility

Signed-off-by: Tianli Feng <ftianli@amazon.com>
Signed-off-by: Tianli Feng <ftianli@amazon.com>
@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure 45e04ce
Log 3305

Reports 3305

@tlfeng
Copy link
Collaborator Author

tlfeng commented Mar 13, 2022

In log 3305:

> Task :qa:mixed-cluster:v1.4.0#mixedClusterTest

REPRODUCE WITH: ./gradlew ':qa:mixed-cluster:v1.4.0#mixedClusterTest' --tests "org.opensearch.backwards.MixedClusterClientYamlTestSuiteIT" -Dtests.method="test {p0=cat.nodes/10_basic/Test cat nodes output - before 2.0.0}" -Dtests.seed=C7989F860D60857C -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=ar-LY -Dtests.timezone=Australia/Broken_Hill -Druntime.java=17

org.opensearch.backwards.MixedClusterClientYamlTestSuiteIT > test {p0=cat.nodes/10_basic/Test cat nodes output - before 2.0.0} FAILED
    java.lang.AssertionError: Failure at [cat.nodes/10_basic:11]: field [$body] was expected to match the provided regex but didn't
    Expected: ^  ip                     \s+  heap\.percent   \s+  ram\.percent \s+ cpu      \s+ load_1m            \s+ load_5m            \s+ load_15m           \s+ node\.role              \s+  master   \s+   name  \n
       ((\d{1,3}\.){3}\d{1,3}  \s+  \d+             \s+  \d*          \s+ (-)?\d* \s+  ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+  [-*x]    \s+   (\S+\s?)+     \n)+  $
         but: was "ip        heap.percent ram.percent cpu load_1m load_5m load_15m node.role cluster_manager name\n127.0.0.1           31          46  16   36.50   56.22    48.62 dimr      *               v1.4.0-2\n127.0.0.1           21          46  16   36.50   56.22    48.62 dimr      -               v1.4.0-1\n127.0.0.1           32          46  16   36.50   56.22    48.62 dimr      -               v1.4.0-0\n127.0.0.1           19          46  16   36.50   56.22    48.62 dimr      -               v1.4.0-3\n"
        at __randomizedtesting.SeedInfo.seed([C7989F860D60857C:4FCCA05CA39CE884]:0)
        at org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase.executeSection(OpenSearchClientYamlSuiteTestCase.java:442)
        at org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase.test(OpenSearchClientYamlSuiteTestCase.java:415)

@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure 7f0ad8f
Log 3309

Reports 3309

Signed-off-by: Tianli Feng <ftianli@amazon.com>
@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure cf385f5
Log 3313

Reports 3313

Signed-off-by: Tianli Feng <ftianli@amazon.com>
@tlfeng tlfeng force-pushed the replace-master-in-cat-nodes branch from efa7a75 to fb7ec1a Compare March 14, 2022 04:26
@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure efa7a75372870d03457cb96bcf18bd5402167558
Log 3328

Reports 3328

@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure fb7ec1a
Log 3329

Reports 3329

@tlfeng
Copy link
Collaborator Author

tlfeng commented Mar 14, 2022

In log 3328:

REPRODUCE WITH: ./gradlew ':qa:mixed-cluster:v1.2.5#mixedClusterTest' --tests "org.opensearch.backwards.MixedClusterClientYamlTestSuiteIT" -Dtests.method="test {p0=indices.get_field_mapping/20_missing_field/Return empty object if field doesn't exist, but index does}" -Dtests.seed=D61FE7F6821A0034 -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=en-PH -Dtests.timezone=Europe/Simferopol -Druntime.java=17

org.opensearch.backwards.MixedClusterClientYamlTestSuiteIT > test {p0=indices.get_field_mapping/20_missing_field/Return empty object if field doesn't exist, but index does} FAILED
    java.lang.AssertionError: Failure at [indices.get_field_mapping/20_missing_field:20]: field [test_index.mappings] is null
        at __randomizedtesting.SeedInfo.seed([D61FE7F6821A0034:5E4BD82C2CE66DCC]:0)
        at org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase.executeSection(OpenSearchClientYamlSuiteTestCase.java:442)
        at org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase.test(OpenSearchClientYamlSuiteTestCase.java:415)

It's reported in #2440

In log 3329:

> Task :server:internalClusterTest

REPRODUCE WITH: ./gradlew ':server:internalClusterTest' --tests "org.opensearch.discovery.StableMasterDisruptionIT.testStaleMasterNotHijackingMajority" -Dtests.seed=1656830A3FB8F3E7 -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=en-IN -Dtests.timezone=America/Puerto_Rico -Druntime.java=17

org.opensearch.discovery.StableMasterDisruptionIT > testStaleMasterNotHijackingMajority FAILED
    java.lang.AssertionError: node_t2: [Tuple [v1=node_t1, v2=null]]
        at __randomizedtesting.SeedInfo.seed([1656830A3FB8F3E7:4950CE051E632CEB]:0)
        at org.junit.Assert.fail(Assert.java:89)
        at org.junit.Assert.assertTrue(Assert.java:42)
        at org.opensearch.discovery.StableMasterDisruptionIT.lambda$testStaleMasterNotHijackingMajority$5(StableMasterDisruptionIT.java:253)
        at org.opensearch.test.OpenSearchTestCase.assertBusy(OpenSearchTestCase.java:1060)
        at org.opensearch.test.OpenSearchTestCase.assertBusy(OpenSearchTestCase.java:1033)
        at org.opensearch.discovery.StableMasterDisruptionIT.testStaleMasterNotHijackingMajority(StableMasterDisruptionIT.java:250)

It's reported in issue #1565. Maybe caused by too many gradle check runs in CI.

@tlfeng tlfeng marked this pull request as ready for review March 14, 2022 05:22
@tlfeng
Copy link
Collaborator Author

tlfeng commented Mar 15, 2022

start gradle check

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success fb7ec1a
Log 3387

Reports 3387

@dblock dblock requested a review from andrross March 15, 2022 15:48
@andrross
Copy link
Member

Because "cat API is a human-readable interface" (https://opensearch.org/docs/latest/opensearch/rest-api/cat/index/), and are not intended for use by software program, the old name "master" is not retained.

Just because the documentation describes this as a human readable does not mean that users don't write software that parses the result :) Given that the response is unstructured text, I think this is probably the right way to go, but I suspect someone somewhere will be broken by this change.

@tlfeng
Copy link
Collaborator Author

tlfeng commented Mar 15, 2022

Just because the documentation describes this as a human readable does not mean that users don't write software that parses the result :) Given that the response is unstructured text, I think this is probably the right way to go, but I suspect someone somewhere will be broken by this change.

😁 Hi @andrross, you are so correct. I can never realized that the test framework of OpenSearch itself is parsing the result of the CAT Nodes API, until running the BWC test. https://github.com/opensearch-project/OpenSearch/blob/1.2.4/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java#L326 😂
It motivated me to add master as the alias for getting the output of cluster_manager column, when using GET _cat/nodes?v&h=master (in the commit 45e04ce).

For example:
The response of GET _cat/nodes?v&h=version&master after this PR will be the same as the current:
(for a single node cluster)

version master
2.0.0   *

I will add this to the PR description as well.
I think with necessary documentation about the "alias", users can find this proper way of specifying headers in the request parameter to keep their code of parsing CAT Nodes API for both 1.x and 2.x versions.

@tlfeng tlfeng merged commit 641350b into opensearch-project:main Mar 18, 2022
@tlfeng tlfeng deleted the replace-master-in-cat-nodes branch March 18, 2022 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking Identifies a breaking change. documentation pending Tracks issues which have PRs merged but documentation changes pending 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.

4 participants