-
Notifications
You must be signed in to change notification settings - Fork 2k
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] Register REST API and forward REST requests to associated extension #4282
[Feature/extensions] Register REST API and forward REST requests to associated extension #4282
Conversation
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
22393b7
to
6199e00
Compare
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Daniel Widdis <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Daniel Widdis <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Daniel Widdis <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Daniel Widdis <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
2564534
to
7ade781
Compare
Gradle Check (Jenkins) Run Completed with:
|
@saratvemulapalli @owaiskazi19 this is ready for your review. I've added tests for everything I think I can; the remainder of things that aren't tested belong in an integration test. Let me know if you think otherwise:
|
Signed-off-by: Daniel Widdis <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
server/src/main/java/org/opensearch/extensions/rest/RestSendToExtensionAction.java
Outdated
Show resolved
Hide resolved
@@ -1165,7 +1165,6 @@ public Node start() throws NodeValidationException { | |||
: "clusterService has a different local node than the factory provided"; | |||
transportService.acceptIncomingRequests(); | |||
extensionsOrchestrator.extensionsInitialize(); | |||
extensionsOrchestrator.setNamedWriteableRegistry(); |
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.
Why are we removing this?
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.
The actions it accomplishes are being moved into the initialize call immediately above it to remove the need for a public setter and more strongly enforce the correct sequencing.
server/src/main/java/org/opensearch/extensions/rest/RestSendToExtensionAction.java
Outdated
Show resolved
Hide resolved
I see we have the logs messages on the issue to explain the workflow. Thanks for adding that. A small request on top of that can we have a small diagram/representation of the code workflow as well to get better understanding of the Register REST APIs?
|
Signed-off-by: Daniel Widdis <[email protected]>
I updated the |
Gradle Check (Jenkins) Run Completed with:
|
Personal preference to help understand the design from the diagram on the issue. You can ignore if you want to :) |
If you can wait until SDK #102 I expect to have a full cradle-to-grave diagram that I think will answer this, so not quite ignoring but deferring to the next PR. |
Gradle Check (Jenkins) Run Completed with:
|
github.com:opensearch-project/OpenSearch into restController Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Codecov Report
@@ Coverage Diff @@
## feature/extensions #4282 +/- ##
========================================================
- Coverage 70.64% 70.54% -0.10%
- Complexity 57195 57275 +80
========================================================
Files 4625 4633 +8
Lines 275473 275817 +344
Branches 40291 40337 +46
========================================================
- Hits 194601 194577 -24
- Misses 64567 64940 +373
+ Partials 16305 16300 -5
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Daniel Widdis <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
There is now a very pretty diagram as part of #109. Enjoy. 😉 |
transportService.sendRequest( | ||
discoveryExtension, | ||
ExtensionsOrchestrator.REQUEST_REST_EXECUTE_ON_EXTENSION_ACTION, | ||
new RestExecuteOnExtensionRequest(method, uri), | ||
restExecuteOnExtensionResponseHandler | ||
); | ||
try { | ||
inProgressLatch.await(5, TimeUnit.SECONDS); | ||
} catch (InterruptedException e) { | ||
return channel -> channel.sendResponse( | ||
new BytesRestResponse(RestStatus.REQUEST_TIMEOUT, "No response from extension to request.") | ||
); | ||
} | ||
} catch (Exception e) { | ||
logger.info("Failed to send REST Actions to extension " + discoveryExtension.getName(), e); | ||
} | ||
String response = responseBuilder.toString(); | ||
if (response.isBlank() || response.startsWith("FAILED")) { | ||
return channel -> channel.sendResponse( | ||
new BytesRestResponse(RestStatus.INTERNAL_SERVER_ERROR, response.isBlank() ? "Request Failed" : response) | ||
); | ||
} | ||
return channel -> channel.sendResponse(new BytesRestResponse(RestStatus.OK, response)); |
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 this @dbwiddis.
You've suggested an improvement to not let the user wait, could you open an issue if you haven't already to discuss a way to optimize it?
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.
I'll think about it. We probably need to implement more RestActions and see how long-running jobs are already handled, so I'm thinking it'll pop up later when it's needed and we can address it then, along with many other incremental changes we'll need.
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.
Really I think this is part of a bigger meta-issue regarding initialization, reachability, etc. SDK #94 touches on some related issues and it can probably be discussed there.
Thanks @dbwiddis for the changes. |
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.
LGTM! Thanks @dbwiddis for all the changes and the design diagram!
Companion PR: opensearch-project/opensearch-sdk-java#101
Description
This and the companion PR linked above completes the work begun in #4100 by registering the received API with the
RestController
. When OpenSearch receives aRestRequest
matching one of these registered routes, it forwards it to the appropriate extension for further action.See the design schematic and description in #64
Issues Resolved
Closes #64, Closes #69, and Closes #70.
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.