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

Support extension additional settings with extension REST initialization #8414

Merged

Conversation

cwperks
Copy link
Member

@cwperks cwperks commented Jul 3, 2023

Description

This PR modifies the RestInitializeExtensionAction to extract any additional settings supplied from ExtensionAwarePlugin.getExtensionSettings <- utilized by the security plugin to define security settings for extensions.

I tested this change by running an extension locally and defining settings from the Security plugin and calling on the API to initialize an extension. I plan to test different types of settings, booleans, strings, arrays, etc to verify this works with different types of settings. I was not able to modify the test to show this working from a test case, but plan to add an automated test ASAP. This PR uses Mockito to partially mock ExtensionsManager to show how additional settings work with the REST endpoint for extension initialization.

Related Issues

Resolves #8032

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: Craig Perkins <cwperx@amazon.com>
@cwperks
Copy link
Member Author

cwperks commented Jul 3, 2023

@owaiskazi19 This PR shows the REST Extension initialization working with settings defined from a plugin like the security plugin.

Signed-off-by: Craig Perkins <cwperx@amazon.com>
@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

Gradle Check (Jenkins) Run Completed with:

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

@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

Gradle Check (Jenkins) Run Completed with:

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

@codecov
Copy link

codecov bot commented Jul 3, 2023

Codecov Report

Merging #8414 (fdb3689) into main (1d22740) will increase coverage by 0.07%.
The diff coverage is 72.50%.

❗ Current head fdb3689 differs from pull request most recent head 4d436d4. Consider uploading reports for the commit 4d436d4 to get more accurate results

@@             Coverage Diff              @@
##               main    #8414      +/-   ##
============================================
+ Coverage     70.81%   70.89%   +0.07%     
- Complexity    56830    56911      +81     
============================================
  Files          4757     4757              
  Lines        269136   269130       -6     
  Branches      39403    39392      -11     
============================================
+ Hits         190585   190789     +204     
+ Misses        62445    62241     -204     
+ Partials      16106    16100       -6     
Impacted Files Coverage Δ
...org/opensearch/extensions/ExtensionDependency.java 73.68% <ø> (+7.01%) ⬆️
...extensions/rest/RestInitializeExtensionAction.java 69.73% <71.79%> (-3.28%) ⬇️
...a/org/opensearch/extensions/ExtensionsManager.java 43.87% <100.00%> (+0.36%) ⬆️

... and 484 files with indirect coverage changes

Signed-off-by: Craig Perkins <cwperx@amazon.com>
@cwperks
Copy link
Member Author

cwperks commented Jul 3, 2023

I was able to successfully setup tests using Mockito to partially mock the extensions manager.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.snapshots.RestoreSnapshotIT.testRestoreInSameRemoteStoreEnabledIndex
      1 org.opensearch.remotestore.SegmentReplicationUsingRemoteStoreIT.testNodeDropWithOngoingReplication

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
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.

Overall LGTM! @dbwiddis need another pair of eyes

cwperks added 3 commits July 3, 2023 16:36
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

Gradle Check (Jenkins) Run Completed with:

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

@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

Gradle Check (Jenkins) Run Completed with:

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

@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.remotestore.SegmentReplicationUsingRemoteStoreIT.testNodeDropWithOngoingReplication
      1 org.opensearch.cluster.allocation.AwarenessAllocationIT.testThreeZoneOneReplicaWithForceZoneValueAndLoadAwareness

@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

Gradle Check (Jenkins) Run Completed with:

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

@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

Gradle Check (Jenkins) Run Completed with:

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

@dbwiddis dbwiddis merged commit a0299fc into opensearch-project:main Jul 4, 2023
@owaiskazi19 owaiskazi19 added the backport 2.x Backport to 2.x branch label Jul 4, 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-8414-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a0299fceda9900f8bfdbf8b0229ad1e8884a4fd4
# Push it to GitHub
git push --set-upstream origin backport/backport-8414-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-8414-to-2.x.

@owaiskazi19
Copy link
Member

@cwperks looks like this one needs a manual backport to 2.x.

cwperks added a commit to cwperks/OpenSearch that referenced this pull request Jul 5, 2023
…ion (opensearch-project#8414)

* Support extension additional settings with extension REST initialization

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add CHANGELOG entry

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add tests

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add addition setting types to test

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Address code review feedback

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Check for missing values

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Use Version.CURRENT

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Switch minimum compat version back to 3.0.0

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Remove hardcoded versions

Signed-off-by: Craig Perkins <cwperx@amazon.com>

---------

Signed-off-by: Craig Perkins <cwperx@amazon.com>
(cherry picked from commit a0299fc)
@cwperks
Copy link
Member Author

cwperks commented Jul 5, 2023

@owaiskazi19 Manual backport created: #8445

owaiskazi19 pushed a commit that referenced this pull request Jul 5, 2023
…EST initialization (#8445)

* Support extension additional settings with extension REST initialization (#8414)

* Support extension additional settings with extension REST initialization

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add CHANGELOG entry

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add tests

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add addition setting types to test

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Address code review feedback

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Check for missing values

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Use Version.CURRENT

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Switch minimum compat version back to 3.0.0

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Remove hardcoded versions

Signed-off-by: Craig Perkins <cwperx@amazon.com>

---------

Signed-off-by: Craig Perkins <cwperx@amazon.com>
(cherry picked from commit a0299fc)

* Update Strings import

Signed-off-by: Craig Perkins <cwperx@amazon.com>

---------

Signed-off-by: Craig Perkins <cwperx@amazon.com>
buddharajusahil pushed a commit to buddharajusahil/OpenSearch that referenced this pull request Jul 18, 2023
…ion (opensearch-project#8414)

* Support extension additional settings with extension REST initialization

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add CHANGELOG entry

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add tests

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add addition setting types to test

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Address code review feedback

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Check for missing values

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Use Version.CURRENT

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Switch minimum compat version back to 3.0.0

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Remove hardcoded versions

Signed-off-by: Craig Perkins <cwperx@amazon.com>

---------

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: sahil buddharaju <sahilbud@amazon.com>
baba-devv pushed a commit to baba-devv/OpenSearch that referenced this pull request Jul 29, 2023
…ion (opensearch-project#8414)

* Support extension additional settings with extension REST initialization

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add CHANGELOG entry

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add tests

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add addition setting types to test

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Address code review feedback

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Check for missing values

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Use Version.CURRENT

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Switch minimum compat version back to 3.0.0

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Remove hardcoded versions

Signed-off-by: Craig Perkins <cwperx@amazon.com>

---------

Signed-off-by: Craig Perkins <cwperx@amazon.com>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
…ion (opensearch-project#8414)

* Support extension additional settings with extension REST initialization

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add CHANGELOG entry

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add tests

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Add addition setting types to test

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Address code review feedback

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Check for missing values

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Use Version.CURRENT

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Switch minimum compat version back to 3.0.0

Signed-off-by: Craig Perkins <cwperx@amazon.com>

* Remove hardcoded versions

Signed-off-by: Craig Perkins <cwperx@amazon.com>

---------

Signed-off-by: Craig Perkins <cwperx@amazon.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.

[Extensions] Create a XContentParser for ExtensionScopedSettings
3 participants