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

Fix the bug that masterOperation(with task param) is bypassed #4103

Merged
merged 3 commits into from
Aug 3, 2022

Conversation

tlfeng
Copy link
Collaborator

@tlfeng tlfeng commented Aug 3, 2022

Description

The method protected void masterOperation(Task task, Request request, ClusterState state, ActionListener<Response> listener) was not properly deprecated by the commit 2a1b239 / PR #403.

There is a problem that it doesn't make any difference to whether overriding the method void masterOperation(Task task, Request request, ClusterState state, ActionListener<Response> listener) or not.
The reason is the only usage for the method changed to call another method clusterManagerOperation(task, request, clusterState, l), which is the default implementation for the method masterOperation(with task param). There is no other usage for the method masterOperation() so it's bypassed.

In the PR:
I restored the usage of the method masterOperation(with task param)

Issues Resolved

Resolve #4062

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>
@tlfeng tlfeng added bug Something isn't working backwards-compatibility backport 2.x Backport to 2.x branch v2.2.0 backport 2.2 Backport to 2.2 branch v3.0.0 Issues and PRs related to version 3.0.0 labels Aug 3, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2022

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

codecov-commenter commented Aug 3, 2022

Codecov Report

Merging #4103 (d4ec950) into main (66c24ff) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##               main    #4103   +/-   ##
=========================================
  Coverage     70.56%   70.57%           
- Complexity    56938    56994   +56     
=========================================
  Files          4588     4588           
  Lines        274132   274132           
  Branches      40178    40178           
=========================================
+ Hits         193454   193477   +23     
+ Misses        64452    64431   -21     
+ Partials      16226    16224    -2     
Impacted Files Coverage Δ
...lustermanager/info/TransportClusterInfoAction.java 61.53% <ø> (ø)
...src/main/java/org/opensearch/test/TestCluster.java 60.00% <ø> (ø)
...stermanager/TransportClusterManagerNodeAction.java 83.15% <100.00%> (+3.15%) ⬆️
...pensearch/client/cluster/RemoteConnectionInfo.java 0.00% <0.00%> (-73.18%) ⬇️
...a/org/opensearch/client/cluster/SniffModeInfo.java 0.00% <0.00%> (-58.83%) ⬇️
...a/org/opensearch/client/cluster/ProxyModeInfo.java 0.00% <0.00%> (-55.00%) ⬇️
.../java/org/opensearch/node/NodeClosedException.java 50.00% <0.00%> (-50.00%) ⬇️
...a/org/opensearch/tasks/TaskCancelledException.java 50.00% <0.00%> (-50.00%) ⬇️
.../index/shard/IndexShardNotRecoveringException.java 0.00% <0.00%> (-50.00%) ⬇️
...nsearch/rest/action/cat/RestCatRecoveryAction.java 43.61% <0.00%> (-42.56%) ⬇️
... and 463 more

Help us with your feedback. Take ten seconds to tell us how you rate us.

@tlfeng tlfeng marked this pull request as ready for review August 3, 2022 16:20
@tlfeng tlfeng requested review from a team and reta as code owners August 3, 2022 16:20
…bstract

Signed-off-by: Tianli Feng <ftianli@amazon.com>
Copy link
Member

@dreamer-89 dreamer-89 left a comment

Choose a reason for hiding this comment

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

Thanks @tlfeng for the fix.

@tlfeng
Copy link
Collaborator Author

tlfeng commented Aug 3, 2022

@dreamer-89 @reta Thanks a lot for your review!

@@ -218,7 +222,7 @@ protected void doStart(ClusterState clusterState) {
}
});
threadPool.executor(executor)
.execute(ActionRunnable.wrap(delegate, l -> clusterManagerOperation(task, request, clusterState, l)));
.execute(ActionRunnable.wrap(delegate, l -> masterOperation(task, request, clusterState, l)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

May be we could keep the clusterManagerOperation but change its delegation model:

    protected void clusterManagerOperation(Task task, Request request, ClusterState state, ActionListener<Response> listener)
        throws Exception {
        masterOperation(task, request, state, listener);
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for the suggestion! It make sense, in this way, the benefit is there will be no references of the master name methods, but the disadvantage is there will be more work in changing the method definitions when removing the deprecated ones.
I will have a try to change in this way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed in the commit d4ec950, thanks for your brilliant idea! 😄

@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2022

Gradle Check (Jenkins) Run Completed with:

…o call masterOperation(task...)

Signed-off-by: Tianli Feng <ftianli@amazon.com>
@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2022

Gradle Check (Jenkins) Run Completed with:

@tlfeng tlfeng merged commit 3ab0d1f into opensearch-project:main Aug 3, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 3, 2022
The method `protected void masterOperation(Task task, Request request, ClusterState state, ActionListener<Response> listener)` was not properly deprecated by the commit 2a1b239 / PR #403.

There is a problem that it doesn't make any difference to whether overriding the method `void masterOperation(Task task, Request request, ClusterState state, ActionListener<Response> listener)` or not.
The reason is the only usage for the method changed to call another method `clusterManagerOperation(task, request, clusterState, l)`, which is the default implementation for the method `masterOperation(with task param)`. There is no other usage for the method `masterOperation()` so it's bypassed.

In the commit:
- Change delegation model for method `clusterManagerOperation(with task param)` to call `masterOperation(with task param)`, according to the comment below #4103 (comment)
- Add a test to validate the backwards compatibility, which copied and modified from an existing test.

Signed-off-by: Tianli Feng <ftianli@amazon.com>
(cherry picked from commit 3ab0d1f)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 3, 2022
The method `protected void masterOperation(Task task, Request request, ClusterState state, ActionListener<Response> listener)` was not properly deprecated by the commit 2a1b239 / PR #403.

There is a problem that it doesn't make any difference to whether overriding the method `void masterOperation(Task task, Request request, ClusterState state, ActionListener<Response> listener)` or not.
The reason is the only usage for the method changed to call another method `clusterManagerOperation(task, request, clusterState, l)`, which is the default implementation for the method `masterOperation(with task param)`. There is no other usage for the method `masterOperation()` so it's bypassed.

In the commit:
- Change delegation model for method `clusterManagerOperation(with task param)` to call `masterOperation(with task param)`, according to the comment below #4103 (comment)
- Add a test to validate the backwards compatibility, which copied and modified from an existing test.

Signed-off-by: Tianli Feng <ftianli@amazon.com>
(cherry picked from commit 3ab0d1f)
tlfeng pushed a commit that referenced this pull request Aug 3, 2022
…#4115)

The method `protected void masterOperation(Task task, Request request, ClusterState state, ActionListener<Response> listener)` was not properly deprecated by the commit 2a1b239 / PR #403.

There is a problem that it doesn't make any difference to whether overriding the method `void masterOperation(Task task, Request request, ClusterState state, ActionListener<Response> listener)` or not.
The reason is the only usage for the method changed to call another method `clusterManagerOperation(task, request, clusterState, l)`, which is the default implementation for the method `masterOperation(with task param)`. There is no other usage for the method `masterOperation()` so it's bypassed.

In the commit:
- Change delegation model for method `clusterManagerOperation(with task param)` to call `masterOperation(with task param)`, according to the comment below #4103 (comment)
- Add a test to validate the backwards compatibility, which copied and modified from an existing test.

Signed-off-by: Tianli Feng <ftianli@amazon.com>
(cherry picked from commit 3ab0d1f)
@tlfeng tlfeng deleted the masteroperation-bypassed branch August 4, 2022 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch backport 2.2 Backport to 2.2 branch backwards-compatibility bug Something isn't working v2.2.0 v3.0.0 Issues and PRs related to version 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] ClusterManager operations are not called with "task" param
5 participants