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

[Feature/extensions] Pass REST params and content to extensions #4633

Merged
merged 6 commits into from
Sep 30, 2022

Conversation

dbwiddis
Copy link
Member

@dbwiddis dbwiddis commented Sep 29, 2022

Companion PR on SDK: #163

  • This PR will break SDK build due to a class rename, merge these together.
  • This PR will also break Extension API due to change in package location for ExtensionRestRequest. AD Extension will need to be updated

Description

Passes the params() from the original RestRequest object to extensions. Internally tracks the consumed params (similar to the RestRequest class) when they are consumed with the param(key) method (similar to existing plugin usage).

During the process, realized that the RestExecuteOnExtensionRequest class (here) completely duplicated the ExtensionRestHandler class (in the SDK), so removed the SDK duplicate and renamed the "Execute" class as ExtensionRestHandler.

Additionally added xContentType and content as well as getters for the params that will enable AD extension functionality, and handling the consumed content on the response.

Issues Resolved

Fixes #111

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
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

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: Daniel Widdis <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

codecov-commenter commented Sep 29, 2022

Codecov Report

Merging #4633 (f853429) into feature/extensions (eae2c0b) will increase coverage by 0.00%.
The diff coverage is 52.11%.

❗ Current head f853429 differs from pull request most recent head 63f611b. Consider uploading reports for the commit 63f611b to get more accurate results

@@                  Coverage Diff                  @@
##             feature/extensions    #4633   +/-   ##
=====================================================
  Coverage                 70.62%   70.63%           
- Complexity                57557    57559    +2     
=====================================================
  Files                      4654     4656    +2     
  Lines                    276657   276679   +22     
  Branches                  40427    40429    +2     
=====================================================
+ Hits                     195399   195434   +35     
+ Misses                    64967    64918   -49     
- Partials                  16291    16327   +36     
Impacted Files Coverage Δ
...opensearch/extensions/ExtensionActionListener.java 72.72% <ø> (ø)
...va/org/opensearch/extensions/ExtensionRequest.java 29.41% <ø> (-14.59%) ⬇️
...rch/extensions/rest/RestSendToExtensionAction.java 27.27% <0.00%> (-0.36%) ⬇️
...sions/ExtensionActionListenerOnFailureRequest.java 29.41% <29.41%> (ø)
...ensearch/extensions/rest/ExtensionRestRequest.java 60.52% <60.52%> (ø)
...rch/extensions/ExtensionActionListenerHandler.java 66.66% <66.66%> (ø)
.../opensearch/extensions/ExtensionsOrchestrator.java 66.66% <75.00%> (-4.22%) ⬇️
.../java/org/opensearch/node/NodeClosedException.java 50.00% <0.00%> (-50.00%) ⬇️
...adcast/BroadcastShardOperationFailedException.java 55.55% <0.00%> (-44.45%) ⬇️
.../java/org/opensearch/search/dfs/AggregatedDfs.java 54.83% <0.00%> (-41.94%) ⬇️
... and 479 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@owaiskazi19
Copy link
Member

@dbwiddis we will be needing these params mentioned here too.

@dbwiddis dbwiddis marked this pull request as draft September 29, 2022 19:14
@dbwiddis
Copy link
Member Author

@dbwiddis we will be needing these params mentioned here too.

Got it... the PR includes param and enables hasParam/paramAsLong (though I can add them specifically). Flipping this to draft to look into also passing content and necessary contentParser pieces. I had already considered including that anyway.

Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

Looks great!

*
* @opensearch.api
*/
public class ExtensionRestRequest extends TransportRequest {
Copy link
Member

Choose a reason for hiding this comment

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

New shorter name, huzzah!

@dbwiddis dbwiddis changed the title [Feature/extensions] Pass REST params to extensions [Feature/extensions] Pass REST params and content to extensions Sep 30, 2022
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@dbwiddis dbwiddis marked this pull request as ready for review September 30, 2022 04:01
@dbwiddis
Copy link
Member Author

Ready for review. Gradle check failure is unrelated to this PR.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

public int hashCode() {
return Objects.hash(method, path, params, xContentType, content, principalIdentifierToken);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

nicely done!

@@ -105,12 +108,16 @@ public List<Route> routes() {

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

qq, out of scope of this PR, should we change the method name to handleRequest in TransportRequest.java at some point in future?

@peternied peternied merged commit 54b4ad0 into opensearch-project:feature/extensions Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants