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

[Enhancement] Pass localNode info to all plugins on node start #7919

Merged

Conversation

DarshitChanpura
Copy link
Member

Updates Node start to now pass localNode info so that it is available directly to a plugin instead of hack-y implementation

This deficit was encountered while trying to solve opensearch-project/security#2724 which required localNode information in order to check whether the intercepted requests were for/from localNode.
The approaches tried:

  1. Modifying GuiceHolder to holder localNode value fetched from TransportService. <- unreliable.
  2. Using ClusterState's getLocalNode() <- fails with AssertionError stating that the calling class is not an instance of ClusterStateObserver.
  3. Using ClusterService's localNode() method in OpenSearchSecurityPlugin class's onNodeStarted() implementation <- doesn't contain any value.

And so with recommendation from @reta , implemented this approach.

Related Issues

opensearch-project/security#2724

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.

… directly to a plugin instead of hacky implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
@github-actions
Copy link
Contributor

github-actions bot commented Jun 6, 2023

Gradle Check (Jenkins) Run Completed with:

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

@codecov
Copy link

codecov bot commented Jun 6, 2023

Codecov Report

Merging #7919 (d2a6db3) into main (5dce570) will decrease coverage by 0.15%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##               main    #7919      +/-   ##
============================================
- Coverage     70.93%   70.78%   -0.15%     
+ Complexity    56633    56559      -74     
============================================
  Files          4719     4719              
  Lines        267555   267557       +2     
  Branches      39206    39206              
============================================
- Hits         189778   189393     -385     
- Misses        61721    62140     +419     
+ Partials      16056    16024      -32     
Impacted Files Coverage Δ
server/src/main/java/org/opensearch/node/Node.java 85.85% <100.00%> (ø)
...ain/java/org/opensearch/plugins/ClusterPlugin.java 83.33% <100.00%> (+33.33%) ⬆️

... and 480 files with indirect coverage changes

@github-actions
Copy link
Contributor

github-actions bot commented Jun 6, 2023

Gradle Check (Jenkins) Run Completed with:

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

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@DarshitChanpura
Copy link
Member Author

CI failed with Execution failed for task ':test:fixtures:krb5kdc-fixture:composeBuild'.. It seems unrelated to the changes in this PR.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.search.backpressure.SearchBackpressureIT.testSearchShardTaskCancellationWithHighCpu
      1 org.opensearch.index.ShardIndexingPressureIT.testShardIndexingPressureTrackingDuringBulkWrites
      1 org.opensearch.cluster.allocation.AwarenessAllocationIT.testThreeZoneOneReplicaWithForceZoneValueAndLoadAwareness

…ed and adds a test to check that current plugins are not affect with this implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

Thanks for adding these tests, looks good to me

@DarshitChanpura
Copy link
Member Author

@dblock Would you please review this again?

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@DarshitChanpura
Copy link
Member Author

The CI test failures seem flaky: https://build.ci.opensearch.org/job/gradle-check/17928/

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      3 org.opensearch.remotestore.SegmentReplicationUsingRemoteStoreIT.testDropPrimaryDuringReplication
      1 org.opensearch.search.backpressure.SearchBackpressureIT.testSearchTaskCancellationWithHighCpu

@saratvemulapalli saratvemulapalli requested a review from dblock June 20, 2023 17:45
@saratvemulapalli saratvemulapalli dismissed dblock’s stale review June 20, 2023 21:30

@dblock dismissing your review as tests are added. Feel free to come back to this.

@saratvemulapalli saratvemulapalli merged commit 40d7583 into opensearch-project:main Jun 20, 2023
@saratvemulapalli saratvemulapalli added the backport 2.x Backport to 2.x branch label Jun 20, 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-7919-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 40d758387bd9227314a64a73035260829bfc3c10
# Push it to GitHub
git push --set-upstream origin backport/backport-7919-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-7919-to-2.x.

@reta
Copy link
Collaborator

reta commented Jun 20, 2023

@DarshitChanpura sadly needs manual backport to 2.x

DarshitChanpura added a commit to DarshitChanpura/OpenSearch that referenced this pull request Jun 21, 2023
…earch-project#7919)

* Updates Node start to now pass localNode info so that it is available directly to a plugin instead of hacky implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds this PR to changelog

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Makes onNodeStarted call plugin agnostic

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Marking onNodeStarted() as deprecated

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds a test to verify the behaviour of new signature of onNodeStarted

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Updates test to also check for nodeId

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds instructions to use the overloaded implementation of onNodeStarted and adds a test to check that current plugins are not affect with this implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

---------

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com>
(cherry picked from commit 40d7583)
reta pushed a commit that referenced this pull request Jun 21, 2023
* [Enhancement] Pass localNode info to all plugins on node start (#7919)

* Updates Node start to now pass localNode info so that it is available directly to a plugin instead of hacky implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds this PR to changelog

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Makes onNodeStarted call plugin agnostic

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Marking onNodeStarted() as deprecated

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds a test to verify the behaviour of new signature of onNodeStarted

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Updates test to also check for nodeId

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds instructions to use the overloaded implementation of onNodeStarted and adds a test to check that current plugins are not affect with this implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

---------

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com>
(cherry picked from commit 40d7583)

* Adds a CHANGELOG entry

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

---------

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
gaiksaya pushed a commit to gaiksaya/OpenSearch that referenced this pull request Jun 21, 2023
…earch-project#7919)

* Updates Node start to now pass localNode info so that it is available directly to a plugin instead of hacky implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds this PR to changelog

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Makes onNodeStarted call plugin agnostic

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Marking onNodeStarted() as deprecated

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds a test to verify the behaviour of new signature of onNodeStarted

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Updates test to also check for nodeId

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds instructions to use the overloaded implementation of onNodeStarted and adds a test to check that current plugins are not affect with this implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

---------

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com>
gaiksaya pushed a commit to gaiksaya/OpenSearch that referenced this pull request Jun 26, 2023
…search-project#8192)

* [Enhancement] Pass localNode info to all plugins on node start (opensearch-project#7919)

* Updates Node start to now pass localNode info so that it is available directly to a plugin instead of hacky implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds this PR to changelog

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Makes onNodeStarted call plugin agnostic

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Marking onNodeStarted() as deprecated

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds a test to verify the behaviour of new signature of onNodeStarted

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Updates test to also check for nodeId

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds instructions to use the overloaded implementation of onNodeStarted and adds a test to check that current plugins are not affect with this implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

---------

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com>
(cherry picked from commit 40d7583)

* Adds a CHANGELOG entry

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

---------

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
imRishN pushed a commit to imRishN/OpenSearch that referenced this pull request Jun 27, 2023
…earch-project#7919)

* Updates Node start to now pass localNode info so that it is available directly to a plugin instead of hacky implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds this PR to changelog

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Makes onNodeStarted call plugin agnostic

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Marking onNodeStarted() as deprecated

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds a test to verify the behaviour of new signature of onNodeStarted

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Updates test to also check for nodeId

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds instructions to use the overloaded implementation of onNodeStarted and adds a test to check that current plugins are not affect with this implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

---------

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com>
Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
…earch-project#7919)

* Updates Node start to now pass localNode info so that it is available directly to a plugin instead of hacky implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds this PR to changelog

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Makes onNodeStarted call plugin agnostic

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Marking onNodeStarted() as deprecated

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds a test to verify the behaviour of new signature of onNodeStarted

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Updates test to also check for nodeId

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds instructions to use the overloaded implementation of onNodeStarted and adds a test to check that current plugins are not affect with this implementation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

---------

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.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.

6 participants