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] Adding Transport Actions support for extensions #4598

Conversation

saratvemulapalli
Copy link
Member

@saratvemulapalli saratvemulapalli commented Sep 26, 2022

Signed-off-by: Sarat Vemulapalli vemulapallisarat@gmail.com

Description

Adding transport actions support for extensions via ExtensionMainAction as proxy.

To help understand the workflow:

  • ExtensionsOrchestrator will register the list of actions with one proxy action for all extensions ExtensionMainAction and register it with ActionModule.
  • Extensions make register transport actions[1] and ExtensionActions will manage all actions for all extensions.
  • ExtensionsOrchestrator will respond with Ack to the extension after a successful registration of the action.
  • When a transport request comes along,ExtensionOrchestrator will look up the registry and make a transport action call to the node which will eventually end up on ExtensionsOrchestrator as it registers ExtensionMainAction.
  • ExtensionsOrchestrator will make a transport API call to the extension to process the request.
  • After the response comes back, ExtensionsOrchestrator will translate the response and send it back to the extension which made the request.

[1] https://github.com/opensearch-project/OpenSearch/blob/feature/extensions/server/src/main/java/org/opensearch/extensions/ExtensionsOrchestrator.java#L253

Issues Resolved

opensearch-project/opensearch-sdk-java#106

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: Sarat Vemulapalli <vemulapallisarat@gmail.com>
@saratvemulapalli saratvemulapalli requested review from a team and reta as code owners September 26, 2022 17:39
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

codecov-commenter commented Sep 27, 2022

Codecov Report

Merging #4598 (02841db) into feature/extensions (54b4ad0) will increase coverage by 0.02%.
The diff coverage is 56.58%.

@@                   Coverage Diff                    @@
##             feature/extensions    #4598      +/-   ##
========================================================
+ Coverage                 70.63%   70.65%   +0.02%     
- Complexity                57533    57950     +417     
========================================================
  Files                      4656     4708      +52     
  Lines                    276711   278528    +1817     
  Branches                  40437    40661     +224     
========================================================
+ Hits                     195457   196805    +1348     
- Misses                    64833    65233     +400     
- Partials                  16421    16490      +69     
Impacted Files Coverage Δ
.../java/org/opensearch/client/RequestConverters.java 85.85% <0.00%> (+1.02%) ⬆️
...ava/org/opensearch/client/RestHighLevelClient.java 41.75% <0.00%> (-0.66%) ⬇️
...va/org/opensearch/geometry/GeometryCollection.java 92.85% <0.00%> (-7.15%) ⬇️
...le/customsettings/ExampleCustomSettingsConfig.java 29.03% <ø> (ø)
...le/customsettings/ExampleCustomSettingsPlugin.java 9.09% <ø> (ø)
...igheuristic/CustomSignificanceHeuristicPlugin.java 0.00% <0.00%> (ø)
...ch/example/customsigheuristic/SimpleHeuristic.java 86.66% <ø> (ø)
...earch/example/customsuggester/CustomSuggester.java 0.00% <0.00%> (ø)
...example/customsuggester/CustomSuggesterPlugin.java 0.00% <0.00%> (ø)
...arch/example/customsuggester/CustomSuggestion.java 0.00% <ø> (ø)
... and 647 more

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

Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

Some initial thoughts. Doesn't seem like most of the new code has any tests for it, unless I'm missing something in another PR.

/**
* This class encapsulates a transport request to extension
*
* @opensearch.api
Copy link
Member

Choose a reason for hiding this comment

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

Not necessarily in this PR but someone should open an issue to discuss what extension classes should be api vs. internal. I'm not so sure about this one.

Copy link
Member Author

Choose a reason for hiding this comment

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

So this is a transport request going to an extension. The extension would use it as an API to understand the request.
But sure let me open up and issue for this, I agree we need a little more wider discussion and alignment.

Copy link
Member

Choose a reason for hiding this comment

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

Internals classes are termed as internal which can't be extended. Classes which can be extended are termed as api

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, but are we expecting users to extend this class or is it here for our convenience?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really extend but we expect extensions to use it. Anyway I'll open up an issue for this.
opensearch-project/opensearch-sdk-java#168

Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

registerRequestHandler();
}

public ExtensionActionResponse handleTransportRequest(ExtensionActionRequest request) throws InterruptedException {
Copy link
Member

Choose a reason for hiding this comment

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

handleActionRequest?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, if you like that better.

Copy link
Member

Choose a reason for hiding this comment

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

I like handleTransportAction to differentiate it from handleRestAction etc.

Copy link
Member Author

@saratvemulapalli saratvemulapalli Oct 6, 2022

Choose a reason for hiding this comment

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

I'll leave it as handleTransportAction for now. @owaiskazi19 let us know if you strongly disagree :)

@saratvemulapalli
Copy link
Member Author

saratvemulapalli commented Sep 27, 2022

Some initial thoughts. Doesn't seem like most of the new code has any tests for it, unless I'm missing something in another PR.

You are right. Added all the tests :) Thanks for the review.

* @param transportActionsRequest The request to handle.
* @return A {@link ExtensionBooleanResponse} indicating success.
*/
public TransportResponse handleRegisterTransportActionsRequest(RegisterTransportActionsRequest transportActionsRequest) {
Copy link
Member

Choose a reason for hiding this comment

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

Separate handler class here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Its just one single method, I'd prefer to have all the functionality with the same class as it's taking care of transport actions. If the handlers grow to multiple of them we can start splitting them.


@Override
public void onFailure(Exception exp) {
logger.debug("Transport request failed", exp);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
logger.debug("Transport request failed", exp);
logger.debug("Transport Action request failed", exp);

*
* @opensearch.internal
*/
public class ExtensionTransportAction extends HandledTransportAction<ExtensionActionRequest, ExtensionActionResponse> {
Copy link
Member

Choose a reason for hiding this comment

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

This is really great. We are able to send request from one extension to another. Just wanted to know how did you test it @saratvemulapalli manually? Did you register actions of 2 different extensions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup.

  • registered an action on extension
  • hook up the Rest Handler API in the extension to make a transport request to the same action
  • Expect the orchestrator to get the request, proxy it back to the action
  • Extension responds to the transport action request
  • Orchestrator gets the response, proxy it back to the caller
  • Extension receives the response.

I can paste the logs, but its huge :D

Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2022

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2022

Gradle Check (Jenkins) Run Completed with:

@saratvemulapalli
Copy link
Member Author

Looks like failures from updating lucene snapshots.
Will rebase main with feature/extensions and my PR as well.

[org.opensearch.qa.verify_version_constants.VerifyVersionConstantsIT.testLuceneVersionConstant](https://build.ci.opensearch.org/job/gradle-check/4048/testReport/junit/org.opensearch.qa.verify_version_constants/VerifyVersionConstantsIT/testLuceneVersionConstant/)
[org.opensearch.qa.verify_version_constants.VerifyVersionConstantsIT.testLuceneVersionConstant](https://build.ci.opensearch.org/job/gradle-check/4048/testReport/junit/org.opensearch.qa.verify_version_constants/VerifyVersionConstantsIT/testLuceneVersionConstant_2/)
[org.opensearch.qa.verify_version_constants.VerifyVersionConstantsIT.testLuceneVersionConstant](https://build.ci.opensearch.org/job/gradle-check/4048/testReport/junit/org.opensearch.qa.verify_version_constants/VerifyVersionConstantsIT/testLuceneVersionConstant_3/)
[org.opensearch.qa.verify_version_constants.VerifyVersionConstantsIT.testLuceneVersionConstant](https://build.ci.opensearch.org/job/gradle-check/4048/testReport/junit/org.opensearch.qa.verify_version_constants/VerifyVersionConstantsIT/testLuceneVersionConstant_4/)

Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2022

Gradle Check (Jenkins) Run Completed with:

Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

Approved but have made some suggestions I hope you'll consider.

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
Copy link
Member

Choose a reason for hiding this comment

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

(Suggestion) my IDE tells me to prefer instanceof to getClass() equality. I don't know why. OK as-is, of course.

Copy link
Member

Choose a reason for hiding this comment

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

(Suggestion) my IDE tells me to prefer instanceof to getClass() equality. I don't know why. OK as-is, of course.

@saratvemulapalli So I actually looked up why. It's related to subclassing. If you had a class Foo extends Bar and then wanted to use Bar with anything requiring equals (e.g., hashmap key) and you had two Foo objects that were equal in all other ways but did not override equals themselves, they wouldn't be equal.

My IDE has a checkbox for the equals code generator to switch it to instanceof.

Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2022

Gradle Check (Jenkins) Run Completed with:

Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2022

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2022

Gradle Check (Jenkins) Run Completed with:

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.

4 participants