Skip to content

Conversation

cwperks
Copy link
Member

@cwperks cwperks commented Jan 15, 2025

Description

This PR removes direct usages of ThreadContext.stashContext and implements a new extension point in core (IdentityAwarePlugin) which assigns this plugin a subject to use for the purposes of executing transport actions outside of the authenticated user context.

With this subject, job-scheduler is permitted to access its own system indices without having to use ThreadContext.stashContext explicitly.

This PR also updates the sample plugin to enable testing with Security.

You can test with security in the sample plugin using a command like this:

./gradlew :opensearch-job-scheduler-sample-extension:integTest -Dhttps=true -Dsecurity.enabled=true  -Dtests.opensearch.secure=true -Dtests.opensearch.username=admin -Dtests.opensearch.password=admin -Duser=admin -Dpassword=admin --tests 'SampleJobRunnerRestIT' -i

Related Issues

Resolves opensearch-project/opensearch-plugins#238

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

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.

@cwperks cwperks closed this Jan 15, 2025
Copy link

codecov bot commented Jan 15, 2025

Codecov Report

❌ Patch coverage is 67.32026% with 100 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.48%. Comparing base (8b2c5fa) to head (3e0913c).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...opensearch/jobscheduler/utils/LockServiceImpl.java 70.10% 41 Missing and 14 partials ⚠️
...obscheduler/rest/action/RestReleaseLockAction.java 0.00% 25 Missing ⚠️
...r/transport/action/TransportGetAllLocksAction.java 80.95% 7 Missing and 1 partial ⚠️
...ensearch/jobscheduler/utils/JobHistoryService.java 80.64% 4 Missing and 2 partials ⚠️
...pensearch/jobscheduler/transport/PluginClient.java 68.75% 4 Missing and 1 partial ⚠️
...rg/opensearch/jobscheduler/JobSchedulerPlugin.java 87.50% 0 Missing and 1 partial ⚠️

❌ Your project status has failed because the head coverage (70.48%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #714      +/-   ##
==========================================
+ Coverage   69.99%   70.48%   +0.48%     
==========================================
  Files          38       41       +3     
  Lines        1733     2053     +320     
  Branches      156      165       +9     
==========================================
+ Hits         1213     1447     +234     
- Misses        430      495      +65     
- Partials       90      111      +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Craig Perkins <[email protected]>
@cwperks cwperks mentioned this pull request Jul 7, 2025
5 tasks
@cwperks cwperks marked this pull request as ready for review July 22, 2025 11:12
@cwperks cwperks changed the title Use pluginSubject for system index interaction and remove usages of stashContext Make LockService and interface and replace usages of ThreadContext.stashContext Aug 7, 2025
cwperks added 3 commits August 7, 2025 15:03
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
@cwperks cwperks changed the title Make LockService and interface and replace usages of ThreadContext.stashContext Make LockService an interface and replace usages of ThreadContext.stashContext Aug 21, 2025
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
@github-project-automation github-project-automation bot moved this from 🏗 In progress to 👀 In Review in Engineering Effectiveness Board Sep 17, 2025
@cwperks cwperks merged commit f01e564 into opensearch-project:main Sep 17, 2025
35 of 40 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In Review to ✅ Done in Engineering Effectiveness Board Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

[META] Remove usages of ThreadContext.stashContext and adopt new mechanism for System Index access

2 participants