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

Generate RestRequest to pass to Rest Handlers #623

Merged
merged 8 commits into from
Mar 30, 2023

Conversation

dbwiddis
Copy link
Member

@dbwiddis dbwiddis commented Mar 29, 2023

Companion PRs (this one must be merged after Core and before AD):

Description

Extensions do not use all the internal components of a RestRequest and initial implementation double-purposed the ExtensionsRestRequest object used in transport as the object that Extensions would need to handle. However, increasing use of the methods on this object are ending up duplicating a lot of code. It makes a lot more sense to just recreate a RestRequest object from the parameters passed in this request.

Issues Resolved

Part of SDK #431.

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.

joshpalis
joshpalis previously approved these changes Mar 30, 2023
Copy link
Member

@saratvemulapalli saratvemulapalli left a comment

Choose a reason for hiding this comment

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

The change makes sense.
I wonder how much of these dependencies we will inherit from OpenSearch.

owaiskazi19
owaiskazi19 previously approved these changes Mar 30, 2023
Copy link
Member

@owaiskazi19 owaiskazi19 left a comment

Choose a reason for hiding this comment

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

Merging this in! We can continue the discussion in the comments/thread

@dbwiddis
Copy link
Member Author

Merging this in! We can continue the discussion in the comments/thread

#605 is still in progress and we can address any lingering questions there as well.

@owaiskazi19
Copy link
Member

owaiskazi19 commented Mar 30, 2023

And a reabse with main is required

> Task :compileJava

> Task :processResources
> Task :classes
/home/runner/work/opensearch-sdk-java/opensearch-sdk-java/src/test/java/org/opensearch/sdk/TestBaseExtensionRestHandler.java:152: error: cannot find symbol
                    uri.append(uri.isEmpty() ? '?' : '&').append(param.getKey()).append('=').append(param.getValue());

@codecov-commenter
Copy link

codecov-commenter commented Mar 30, 2023

Codecov Report

Merging #623 (84a1580) into main (e13aed8) will decrease coverage by 0.73%.
The diff coverage is 53.33%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff              @@
##               main     #623      +/-   ##
============================================
- Coverage     64.09%   63.36%   -0.73%     
- Complexity      252      253       +1     
============================================
  Files            50       50              
  Lines          1103     1122      +19     
  Branches         35       36       +1     
============================================
+ Hits            707      711       +4     
- Misses          385      400      +15     
  Partials         11       11              
Impacted Files Coverage Δ
.../java/org/opensearch/sdk/ExtensionRestHandler.java 100.00% <ø> (ø)
src/main/java/org/opensearch/sdk/RouteHandler.java 100.00% <ø> (ø)
...rch/sdk/handlers/ExtensionsRestRequestHandler.java 30.30% <12.50%> (-17.07%) ⬇️
...a/org/opensearch/sdk/BaseExtensionRestHandler.java 88.00% <100.00%> (ø)
...main/java/org/opensearch/sdk/ExtensionsRunner.java 77.22% <100.00%> (+0.57%) ⬆️
...ch/sdk/sample/helloworld/rest/RestHelloAction.java 80.85% <100.00%> (-4.26%) ⬇️
.../sample/helloworld/rest/RestRemoteHelloAction.java 25.00% <100.00%> (ø)

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

@dbwiddis
Copy link
Member Author

                uri.append(uri.isEmpty() ? '?' : '&').append(param.getKey()).append('=').append(param.getValue());

Turns out isEmpty() is JDK15+, which is why it passed locally. Going back to the old style .length() == 0.

Fixed and rebased to main.

@owaiskazi19 owaiskazi19 merged commit 7b9ccde into opensearch-project:main Mar 30, 2023
@opensearch-trigger-bot
Copy link

The backport to 1.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/backport-1.x 1.x
# Navigate to the new working tree
pushd ../.worktrees/backport-1.x
# Create a new branch
git switch --create backport/backport-623-to-1.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 7b9ccde29e35d4858b290c828e059297610c8555
# Push it to GitHub
git push --set-upstream origin backport/backport-623-to-1.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/backport-1.x

Then, create a pull request where the base branch is 1.x and the compare/head branch is backport/backport-623-to-1.x.

@owaiskazi19
Copy link
Member

owaiskazi19 commented Mar 30, 2023

@dbwiddis the backport failed for 1.x. Can we have a manual PR and clear the difference?

@dbwiddis
Copy link
Member Author

The backport to 1.x failed:

I'll handle this

@dbwiddis
Copy link
Member Author

Probably need backport #628 merged before trying to backport this.

@dbwiddis dbwiddis deleted the restRequest branch March 30, 2023 18:12
@nassipkali
Copy link
Contributor

Should I replace ExtensionRestRequest with RestRequest? If this PR affect my PR then I hope there will be more details.

dbwiddis added a commit to dbwiddis/opensearch-sdk-java that referenced this pull request Mar 30, 2023
* Generate RestRequest to pass to Rest Handlers

* Update Response handling to use RestRequest (needs companion PR)

Signed-off-by: Daniel Widdis <[email protected]>

* Update Extension with new SDK signature (preview of AD extension PR)

Signed-off-by: Daniel Widdis <[email protected]>

* Fix tests

Signed-off-by: Daniel Widdis <[email protected]>

* Less diff on migration, yay!

Signed-off-by: Daniel Widdis <[email protected]>

* Remove stray reference to old type

Signed-off-by: Daniel Widdis <[email protected]>

* Typo fix

Signed-off-by: Daniel Widdis <[email protected]>

* CharSequence isEmpty() is a JDK 15+ feature

Signed-off-by: Daniel Widdis <[email protected]>

---------

Signed-off-by: Daniel Widdis <[email protected]>
@dbwiddis
Copy link
Member Author

Should I replace ExtensionRestRequest with RestRequest? If this PR affect my PR then I hope there will be more details.

Hey @nassipkali sorry for any confusion. This comment on #605 is the latest status and I will post a complete answer to your question on that PR.

owaiskazi19 pushed a commit that referenced this pull request Apr 3, 2023
* Generate RestRequest to pass to Rest Handlers

* Update Response handling to use RestRequest (needs companion PR)



* Update Extension with new SDK signature (preview of AD extension PR)



* Fix tests



* Less diff on migration, yay!



* Remove stray reference to old type



* Typo fix



* CharSequence isEmpty() is a JDK 15+ feature



---------

Signed-off-by: Daniel Widdis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants