-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 request parameter 'cluster_manager_timeout' as the alternative for 'master_timeout', and deprecate 'master_timeout' - in CAT Nodes API #2435
Conversation
Can one of the admins verify this patch? |
❌ Gradle Check failure b842e508de00a4009e250409fa0bcaabffbba79a |
b842e50
to
e16ce49
Compare
e16ce49
to
009ded2
Compare
❌ Gradle Check failure e16ce49116bb24ba1f94364a576dde27367a114b |
❌ Gradle Check failure 009ded2aed9f96d8a157cbe74bbf6edabf1407bb |
Signed-off-by: Tianli Feng <[email protected]>
009ded2
to
24cf061
Compare
Signed-off-by: Tianli Feng <[email protected]>
Signed-off-by: Tianli Feng <[email protected]>
Signed-off-by: Tianli Feng <[email protected]>
Signed-off-by: Tianli Feng <[email protected]>
…-timeout Signed-off-by: Tianli Feng <[email protected]>
Signed-off-by: Tianli Feng <[email protected]>
db4ba0f
to
8e0e074
Compare
❌ Gradle Check failure db4ba0f9afafec513be70e53d6c14a754212f7c5 |
Signed-off-by: Tianli Feng <[email protected]>
in log 3377
It's reported in issue #2440 |
Signed-off-by: Tianli Feng <[email protected]>
Signed-off-by: Tianli Feng <[email protected]>
@Deprecated | ||
public void validateParamValuesAreEqual(String... keys) { | ||
// Filter the non-empty values of the parameters with the key, and get the distinct values. | ||
Set<String> set = new HashSet<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor improvement - you don't need a Set
to check this. You can just track the last seen value and ensure that every subsequent value matches it. This would also force a break out of the loop as soon as there is a mismatch rather than attempting to parse all values of the input keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kartg Thank you so much for your careful review and your valuable opinion!
I will make the changes according to your suggestion!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in the commit 02e68b5. I learnt the nice way to check if all the values are the same, thank you! 👍
if (request.hasParam(deprecatedTimeoutParam)) { | ||
deprecationLogger.deprecate("cat_nodes_master_timeout_parameter", MASTER_TIMEOUT_DEPRECATED_MESSAGE); | ||
request.validateParamValuesAreEqual(deprecatedTimeoutParam, clusterManagerTimeoutParam); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two nitpicks here:
- Setting the masterNodeTimeout should occur within the if-condition
- The validation could occur before setting the value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion! Now the procedure is more reasonable 😄. I modified the code in the commit 399f2d9
+ valueForKey2, | ||
Strings.isNullOrEmpty(valueForKey1) || Strings.isNullOrEmpty(valueForKey2) || valueForKey1.equals(valueForKey2) | ||
); | ||
} catch (OpenSearchParseException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please split this into two tests?
We should deterministically test both cases - when the two are equal and for inequality - for all test runs rather than testing either code path through a random.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for telling me the opinion to design test case! Updated along wit the above comment 02e68b5
Signed-off-by: Tianli Feng <[email protected]>
Signed-off-by: Tianli Feng <[email protected]>
Signed-off-by: Tianli Feng <[email protected]>
Signed-off-by: Tianli Feng <[email protected]>
Signed-off-by: Tianli Feng <[email protected]>
…-timeout Signed-off-by: Tianli Feng <[email protected]>
Signed-off-by: Tianli Feng <[email protected]>
…emoval - in CAT Nodes API (#2670) (#2695) The request parameter `master_timeout` for CAT Nodes API is deprecated and alternative parameter `cluster_manager_timeout` is added in commit a87c9d4 / PR #2435. This PR refactors a previous code commit, and it's suggested by #2658 (comment). Change: This PR put the temporary code related to the 'master_timeout' deprecation in centralized places, so that it will be easier to remove when removing the deprecated parameter `master_timeout` in the future. - Move the method `parseDeprecatedMasterTimeoutParameter()` into abstract base class `BaseRestHandler`, so that every REST API handler can call it. - Put the unit tests related to the 'master_timeout' deprecation in one class. Another notable change: Prohibit using two paramters `master_timeout` and `cluster_manager_timeout` together. Reason: There are other 60 REST APIs have got request parameter `master_timeout`, and the parameter pending to be deprecated. (See issue #2511 for the full list). - Adding new codes (creating deprecation warning, validating the parameter value and unit tests) in every class for the 60 APIs will cause large duplication. - Removing the duplicate deprecated codes in the future is also a trouble. Signed-off-by: Tianli Feng <[email protected]>
…emoval - in CAT Nodes API (#2670) (#2696) The request parameter `master_timeout` for CAT Nodes API is deprecated and alternative parameter `cluster_manager_timeout` is added in commit a87c9d4 / PR #2435. This PR refactors a previous code commit, and it's suggested by #2658 (comment). Change: This PR put the temporary code related to the 'master_timeout' deprecation in centralized places, so that it will be easier to remove when removing the deprecated parameter `master_timeout` in the future. - Move the method `parseDeprecatedMasterTimeoutParameter()` into abstract base class `BaseRestHandler`, so that every REST API handler can call it. - Put the unit tests related to the 'master_timeout' deprecation in one class. Another notable change: Prohibit using two paramters `master_timeout` and `cluster_manager_timeout` together. Reason: There are other 60 REST APIs have got request parameter `master_timeout`, and the parameter pending to be deprecated. (See issue #2511 for the full list). - Adding new codes (creating deprecation warning, validating the parameter value and unit tests) in every class for the 60 APIs will cause large duplication. - Removing the duplicate deprecated codes in the future is also a trouble. Signed-off-by: Tianli Feng <[email protected]>
…r 'master_timeout', and deprecate 'master_timeout' - in CAT APIs (#2557) Apply the change of CAT Nodes API in PR #2435 to other applicable CAT APIs. - Deprecate the request parameter `master_timeout` that used in many CAT APIs. - Add alternative new request parameter `cluster_manager_timeout`. - Add unit tests. Signed-off-by: Tianli Feng <[email protected]>
…r 'master_timeout', and deprecate 'master_timeout' - in CAT APIs (#2557) Apply the change of CAT Nodes API in PR #2435 to other applicable CAT APIs. - Deprecate the request parameter `master_timeout` that used in many CAT APIs. - Add alternative new request parameter `cluster_manager_timeout`. - Add unit tests. Signed-off-by: Tianli Feng <[email protected]> (cherry picked from commit 78465b4)
…r 'master_timeout', and deprecate 'master_timeout' - in CAT APIs (#2557) Apply the change of CAT Nodes API in PR #2435 to other applicable CAT APIs. - Deprecate the request parameter `master_timeout` that used in many CAT APIs. - Add alternative new request parameter `cluster_manager_timeout`. - Add unit tests. Signed-off-by: Tianli Feng <[email protected]> (cherry picked from commit 78465b4)
… alternative for 'master_timeout', and deprecate 'master_timeout' - in CAT APIs (#2716) Apply the change of CAT Nodes API in PR #2435 to other applicable CAT APIs. - Deprecate the request parameter `master_timeout` that used in many CAT APIs. - Add alternative new request parameter `cluster_manager_timeout`. - Add unit tests. Signed-off-by: Tianli Feng <[email protected]> (cherry picked from commit 78465b4)
… alternative for 'master_timeout', and deprecate 'master_timeout' - in CAT APIs (#2717) Apply the change of CAT Nodes API in PR #2435 to other applicable CAT APIs. - Deprecate the request parameter `master_timeout` that used in many CAT APIs. - Add alternative new request parameter `cluster_manager_timeout`. - Add unit tests. Signed-off-by: Tianli Feng <[email protected]> (cherry picked from commit 78465b4)
Description
master_timeout
is being used in multiple APIs, such as cat allocation and cat nodes APIs.The PR take CAT Nodes API as a sample.
cluster_manager_timeout
, as the alternative for the existingmaster_timeout
, in CAT Nodes APIThrow an exception when bothmaster_timeout
andcluster_manager_timeout
are assigned but with different values, such asGET _cat/nodes?v&master_timeout=1s&cluster_manager_timeout=2s
. This is addressed by the temporary methodvalidateParamValuesAreEqual()
added inRestRequest
class.(The above behavior is changed by commit e1ee222 / PR Centralize codes related to 'master_timeout' deprecation for eaiser removal - in CAT Nodes API #2670)
Throw an exception when both
master_timeout
andcluster_manager_timeout
are assigned, no matter the assigned value are same or not, such asGET _cat/nodes?v&master_timeout=1s&cluster_manager_timeout=1s
.master_timeout
master_timeout
of inrest api spec
Deprecation notice:
With the built-in deprecation logger of OpenSearch (code), the following message will be recorded in the log files:
runTask_deprecation.log
runTask_deprecation.json
Testing:
When the values of old and new parameters are not the same:
Issues Resolved
Part of #1549
Check List
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.