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

[Extensions] REST API to initialize an extension and dynamically load it #8029

Merged

Conversation

owaiskazi19
Copy link
Member

@owaiskazi19 owaiskazi19 commented Jun 12, 2023

Description

Currently, extensions are initialized in OpenSearch by creating an extensions.yml file. This allows OpenSearch to load the extensions only during the bootstrap. The approach created a chicken-egg problem when the hostAddress and hostPort of the OpenSearch cluster is unknown to extension to send a communication request.

This PR

  • creates a REST API to initialize an extension dynamically. OpenSearch will load the extension based on the request body and then make a communication call to the specific extension and the rest of the workflow will follow.
  • cleans up the old mechanism of creating an extensions.yml file and loading the extensions from it.

Request:
_extensions/initialize

Body:

{
    "name": "ad-extension",
    "uniqueId": "ad-extension",
    "hostAddress": "127.0.0.1",
    "port": "4532",
    "version": "1.0",
    "opensearchVersion": "3.0.0",
    "minimumCompatibleVersion": "3.0.0",
    "dependencies": [{"uniqueId": "test1", "version": "2.0.0"}, {"uniqueId": "test2", "version": "3.0.0"}]
}

Related Issues

Resolves opensearch-project/opensearch-sdk-java#782

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.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Copy link
Member

@joshpalis joshpalis left a comment

Choose a reason for hiding this comment

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

doing an initial pass

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.indices.replication.SegmentReplicationIT.testReplicationPostDeleteAndForceMerge

@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Merging #8029 (f6928dd) into main (2d9a88c) will decrease coverage by 0.13%.
The diff coverage is 65.87%.

@@             Coverage Diff              @@
##               main    #8029      +/-   ##
============================================
- Coverage     70.99%   70.87%   -0.13%     
+ Complexity    56683    56607      -76     
============================================
  Files          4720     4721       +1     
  Lines        267590   267614      +24     
  Branches      39208    39218      +10     
============================================
- Hits         189984   189661     -323     
- Misses        61635    61980     +345     
- Partials      15971    15973       +2     
Impacted Files Coverage Δ
...c/main/java/org/opensearch/bootstrap/Security.java 33.09% <ø> (+0.23%) ⬆️
.../src/main/java/org/opensearch/env/Environment.java 87.78% <ø> (+0.66%) ⬆️
...rch/extensions/rest/RestActionsRequestHandler.java 100.00% <ø> (ø)
...rch/extensions/rest/RestSendToExtensionAction.java 46.66% <ø> (ø)
server/src/main/java/org/opensearch/node/Node.java 85.83% <0.00%> (-0.02%) ⬇️
.../main/java/org/opensearch/action/ActionModule.java 95.03% <33.33%> (-0.47%) ⬇️
...org/opensearch/extensions/ExtensionDependency.java 66.66% <60.00%> (-7.02%) ⬇️
...a/org/opensearch/extensions/ExtensionsManager.java 43.50% <60.52%> (-13.57%) ⬇️
...extensions/rest/RestInitializeExtensionAction.java 73.01% <73.01%> (ø)
...g/opensearch/extensions/NoopExtensionsManager.java 42.85% <100.00%> (-19.65%) ⬇️

... and 463 files with indirect coverage changes

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.remotestore.SegmentReplicationUsingRemoteStoreIT.testDropPrimaryDuringReplication

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
@owaiskazi19 owaiskazi19 force-pushed the initialize-extension-api branch from 2301655 to 183a157 Compare June 21, 2023 20:49
@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: Owais Kazi <owaiskazi19@gmail.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.search.backpressure.SearchBackpressureIT.testSearchShardTaskCancellationWithHighCpu

@owaiskazi19 owaiskazi19 merged commit f015e6a into opensearch-project:main Jun 21, 2023
@owaiskazi19 owaiskazi19 added the backport 2.x Backport to 2.x branch label Jun 21, 2023
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.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-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-8029-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 f015e6a6cc205d1300c852fc731aac90bac3d930
# Push it to GitHub
git push --set-upstream origin backport/backport-8029-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/backport-2.x

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

owaiskazi19 added a commit to owaiskazi19/OpenSearch that referenced this pull request Jun 22, 2023
… it (opensearch-project#8029)

* Implemented REST API for initializing extension

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Cleanup extensions.yml design

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added tests for RestInitializeExtensionAction

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Pulled extensions REST request in extensions directory

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Removed forbidden APIs from rest action and modified tests

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added entry in changelog

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added test for parse

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Addressed PR comments

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Addressed PR comments

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Spotless Fixed

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Handled exceptions

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Handled test failure

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

---------

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
owaiskazi19 added a commit to owaiskazi19/OpenSearch that referenced this pull request Jun 22, 2023
… it (opensearch-project#8029)

* Implemented REST API for initializing extension

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Cleanup extensions.yml design

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added tests for RestInitializeExtensionAction

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Pulled extensions REST request in extensions directory

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Removed forbidden APIs from rest action and modified tests

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added entry in changelog

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added test for parse

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Addressed PR comments

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Addressed PR comments

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Spotless Fixed

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Handled exceptions

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Handled test failure

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

---------

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
owaiskazi19 added a commit to owaiskazi19/OpenSearch that referenced this pull request Jun 22, 2023
… it (opensearch-project#8029)

* Implemented REST API for initializing extension

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Cleanup extensions.yml design

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added tests for RestInitializeExtensionAction

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Pulled extensions REST request in extensions directory

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Removed forbidden APIs from rest action and modified tests

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added entry in changelog

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added test for parse

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Addressed PR comments

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Addressed PR comments

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Spotless Fixed

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Handled exceptions

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Handled test failure

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

---------

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
owaiskazi19 added a commit to owaiskazi19/OpenSearch that referenced this pull request Jun 22, 2023
… it (opensearch-project#8029)

* Implemented REST API for initializing extension

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Cleanup extensions.yml design

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added tests for RestInitializeExtensionAction

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Pulled extensions REST request in extensions directory

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Removed forbidden APIs from rest action and modified tests

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added entry in changelog

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added test for parse

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Addressed PR comments

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Addressed PR comments

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Spotless Fixed

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Handled exceptions

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Handled test failure

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

---------

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
saratvemulapalli pushed a commit that referenced this pull request Jun 26, 2023
… it (#8029) (#8210)

* Implemented REST API for initializing extension



* Cleanup extensions.yml design



* Added tests for RestInitializeExtensionAction



* Pulled extensions REST request in extensions directory



* Removed forbidden APIs from rest action and modified tests



* Added entry in changelog



* Added test for parse



* Addressed PR comments



* Addressed PR comments



* Spotless Fixed



* Handled exceptions



* Handled test failure



---------

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
gaiksaya pushed a commit to gaiksaya/OpenSearch that referenced this pull request Jun 26, 2023
… it (opensearch-project#8029) (opensearch-project#8210)

* Implemented REST API for initializing extension



* Cleanup extensions.yml design



* Added tests for RestInitializeExtensionAction



* Pulled extensions REST request in extensions directory



* Removed forbidden APIs from rest action and modified tests



* Added entry in changelog



* Added test for parse



* Addressed PR comments



* Addressed PR comments



* Spotless Fixed



* Handled exceptions



* Handled test failure



---------

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
imRishN pushed a commit to imRishN/OpenSearch that referenced this pull request Jun 27, 2023
… it (opensearch-project#8029)

* Implemented REST API for initializing extension

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Cleanup extensions.yml design

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added tests for RestInitializeExtensionAction

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Pulled extensions REST request in extensions directory

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Removed forbidden APIs from rest action and modified tests

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added entry in changelog

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added test for parse

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Addressed PR comments

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Addressed PR comments

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Spotless Fixed

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Handled exceptions

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Handled test failure

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

---------

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
… it (opensearch-project#8029)

* Implemented REST API for initializing extension

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Cleanup extensions.yml design

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added tests for RestInitializeExtensionAction

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Pulled extensions REST request in extensions directory

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Removed forbidden APIs from rest action and modified tests

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added entry in changelog

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Added test for parse

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Addressed PR comments

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Addressed PR comments

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Spotless Fixed

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Handled exceptions

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Handled test failure

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

---------

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[META] [BUG] Extension-to-OpenSearch connections have multiple bugs
7 participants